summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/zoom
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/zoom')
-rw-r--r--browser/base/content/test/zoom/browser.ini34
-rw-r--r--browser/base/content/test/zoom/browser_background_link_zoom_reset.js45
-rw-r--r--browser/base/content/test/zoom/browser_background_zoom.js115
-rw-r--r--browser/base/content/test/zoom/browser_default_zoom.js149
-rw-r--r--browser/base/content/test/zoom/browser_default_zoom_fission.js114
-rw-r--r--browser/base/content/test/zoom/browser_default_zoom_multitab.js190
-rw-r--r--browser/base/content/test/zoom/browser_default_zoom_multitab_002.js93
-rw-r--r--browser/base/content/test/zoom/browser_default_zoom_sitespecific.js108
-rw-r--r--browser/base/content/test/zoom/browser_image_zoom_tabswitch.js39
-rw-r--r--browser/base/content/test/zoom/browser_mousewheel_zoom.js72
-rw-r--r--browser/base/content/test/zoom/browser_sitespecific_background_pref.js35
-rw-r--r--browser/base/content/test/zoom/browser_sitespecific_image_zoom.js52
-rw-r--r--browser/base/content/test/zoom/browser_sitespecific_video_zoom.js128
-rw-r--r--browser/base/content/test/zoom/browser_subframe_textzoom.js52
-rw-r--r--browser/base/content/test/zoom/browser_tabswitch_zoom_flicker.js45
-rw-r--r--browser/base/content/test/zoom/browser_tooltip_zoom.js41
-rw-r--r--browser/base/content/test/zoom/browser_zoom_commands.js203
-rw-r--r--browser/base/content/test/zoom/head.js223
-rw-r--r--browser/base/content/test/zoom/zoom_test.html14
19 files changed, 1752 insertions, 0 deletions
diff --git a/browser/base/content/test/zoom/browser.ini b/browser/base/content/test/zoom/browser.ini
new file mode 100644
index 0000000000..720cf9b88e
--- /dev/null
+++ b/browser/base/content/test/zoom/browser.ini
@@ -0,0 +1,34 @@
+[DEFAULT]
+support-files =
+ head.js
+ ../general/moz.png
+ zoom_test.html
+
+[browser_background_link_zoom_reset.js]
+https_first_disabled = true
+[browser_background_zoom.js]
+https_first_disabled = true
+[browser_default_zoom.js]
+[browser_default_zoom_fission.js]
+[browser_default_zoom_multitab.js]
+https_first_disabled = true
+[browser_default_zoom_sitespecific.js]
+[browser_image_zoom_tabswitch.js]
+https_first_disabled = true
+skip-if = (os == "mac") #Bug 1526628
+[browser_mousewheel_zoom.js]
+https_first_disabled = true
+[browser_sitespecific_background_pref.js]
+https_first_disabled = true
+[browser_sitespecific_image_zoom.js]
+[browser_sitespecific_video_zoom.js]
+https_first_disabled = true
+support-files =
+ ../general/video.ogg
+skip-if = os == "win" && debug || (verify && debug && (os == 'linux')) # Bug 1315042
+[browser_subframe_textzoom.js]
+[browser_tabswitch_zoom_flicker.js]
+https_first_disabled = true
+skip-if = (debug && os == "linux" && bits == 64) || (!debug && os == "win") # Bug 1652383
+[browser_tooltip_zoom.js]
+[browser_zoom_commands.js]
diff --git a/browser/base/content/test/zoom/browser_background_link_zoom_reset.js b/browser/base/content/test/zoom/browser_background_link_zoom_reset.js
new file mode 100644
index 0000000000..ac224cc4a5
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_background_link_zoom_reset.js
@@ -0,0 +1,45 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+const TEST_PAGE = "/browser/browser/base/content/test/zoom/zoom_test.html";
+var gTestTab, gBgTab, gTestZoom;
+
+function testBackgroundLoad() {
+ (async function () {
+ is(
+ ZoomManager.zoom,
+ gTestZoom,
+ "opening a background tab should not change foreground zoom"
+ );
+
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gBgTab);
+
+ await FullZoom.reset();
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gTestTab);
+ finish();
+ })();
+}
+
+function testInitialZoom() {
+ (async function () {
+ is(ZoomManager.zoom, 1, "initial zoom level should be 1");
+ FullZoom.enlarge();
+
+ gTestZoom = ZoomManager.zoom;
+ isnot(gTestZoom, 1, "zoom level should have changed");
+
+ gBgTab = BrowserTestUtils.addTab(gBrowser);
+ await FullZoomHelper.load(gBgTab, "http://mochi.test:8888" + TEST_PAGE);
+ })().then(testBackgroundLoad, FullZoomHelper.failAndContinue(finish));
+}
+
+function test() {
+ waitForExplicitFinish();
+
+ (async function () {
+ gTestTab = BrowserTestUtils.addTab(gBrowser);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTestTab);
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ await FullZoomHelper.load(gTestTab, "http://example.org" + TEST_PAGE);
+ })().then(testInitialZoom, FullZoomHelper.failAndContinue(finish));
+}
diff --git a/browser/base/content/test/zoom/browser_background_zoom.js b/browser/base/content/test/zoom/browser_background_zoom.js
new file mode 100644
index 0000000000..a4faf29ad9
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_background_zoom.js
@@ -0,0 +1,115 @@
+var gTestPage =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
+var gTestImage =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.org/browser/browser/base/content/test/general/moz.png";
+var gTab1, gTab2, gTab3;
+var gLevel;
+
+function test() {
+ waitForExplicitFinish();
+ registerCleanupFunction(async () => {
+ await new Promise(resolve => {
+ ContentPrefService2.removeByName(FullZoom.name, Cu.createLoadContext(), {
+ handleCompletion: resolve,
+ });
+ });
+ });
+
+ (async function () {
+ gTab1 = BrowserTestUtils.addTab(gBrowser, gTestPage);
+ gTab2 = BrowserTestUtils.addTab(gBrowser);
+ gTab3 = BrowserTestUtils.addTab(gBrowser);
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
+ await FullZoomHelper.load(gTab1, gTestPage);
+ await FullZoomHelper.load(gTab2, gTestPage);
+ })().then(secondPageLoaded, FullZoomHelper.failAndContinue(finish));
+}
+
+function secondPageLoaded() {
+ (async function () {
+ FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1");
+ FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1");
+ FullZoomHelper.zoomTest(gTab3, 1, "Initial zoom of tab 3 should be 1");
+
+ // Now have three tabs, two with the test page, one blank. Tab 1 is selected
+ // Zoom tab 1
+ FullZoom.enlarge();
+ gLevel = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1));
+
+ ok(gLevel > 1, "New zoom for tab 1 should be greater than 1");
+ FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2");
+ FullZoomHelper.zoomTest(gTab3, 1, "Zooming tab 1 should not affect tab 3");
+
+ await FullZoomHelper.load(gTab3, gTestPage);
+ })().then(thirdPageLoaded, FullZoomHelper.failAndContinue(finish));
+}
+
+function thirdPageLoaded() {
+ (async function () {
+ FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed");
+ FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 should still not be affected");
+ FullZoomHelper.zoomTest(
+ gTab3,
+ gLevel,
+ "Tab 3 should have zoomed as it was loading in the background"
+ );
+
+ // Switching to tab 2 should update its zoom setting.
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
+ FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed");
+ FullZoomHelper.zoomTest(gTab2, gLevel, "Tab 2 should be zoomed now");
+ FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should still be zoomed");
+
+ await FullZoomHelper.load(gTab1, gTestImage);
+ })().then(imageLoaded, FullZoomHelper.failAndContinue(finish));
+}
+
+function imageLoaded() {
+ (async function () {
+ FullZoomHelper.zoomTest(
+ gTab1,
+ 1,
+ "Zoom should be 1 when image was loaded in the background"
+ );
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
+ FullZoomHelper.zoomTest(
+ gTab1,
+ 1,
+ "Zoom should still be 1 when tab with image is selected"
+ );
+ })().then(imageZoomSwitch, FullZoomHelper.failAndContinue(finish));
+}
+
+function imageZoomSwitch() {
+ (async function () {
+ await FullZoomHelper.navigate(FullZoomHelper.BACK);
+ await FullZoomHelper.navigate(FullZoomHelper.FORWARD);
+ FullZoomHelper.zoomTest(
+ gTab1,
+ 1,
+ "Tab 1 should not be zoomed when an image loads"
+ );
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
+ FullZoomHelper.zoomTest(
+ gTab1,
+ 1,
+ "Tab 1 should still not be zoomed when deselected"
+ );
+ })().then(finishTest, FullZoomHelper.failAndContinue(finish));
+}
+
+var finishTestStarted = false;
+function finishTest() {
+ (async function () {
+ ok(!finishTestStarted, "finishTest called more than once");
+ finishTestStarted = true;
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gTab3);
+ })().then(finish, FullZoomHelper.failAndContinue(finish));
+}
diff --git a/browser/base/content/test/zoom/browser_default_zoom.js b/browser/base/content/test/zoom/browser_default_zoom.js
new file mode 100644
index 0000000000..bf0533fdad
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_default_zoom.js
@@ -0,0 +1,149 @@
+/* Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_init_default_zoom() {
+ const TEST_PAGE_URL =
+ "data:text/html;charset=utf-8,<body>test_init_default_zoom</body>";
+
+ // Prepare the test tab
+ info("Creating tab");
+ let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser = gBrowser.getBrowserForTab(tab);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
+
+ // 100% global zoom
+ info("Getting default zoom");
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 1, "Global zoom is init at 100%");
+ // 100% tab zoom
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser),
+ 1,
+ "Current zoom is init at 100%"
+ );
+ info("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
+
+add_task(async function test_set_default_zoom() {
+ const TEST_PAGE_URL =
+ "data:text/html;charset=utf-8,<body>test_set_default_zoom</body>";
+
+ // Prepare the test tab
+ info("Creating tab");
+ let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser = gBrowser.getBrowserForTab(tab);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
+
+ // 120% global zoom
+ info("Changing default zoom");
+ await FullZoomHelper.changeDefaultZoom(120);
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 1.2, "Global zoom is at 120%");
+
+ // 120% tab zoom
+ await TestUtils.waitForCondition(() => {
+ info("Current zoom is: " + ZoomManager.getZoomForBrowser(tabBrowser));
+ return ZoomManager.getZoomForBrowser(tabBrowser) == 1.2;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser),
+ 1.2,
+ "Current zoom matches changed default zoom"
+ );
+ info("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+ await FullZoomHelper.changeDefaultZoom(100);
+});
+
+add_task(async function test_enlarge_reduce_reset_local_zoom() {
+ const TEST_PAGE_URL =
+ "data:text/html;charset=utf-8,<body>test_enlarge_reduce_reset_local_zoom</body>";
+
+ // Prepare the test tab
+ info("Creating tab");
+ let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser = gBrowser.getBrowserForTab(tab);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
+
+ // 120% global zoom
+ info("Changing default zoom");
+ await FullZoomHelper.changeDefaultZoom(120);
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 1.2, "Global zoom is at 120%");
+
+ await TestUtils.waitForCondition(() => {
+ info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
+ return ZoomManager.getZoomForBrowser(tabBrowser) == 1.2;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser),
+ 1.2,
+ "Current tab zoom matches default zoom"
+ );
+
+ await FullZoom.enlarge();
+ info("Enlarged!");
+ defaultZoom = await FullZoomHelper.getGlobalValue();
+ info("Current global zoom is " + defaultZoom);
+
+ // 133% tab zoom
+ await TestUtils.waitForCondition(() => {
+ info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
+ return ZoomManager.getZoomForBrowser(tabBrowser) == 1.33;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser),
+ 1.33,
+ "Increasing zoom changes zoom of current tab."
+ );
+ defaultZoom = await FullZoomHelper.getGlobalValue();
+ // 120% global zoom
+ is(
+ defaultZoom,
+ 1.2,
+ "Increasing zoom of current tab doesn't change default zoom."
+ );
+ info("Reducing...");
+ info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
+ await FullZoom.reduce(); // 120% tab zoom
+ info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
+ await FullZoom.reduce(); // 110% tab zoom
+ info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
+ await FullZoom.reduce(); // 100% tab zoom
+ info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
+
+ await TestUtils.waitForCondition(() => {
+ info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
+ return ZoomManager.getZoomForBrowser(tabBrowser) == 1;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser),
+ 1,
+ "Decreasing zoom changes zoom of current tab."
+ );
+ defaultZoom = await FullZoomHelper.getGlobalValue();
+ // 120% global zoom
+ is(
+ defaultZoom,
+ 1.2,
+ "Decreasing zoom of current tab doesn't change default zoom."
+ );
+ info("Resetting...");
+ FullZoom.reset(); // 120% tab zoom
+ await TestUtils.waitForCondition(() => {
+ info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
+ return ZoomManager.getZoomForBrowser(tabBrowser) == 1.2;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser),
+ 1.2,
+ "Reseting zoom causes current tab to zoom to default zoom."
+ );
+
+ // no reset necessary, it was performed as part of the test
+ info("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
diff --git a/browser/base/content/test/zoom/browser_default_zoom_fission.js b/browser/base/content/test/zoom/browser_default_zoom_fission.js
new file mode 100644
index 0000000000..4d3d8b3896
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_default_zoom_fission.js
@@ -0,0 +1,114 @@
+/* Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_sitespecific_iframe_global_zoom() {
+ const TEST_PAGE_URL =
+ 'data:text/html;charset=utf-8,<body>test_sitespecific_iframe_global_zoom<iframe src=""></iframe></body>';
+ const TEST_IFRAME_URL = "https://example.com/";
+
+ // Prepare the test tab
+ console.log("Creating tab");
+ let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser = gBrowser.getBrowserForTab(tab);
+ console.log("Loading tab");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
+
+ // 67% global zoom
+ console.log("Changing default zoom");
+ await FullZoomHelper.changeDefaultZoom(67);
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 0.67, "Global zoom is at 67%");
+ await TestUtils.waitForCondition(() => {
+ console.log("Current zoom is: ", ZoomManager.getZoomForBrowser(tabBrowser));
+ return ZoomManager.getZoomForBrowser(tabBrowser) == 0.67;
+ });
+
+ let zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser).toFixed(2);
+ is(zoomLevel, "0.67", "tab zoom has been set to 67%");
+
+ let frameLoadedPromise = BrowserTestUtils.browserLoaded(
+ tabBrowser,
+ true,
+ TEST_IFRAME_URL
+ );
+ console.log("Spawinging iframe");
+ SpecialPowers.spawn(tabBrowser, [TEST_IFRAME_URL], url => {
+ content.document.querySelector("iframe").src = url;
+ });
+ console.log("Awaiting frame promise");
+ let loadedURL = await frameLoadedPromise;
+ is(loadedURL, TEST_IFRAME_URL, "got the load event for the iframe");
+
+ let frameZoom = await SpecialPowers.spawn(
+ gBrowser.selectedBrowser.browsingContext.children[0],
+ [],
+ async () => {
+ await ContentTaskUtils.waitForCondition(() => {
+ return content.docShell.browsingContext.fullZoom.toFixed(2) == 0.67;
+ });
+ return content.docShell.browsingContext.fullZoom.toFixed(2);
+ }
+ );
+
+ is(frameZoom, zoomLevel, "global zoom is reflected in iframe");
+ console.log("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
+
+add_task(async function test_sitespecific_global_zoom_enlarge() {
+ const TEST_PAGE_URL =
+ 'data:text/html;charset=utf-8,<body>test_sitespecific_global_zoom_enlarge<iframe src=""></iframe></body>';
+ const TEST_IFRAME_URL = "https://example.org/";
+
+ // Prepare the test tab
+ console.log("Adding tab");
+ let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser = gBrowser.getBrowserForTab(tab);
+ console.log("Awaiting tab load");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
+
+ // 67% global zoom persists from previous test
+
+ let frameLoadedPromise = BrowserTestUtils.browserLoaded(
+ tabBrowser,
+ true,
+ TEST_IFRAME_URL
+ );
+ console.log("Spawning iframe");
+ SpecialPowers.spawn(tabBrowser, [TEST_IFRAME_URL], url => {
+ content.document.querySelector("iframe").src = url;
+ });
+ console.log("Awaiting iframe load");
+ let loadedURL = await frameLoadedPromise;
+ is(loadedURL, TEST_IFRAME_URL, "got the load event for the iframe");
+ console.log("Enlarging tab");
+ await FullZoom.enlarge();
+ // 80% local zoom
+ await TestUtils.waitForCondition(() => {
+ console.log("Current zoom is: ", ZoomManager.getZoomForBrowser(tabBrowser));
+ return ZoomManager.getZoomForBrowser(tabBrowser) == 0.8;
+ });
+
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser).toFixed(2),
+ "0.80",
+ "Local zoom is increased"
+ );
+
+ let frameZoom = await SpecialPowers.spawn(
+ gBrowser.selectedBrowser.browsingContext.children[0],
+ [],
+ async () => {
+ await ContentTaskUtils.waitForCondition(() => {
+ return content.docShell.browsingContext.fullZoom.toFixed(2) == 0.8;
+ });
+ return content.docShell.browsingContext.fullZoom.toFixed(2);
+ }
+ );
+
+ is(frameZoom, "0.80", "(without fission) iframe zoom matches page zoom");
+ console.log("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
diff --git a/browser/base/content/test/zoom/browser_default_zoom_multitab.js b/browser/base/content/test/zoom/browser_default_zoom_multitab.js
new file mode 100644
index 0000000000..d204020889
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_default_zoom_multitab.js
@@ -0,0 +1,190 @@
+/* Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_multidomain_global_zoom() {
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ const TEST_PAGE_URL_1 = "http://example.com/";
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ const TEST_PAGE_URL_2 = "http://example.org/";
+
+ // Prepare the test tabs
+ console.log("Creating tab 1");
+ let tab1 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL_1);
+ let tabBrowser1 = gBrowser.getBrowserForTab(tab1);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+
+ console.log("Creating tab 2");
+ let tab2 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL_2);
+ let tabBrowser2 = gBrowser.getBrowserForTab(tab2);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+
+ // 67% global zoom
+ console.log("Changing default zoom");
+ await FullZoomHelper.changeDefaultZoom(67);
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 0.67, "Global zoom is set to 67%");
+
+ // 67% local zoom tab 1
+ console.log("Selecting tab 1");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Currnet zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser1)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.67;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser1),
+ 0.67,
+ "Setting default zoom causes tab 1 (background) to zoom to default zoom."
+ );
+
+ // 67% local zoom tab 2
+ console.log("Selecting tab 2");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser2)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.67;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser2),
+ 0.67,
+ "Setting default zoom causes tab 2 (foreground) to zoom to default zoom."
+ );
+ console.log("Enlarging tab");
+ await FullZoom.enlarge();
+ // 80% local zoom tab 2
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser2)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.8;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser2),
+ 0.8,
+ "Enlarging local zoom of tab 2."
+ );
+
+ // 67% local zoom tab 1
+ console.log("Selecting tab 1");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser1)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.67;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser1),
+ 0.67,
+ "Tab 1 is unchanged by tab 2's enlarge call."
+ );
+ console.log("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+ console.log("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
+
+add_task(async function test_site_specific_global_zoom() {
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ const TEST_PAGE_URL_1 = "http://example.net/";
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ const TEST_PAGE_URL_2 = "http://example.net/";
+
+ // Prepare the test tabs
+ console.log("Adding tab 1");
+ let tab1 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL_1);
+ console.log("Getting tab 1 browser");
+ let tabBrowser1 = gBrowser.getBrowserForTab(tab1);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+
+ console.log("Adding tab 2");
+ let tab2 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL_2);
+ console.log("Getting tab 2 browser");
+ let tabBrowser2 = gBrowser.getBrowserForTab(tab2);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+
+ console.log("checking global zoom");
+ // 67% global zoom persists from previous test
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 0.67, "Default zoom is 67%");
+
+ // 67% local zoom tab 1
+ console.log("Selecting tab 1");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ console.log("Awaiting condition");
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current tab 1 zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser1)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.67;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser1),
+ 0.67,
+ "Setting default zoom causes tab 1 (background) to zoom to default zoom."
+ );
+
+ // 67% local zoom tab 2
+ console.log("Selecting tab 2");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ console.log("Awaiting condition");
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current tab 2 zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser2)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.67;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser2),
+ 0.67,
+ "Setting default zoom causes tab 2 (foreground) to zoom to default zoom."
+ );
+
+ // 80% site specific zoom
+ console.log("Selecting tab 1");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ console.log("Enlarging");
+ await FullZoom.enlarge();
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current tab 1 zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser1)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.8;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser1),
+ 0.8,
+ "Changed local zoom in tab one."
+ );
+ console.log("Selecting tab 2");
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current tab 2 zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser2)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.8;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser2),
+ 0.8,
+ "Second tab respects site specific zoom."
+ );
+ console.log("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+ console.log("Removing tab");
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
diff --git a/browser/base/content/test/zoom/browser_default_zoom_multitab_002.js b/browser/base/content/test/zoom/browser_default_zoom_multitab_002.js
new file mode 100644
index 0000000000..3e85bffa51
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_default_zoom_multitab_002.js
@@ -0,0 +1,93 @@
+/* Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_site_specific_global_zoom() {
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ const TEST_PAGE_URL_1 = "http://example.net";
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ const TEST_PAGE_URL_2 = "http://example.net";
+
+ // Prepare the test tabs
+ console.log("Adding tab 1");
+ let tab1 = BrowserTestUtils.addTab(gBrowser);
+ let tabBrowser1 = gBrowser.getBrowserForTab(tab1);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ await FullZoomHelper.load(tab1, TEST_PAGE_URL_1);
+
+ console.log("Adding tab 2");
+ let tab2 = BrowserTestUtils.addTab(gBrowser);
+ let tabBrowser2 = gBrowser.getBrowserForTab(tab2);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ await FullZoomHelper.load(tab2, TEST_PAGE_URL_2);
+
+ // 67% global zoom
+ await FullZoomHelper.changeDefaultZoom(67);
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 0.67, "Global zoom is set to 67%");
+
+ // 67% local zoom tab 1
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current tab 1 zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser1)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.67;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser1),
+ 0.67,
+ "Setting default zoom causes tab 1 (background) to zoom to default zoom."
+ );
+
+ // 67% local zoom tab 2
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current tab 2 zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser2)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.67;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser2),
+ 0.67,
+ "Setting default zoom causes tab 2 (foreground) to zoom to default zoom."
+ );
+
+ // 80% site specific zoom
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ console.log("Enlarging");
+ await FullZoom.enlarge();
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current tab 1 zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser1)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.8;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser1),
+ 0.8,
+ "Changed local zoom in tab one."
+ );
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ await TestUtils.waitForCondition(() => {
+ console.log(
+ "Current tab 2 zoom is: ",
+ ZoomManager.getZoomForBrowser(tabBrowser2)
+ );
+ return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.8;
+ });
+ is(
+ ZoomManager.getZoomForBrowser(tabBrowser2),
+ 0.8,
+ "Second tab respects site specific zoom."
+ );
+
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
diff --git a/browser/base/content/test/zoom/browser_default_zoom_sitespecific.js b/browser/base/content/test/zoom/browser_default_zoom_sitespecific.js
new file mode 100644
index 0000000000..923f3b687a
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_default_zoom_sitespecific.js
@@ -0,0 +1,108 @@
+/* Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_disabled_ss_multi() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.zoom.siteSpecific", false]],
+ });
+ const TEST_PAGE_URL = "https://example.org/";
+
+ // Prepare the test tabs
+ let tab2 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser2 = gBrowser.getBrowserForTab(tab2);
+ let isLoaded = BrowserTestUtils.browserLoaded(
+ tabBrowser2,
+ false,
+ TEST_PAGE_URL
+ );
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ await isLoaded;
+
+ let zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser2);
+ is(zoomLevel, 1, "tab 2 zoom has been set to 100%");
+
+ let tab1 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser1 = gBrowser.getBrowserForTab(tab1);
+ isLoaded = BrowserTestUtils.browserLoaded(tabBrowser1, false, TEST_PAGE_URL);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ await isLoaded;
+
+ zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser1);
+ is(zoomLevel, 1, "tab 1 zoom has been set to 100%");
+
+ // 67% global zoom
+ await FullZoomHelper.changeDefaultZoom(67);
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 0.67, "Global zoom is at 67%");
+
+ await TestUtils.waitForCondition(
+ () => ZoomManager.getZoomForBrowser(tabBrowser1) == 0.67
+ );
+ zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser1);
+ is(zoomLevel, 0.67, "tab 1 zoom has been set to 67%");
+
+ await FullZoom.enlarge();
+
+ zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser1);
+ is(zoomLevel, 0.8, "tab 1 zoom has been set to 80%");
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser2);
+ is(zoomLevel, 1, "tab 2 zoom remains 100%");
+
+ let tab3 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser3 = gBrowser.getBrowserForTab(tab3);
+ isLoaded = BrowserTestUtils.browserLoaded(tabBrowser3, false, TEST_PAGE_URL);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab3);
+ await isLoaded;
+
+ zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser3);
+ is(zoomLevel, 0.67, "tab 3 zoom has been set to 67%");
+
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
+
+add_task(async function test_disabled_ss_custom() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.zoom.siteSpecific", false]],
+ });
+ const TEST_PAGE_URL = "https://example.org/";
+
+ // 150% global zoom
+ await FullZoomHelper.changeDefaultZoom(150);
+ let defaultZoom = await FullZoomHelper.getGlobalValue();
+ is(defaultZoom, 1.5, "Global zoom is at 150%");
+
+ // Prepare test tab
+ let tab1 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
+ let tabBrowser1 = gBrowser.getBrowserForTab(tab1);
+ let isLoaded = BrowserTestUtils.browserLoaded(
+ tabBrowser1,
+ false,
+ TEST_PAGE_URL
+ );
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ await isLoaded;
+
+ await TestUtils.waitForCondition(
+ () => ZoomManager.getZoomForBrowser(tabBrowser1) == 1.5
+ );
+ let zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser1);
+ is(zoomLevel, 1.5, "tab 1 zoom has been set to 150%");
+
+ await FullZoom.enlarge();
+
+ zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser1);
+ is(zoomLevel, 1.7, "tab 1 zoom has been set to 170%");
+
+ await BrowserTestUtils.reloadTab(tab1);
+
+ zoomLevel = ZoomManager.getZoomForBrowser(tabBrowser1);
+ is(zoomLevel, 1.7, "tab 1 zoom remains 170%");
+
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+});
diff --git a/browser/base/content/test/zoom/browser_image_zoom_tabswitch.js b/browser/base/content/test/zoom/browser_image_zoom_tabswitch.js
new file mode 100644
index 0000000000..83ffab26e8
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_image_zoom_tabswitch.js
@@ -0,0 +1,39 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+function test() {
+ let tab1, tab2;
+ const TEST_IMAGE =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.org/browser/browser/base/content/test/general/moz.png";
+
+ waitForExplicitFinish();
+
+ (async function () {
+ tab1 = BrowserTestUtils.addTab(gBrowser);
+ tab2 = BrowserTestUtils.addTab(gBrowser);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ await FullZoomHelper.load(tab1, TEST_IMAGE);
+
+ is(ZoomManager.zoom, 1, "initial zoom level for first should be 1");
+
+ FullZoom.enlarge();
+ let zoom = ZoomManager.zoom;
+ isnot(zoom, 1, "zoom level should have changed");
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ is(ZoomManager.zoom, 1, "initial zoom level for second tab should be 1");
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ is(
+ ZoomManager.zoom,
+ zoom,
+ "zoom level for first tab should not have changed"
+ );
+
+ await FullZoomHelper.removeTabAndWaitForLocationChange(tab1);
+ await FullZoomHelper.removeTabAndWaitForLocationChange(tab2);
+ })().then(finish, FullZoomHelper.failAndContinue(finish));
+}
diff --git a/browser/base/content/test/zoom/browser_mousewheel_zoom.js b/browser/base/content/test/zoom/browser_mousewheel_zoom.js
new file mode 100644
index 0000000000..a814f1dba6
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_mousewheel_zoom.js
@@ -0,0 +1,72 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const TEST_PAGE =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
+
+var gTab1, gTab2, gLevel1;
+
+function test() {
+ waitForExplicitFinish();
+
+ // Scroll on Ctrl + mousewheel
+ SpecialPowers.pushPrefEnv({ set: [["mousewheel.with_control.action", 3]] });
+
+ (async function () {
+ gTab1 = BrowserTestUtils.addTab(gBrowser);
+ gTab2 = BrowserTestUtils.addTab(gBrowser);
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
+ await FullZoomHelper.load(gTab1, TEST_PAGE);
+ await FullZoomHelper.load(gTab2, TEST_PAGE);
+ })().then(zoomTab1, FullZoomHelper.failAndContinue(finish));
+}
+
+function zoomTab1() {
+ (async function () {
+ is(gBrowser.selectedTab, gTab1, "Tab 1 is selected");
+ FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1");
+ FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1");
+
+ let browser1 = gBrowser.getBrowserForTab(gTab1);
+ await BrowserTestUtils.synthesizeMouse(
+ null,
+ 10,
+ 10,
+ {
+ wheel: true,
+ ctrlKey: true,
+ deltaY: -1,
+ deltaMode: WheelEvent.DOM_DELTA_LINE,
+ },
+ browser1
+ );
+
+ info("Waiting for tab 1 to be zoomed");
+ await TestUtils.waitForCondition(() => {
+ gLevel1 = ZoomManager.getZoomForBrowser(browser1);
+ return gLevel1 > 1;
+ });
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
+ FullZoomHelper.zoomTest(
+ gTab2,
+ gLevel1,
+ "Tab 2 should have zoomed along with tab 1"
+ );
+ })().then(finishTest, FullZoomHelper.failAndContinue(finish));
+}
+
+function finishTest() {
+ (async function () {
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
+ await FullZoom.reset();
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
+ await FullZoom.reset();
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
+ })().then(finish, FullZoomHelper.failAndContinue(finish));
+}
diff --git a/browser/base/content/test/zoom/browser_sitespecific_background_pref.js b/browser/base/content/test/zoom/browser_sitespecific_background_pref.js
new file mode 100644
index 0000000000..5756c4d8d3
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_sitespecific_background_pref.js
@@ -0,0 +1,35 @@
+function test() {
+ waitForExplicitFinish();
+
+ (async function () {
+ let testPage =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
+ let tab1 = BrowserTestUtils.addTab(gBrowser);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
+ await FullZoomHelper.load(tab1, testPage);
+
+ let tab2 = BrowserTestUtils.addTab(gBrowser);
+ await FullZoomHelper.load(tab2, testPage);
+
+ await FullZoom.enlarge();
+ let tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
+ let tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser);
+ is(tab2Zoom, tab1Zoom, "Zoom should affect background tabs");
+
+ Services.prefs.setBoolPref("browser.zoom.updateBackgroundTabs", false);
+ await FullZoom.reset();
+ gBrowser.selectedTab = tab1;
+ tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
+ tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser);
+ isnot(tab1Zoom, tab2Zoom, "Zoom should not affect background tabs");
+
+ if (Services.prefs.prefHasUserValue("browser.zoom.updateBackgroundTabs")) {
+ Services.prefs.clearUserPref("browser.zoom.updateBackgroundTabs");
+ }
+ await FullZoomHelper.removeTabAndWaitForLocationChange(tab1);
+ await FullZoomHelper.removeTabAndWaitForLocationChange(tab2);
+ })().then(finish, FullZoomHelper.failAndContinue(finish));
+}
diff --git a/browser/base/content/test/zoom/browser_sitespecific_image_zoom.js b/browser/base/content/test/zoom/browser_sitespecific_image_zoom.js
new file mode 100644
index 0000000000..fae454fd04
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_sitespecific_image_zoom.js
@@ -0,0 +1,52 @@
+var tabElm, zoomLevel;
+function start_test_prefNotSet() {
+ (async function () {
+ is(ZoomManager.zoom, 1, "initial zoom level should be 1");
+ FullZoom.enlarge();
+
+ // capture the zoom level to test later
+ zoomLevel = ZoomManager.zoom;
+ isnot(zoomLevel, 1, "zoom level should have changed");
+
+ await FullZoomHelper.load(
+ gBrowser.selectedTab,
+ "http://mochi.test:8888/browser/browser/base/content/test/general/moz.png"
+ );
+ })().then(continue_test_prefNotSet, FullZoomHelper.failAndContinue(finish));
+}
+
+function continue_test_prefNotSet() {
+ (async function () {
+ is(ZoomManager.zoom, 1, "zoom level pref should not apply to an image");
+ await FullZoom.reset();
+
+ await FullZoomHelper.load(
+ gBrowser.selectedTab,
+ "http://mochi.test:8888/browser/browser/base/content/test/zoom/zoom_test.html"
+ );
+ })().then(end_test_prefNotSet, FullZoomHelper.failAndContinue(finish));
+}
+
+function end_test_prefNotSet() {
+ (async function () {
+ is(ZoomManager.zoom, zoomLevel, "the zoom level should have persisted");
+
+ // Reset the zoom so that other tests have a fresh zoom level
+ await FullZoom.reset();
+ await FullZoomHelper.removeTabAndWaitForLocationChange();
+ finish();
+ })();
+}
+
+function test() {
+ waitForExplicitFinish();
+
+ (async function () {
+ tabElm = BrowserTestUtils.addTab(gBrowser);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tabElm);
+ await FullZoomHelper.load(
+ tabElm,
+ "http://mochi.test:8888/browser/browser/base/content/test/zoom/zoom_test.html"
+ );
+ })().then(start_test_prefNotSet, FullZoomHelper.failAndContinue(finish));
+}
diff --git a/browser/base/content/test/zoom/browser_sitespecific_video_zoom.js b/browser/base/content/test/zoom/browser_sitespecific_video_zoom.js
new file mode 100644
index 0000000000..ba61a2f5a5
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_sitespecific_video_zoom.js
@@ -0,0 +1,128 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const TEST_PAGE =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
+const TEST_VIDEO =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.org/browser/browser/base/content/test/general/video.ogg";
+
+var gTab1, gTab2, gLevel1;
+
+function test() {
+ waitForExplicitFinish();
+
+ (async function () {
+ gTab1 = BrowserTestUtils.addTab(gBrowser);
+ gTab2 = BrowserTestUtils.addTab(gBrowser);
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
+ await FullZoomHelper.load(gTab1, TEST_PAGE);
+ await FullZoomHelper.load(gTab2, TEST_VIDEO);
+ })().then(zoomTab1, FullZoomHelper.failAndContinue(finish));
+}
+
+function zoomTab1() {
+ (async function () {
+ is(gBrowser.selectedTab, gTab1, "Tab 1 is selected");
+
+ // Reset zoom level if we run this test > 1 time in same browser session.
+ var level1 = ZoomManager.getZoomForBrowser(
+ gBrowser.getBrowserForTab(gTab1)
+ );
+ if (level1 > 1) {
+ FullZoom.reduce();
+ }
+
+ FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1");
+ FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1");
+
+ FullZoom.enlarge();
+ gLevel1 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1));
+
+ ok(gLevel1 > 1, "New zoom for tab 1 should be greater than 1");
+ FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2");
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
+ FullZoomHelper.zoomTest(
+ gTab2,
+ 1,
+ "Tab 2 is still unzoomed after it is selected"
+ );
+ FullZoomHelper.zoomTest(gTab1, gLevel1, "Tab 1 is still zoomed");
+ })().then(zoomTab2, FullZoomHelper.failAndContinue(finish));
+}
+
+function zoomTab2() {
+ (async function () {
+ is(gBrowser.selectedTab, gTab2, "Tab 2 is selected");
+
+ FullZoom.reduce();
+ let level2 = ZoomManager.getZoomForBrowser(
+ gBrowser.getBrowserForTab(gTab2)
+ );
+
+ ok(level2 < 1, "New zoom for tab 2 should be less than 1");
+ FullZoomHelper.zoomTest(
+ gTab1,
+ gLevel1,
+ "Zooming tab 2 should not affect tab 1"
+ );
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
+ FullZoomHelper.zoomTest(
+ gTab1,
+ gLevel1,
+ "Tab 1 should have the same zoom after it's selected"
+ );
+ })().then(testNavigation, FullZoomHelper.failAndContinue(finish));
+}
+
+function testNavigation() {
+ (async function () {
+ await FullZoomHelper.load(gTab1, TEST_VIDEO);
+ FullZoomHelper.zoomTest(
+ gTab1,
+ 1,
+ "Zoom should be 1 when a video was loaded"
+ );
+ await waitForNextTurn(); // trying to fix orange bug 806046
+ await FullZoomHelper.navigate(FullZoomHelper.BACK);
+ FullZoomHelper.zoomTest(
+ gTab1,
+ gLevel1,
+ "Zoom should be restored when a page is loaded"
+ );
+ await waitForNextTurn(); // trying to fix orange bug 806046
+ await FullZoomHelper.navigate(FullZoomHelper.FORWARD);
+ FullZoomHelper.zoomTest(
+ gTab1,
+ 1,
+ "Zoom should be 1 again when navigating back to a video"
+ );
+ })().then(finishTest, FullZoomHelper.failAndContinue(finish));
+}
+
+function waitForNextTurn() {
+ return new Promise(resolve => {
+ setTimeout(() => resolve(), 0);
+ });
+}
+
+var finishTestStarted = false;
+function finishTest() {
+ (async function () {
+ ok(!finishTestStarted, "finishTest called more than once");
+ finishTestStarted = true;
+
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
+ await FullZoom.reset();
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
+ await FullZoom.reset();
+ await FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
+ })().then(finish, FullZoomHelper.failAndContinue(finish));
+}
diff --git a/browser/base/content/test/zoom/browser_subframe_textzoom.js b/browser/base/content/test/zoom/browser_subframe_textzoom.js
new file mode 100644
index 0000000000..e5d40cf585
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_subframe_textzoom.js
@@ -0,0 +1,52 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * Test the fix for bug 441778 to ensure site-specific page zoom doesn't get
+ * modified by sub-document loads of content from a different domain.
+ */
+
+function test() {
+ waitForExplicitFinish();
+
+ const TEST_PAGE_URL = 'data:text/html,<body><iframe src=""></iframe></body>';
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ const TEST_IFRAME_URL = "http://test2.example.org/";
+
+ (async function () {
+ // Prepare the test tab
+ let tab = BrowserTestUtils.addTab(gBrowser);
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
+
+ let testBrowser = tab.linkedBrowser;
+
+ await FullZoomHelper.load(tab, TEST_PAGE_URL);
+
+ // Change the zoom level and then save it so we can compare it to the level
+ // after loading the sub-document.
+ FullZoom.enlarge();
+ var zoomLevel = ZoomManager.zoom;
+
+ // Start the sub-document load.
+ await new Promise(resolve => {
+ executeSoon(function () {
+ BrowserTestUtils.browserLoaded(testBrowser, true).then(url => {
+ is(url, TEST_IFRAME_URL, "got the load event for the iframe");
+ is(
+ ZoomManager.zoom,
+ zoomLevel,
+ "zoom is retained after sub-document load"
+ );
+
+ FullZoomHelper.removeTabAndWaitForLocationChange().then(() =>
+ resolve()
+ );
+ });
+ SpecialPowers.spawn(testBrowser, [TEST_IFRAME_URL], url => {
+ content.document.querySelector("iframe").src = url;
+ });
+ });
+ });
+ })().then(finish, FullZoomHelper.failAndContinue(finish));
+}
diff --git a/browser/base/content/test/zoom/browser_tabswitch_zoom_flicker.js b/browser/base/content/test/zoom/browser_tabswitch_zoom_flicker.js
new file mode 100644
index 0000000000..df1c3816ae
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_tabswitch_zoom_flicker.js
@@ -0,0 +1,45 @@
+var tab;
+
+function test() {
+ // ----------
+ // Test setup
+
+ waitForExplicitFinish();
+
+ Services.prefs.setBoolPref("browser.zoom.updateBackgroundTabs", true);
+ Services.prefs.setBoolPref("browser.zoom.siteSpecific", true);
+
+ let uri =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
+
+ (async function () {
+ tab = BrowserTestUtils.addTab(gBrowser);
+ await FullZoomHelper.load(tab, uri);
+
+ // -------------------------------------------------------------------
+ // Test - Trigger a tab switch that should update the zoom level
+ await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
+ ok(true, "applyPrefToSetting was called");
+ })().then(endTest, FullZoomHelper.failAndContinue(endTest));
+}
+
+// -------------
+// Test clean-up
+function endTest() {
+ (async function () {
+ await FullZoomHelper.removeTabAndWaitForLocationChange(tab);
+
+ tab = null;
+
+ if (Services.prefs.prefHasUserValue("browser.zoom.updateBackgroundTabs")) {
+ Services.prefs.clearUserPref("browser.zoom.updateBackgroundTabs");
+ }
+
+ if (Services.prefs.prefHasUserValue("browser.zoom.siteSpecific")) {
+ Services.prefs.clearUserPref("browser.zoom.siteSpecific");
+ }
+
+ finish();
+ })();
+}
diff --git a/browser/base/content/test/zoom/browser_tooltip_zoom.js b/browser/base/content/test/zoom/browser_tooltip_zoom.js
new file mode 100644
index 0000000000..f7627b1749
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_tooltip_zoom.js
@@ -0,0 +1,41 @@
+add_task(async function test_zoom_tooltip() {
+ const TEST_PAGE_URL = 'data:text/html,<html title="tooltiptext">';
+ await BrowserTestUtils.withNewTab(TEST_PAGE_URL, async function (browser) {
+ FullZoom.setZoom(2.0, browser);
+
+ const tooltip = document.getElementById("remoteBrowserTooltip");
+ const popupShown = new Promise(resolve => {
+ tooltip.addEventListener("popupshown", resolve, { once: true });
+ });
+
+ // Fire a mousemove to trigger the tooltip.
+ // Margin from the anchor and stuff depends on the platform, but these
+ // should be big enough so that all platforms pass, but not big enough so
+ // that it'd pass even when messing up the coordinates would.
+ const DISTANCE = 300;
+ const EPSILON = 25;
+
+ EventUtils.synthesizeMouse(browser, DISTANCE, DISTANCE, {
+ type: "mousemove",
+ });
+
+ await popupShown;
+ ok(
+ true,
+ `popup should be shown (coords: ${tooltip.screenX}, ${tooltip.screenY})`
+ );
+
+ isfuzzy(
+ tooltip.screenX,
+ browser.screenX + DISTANCE,
+ EPSILON,
+ "Should be at the right x position, more or less"
+ );
+ isfuzzy(
+ tooltip.screenY,
+ browser.screenY + DISTANCE,
+ EPSILON,
+ "Should be at the right y position, more or less"
+ );
+ });
+});
diff --git a/browser/base/content/test/zoom/browser_zoom_commands.js b/browser/base/content/test/zoom/browser_zoom_commands.js
new file mode 100644
index 0000000000..88b6f42059
--- /dev/null
+++ b/browser/base/content/test/zoom/browser_zoom_commands.js
@@ -0,0 +1,203 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_PAGE_URL =
+ "data:text/html;charset=utf-8,<body>test_zoom_levels</body>";
+
+/**
+ * Waits for the zoom commands in the window to have the expected enabled
+ * state.
+ *
+ * @param {Object} expectedState
+ * An object where each key represents one of the zoom commands,
+ * and the value is a boolean that is true if the command should
+ * be enabled, and false if it should be disabled.
+ *
+ * The keys are "enlarge", "reduce" and "reset" for readability,
+ * and internally this function maps those keys to the appropriate
+ * commands.
+ * @returns Promise
+ * @resolves undefined
+ */
+async function waitForCommandEnabledState(expectedState) {
+ const COMMAND_MAP = {
+ enlarge: "cmd_fullZoomEnlarge",
+ reduce: "cmd_fullZoomReduce",
+ reset: "cmd_fullZoomReset",
+ };
+
+ await TestUtils.waitForCondition(() => {
+ for (let commandKey in expectedState) {
+ let commandID = COMMAND_MAP[commandKey];
+ let command = document.getElementById(commandID);
+ let expectedEnabled = expectedState[commandKey];
+
+ if (command.hasAttribute("disabled") == expectedEnabled) {
+ return false;
+ }
+ }
+ Assert.ok("Commands finally reached the expected state.");
+ return true;
+ }, "Waiting for commands to reach the right state.");
+}
+
+/**
+ * Tests that the "Zoom Text Only" command is in the right checked
+ * state.
+ *
+ * @param {boolean} isChecked
+ * True if the command should have its "checked" attribute set to
+ * "true". Otherwise, ensures that the attribute is set to "false".
+ */
+function assertTextZoomCommandCheckedState(isChecked) {
+ let command = document.getElementById("cmd_fullZoomToggle");
+ Assert.equal(
+ command.getAttribute("checked"),
+ "" + isChecked,
+ "Text zoom command has expected checked attribute"
+ );
+}
+
+/**
+ * Tests that zoom commands are properly updated when changing
+ * zoom levels and/or preferences on an individual browser.
+ */
+add_task(async function test_update_browser_zoom() {
+ await BrowserTestUtils.withNewTab(TEST_PAGE_URL, async browser => {
+ let currentZoom = await FullZoomHelper.getGlobalValue();
+ Assert.equal(
+ currentZoom,
+ 1,
+ "We expect to start at the default zoom level."
+ );
+
+ await waitForCommandEnabledState({
+ enlarge: true,
+ reduce: true,
+ reset: false,
+ });
+ assertTextZoomCommandCheckedState(false);
+
+ // We'll run two variations of this test - one with text zoom enabled,
+ // and the other without.
+ for (let textZoom of [true, false]) {
+ info(`Running variation with textZoom set to ${textZoom}`);
+
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.zoom.full", !textZoom]],
+ });
+
+ // 120% global zoom
+ info("Changing default zoom by a single level");
+ ZoomManager.zoom = 1.2;
+
+ await waitForCommandEnabledState({
+ enlarge: true,
+ reduce: true,
+ reset: true,
+ });
+ await assertTextZoomCommandCheckedState(textZoom);
+
+ // Now max out the zoom level.
+ ZoomManager.zoom = ZoomManager.MAX;
+
+ await waitForCommandEnabledState({
+ enlarge: false,
+ reduce: true,
+ reset: true,
+ });
+ await assertTextZoomCommandCheckedState(textZoom);
+
+ // Now min out the zoom level.
+ ZoomManager.zoom = ZoomManager.MIN;
+ await waitForCommandEnabledState({
+ enlarge: true,
+ reduce: false,
+ reset: true,
+ });
+ await assertTextZoomCommandCheckedState(textZoom);
+
+ // Now reset back to the default zoom level
+ ZoomManager.zoom = 1;
+ await waitForCommandEnabledState({
+ enlarge: true,
+ reduce: true,
+ reset: false,
+ });
+ await assertTextZoomCommandCheckedState(textZoom);
+ }
+ });
+});
+
+/**
+ * Tests that zoom commands are properly updated when changing
+ * zoom levels when the default zoom is not at 1.0.
+ */
+add_task(async function test_update_browser_zoom() {
+ await BrowserTestUtils.withNewTab(TEST_PAGE_URL, async browser => {
+ let currentZoom = await FullZoomHelper.getGlobalValue();
+ Assert.equal(
+ currentZoom,
+ 1,
+ "We expect to start at the default zoom level."
+ );
+
+ // Now change the default zoom to 200%, which is what we'll switch
+ // back to when choosing to reset the zoom level.
+ //
+ // It's a bit maddening that changeDefaultZoom takes values in integer
+ // units from 30 to 500, whereas ZoomManager.zoom takes things in float
+ // units from 0.3 to 5.0, but c'est la vie for now.
+ await FullZoomHelper.changeDefaultZoom(200);
+ registerCleanupFunction(async () => {
+ await FullZoomHelper.changeDefaultZoom(100);
+ });
+
+ await waitForCommandEnabledState({
+ enlarge: true,
+ reduce: true,
+ reset: false,
+ });
+
+ // 120% global zoom
+ info("Changing default zoom by a single level");
+ ZoomManager.zoom = 2.2;
+
+ await waitForCommandEnabledState({
+ enlarge: true,
+ reduce: true,
+ reset: true,
+ });
+ await assertTextZoomCommandCheckedState(false);
+
+ // Now max out the zoom level.
+ ZoomManager.zoom = ZoomManager.MAX;
+
+ await waitForCommandEnabledState({
+ enlarge: false,
+ reduce: true,
+ reset: true,
+ });
+ await assertTextZoomCommandCheckedState(false);
+
+ // Now min out the zoom level.
+ ZoomManager.zoom = ZoomManager.MIN;
+ await waitForCommandEnabledState({
+ enlarge: true,
+ reduce: false,
+ reset: true,
+ });
+ await assertTextZoomCommandCheckedState(false);
+
+ // Now reset back to the default zoom level
+ ZoomManager.zoom = 2;
+ await waitForCommandEnabledState({
+ enlarge: true,
+ reduce: true,
+ reset: false,
+ });
+ await assertTextZoomCommandCheckedState(false);
+ });
+});
diff --git a/browser/base/content/test/zoom/head.js b/browser/base/content/test/zoom/head.js
new file mode 100644
index 0000000000..d5f09aa5e2
--- /dev/null
+++ b/browser/base/content/test/zoom/head.js
@@ -0,0 +1,223 @@
+/* Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/ */
+
+let gContentPrefs = Cc["@mozilla.org/content-pref/service;1"].getService(
+ Ci.nsIContentPrefService2
+);
+
+let gLoadContext = Cu.createLoadContext();
+
+registerCleanupFunction(async function () {
+ await new Promise(resolve => {
+ gContentPrefs.removeByName(window.FullZoom.name, gLoadContext, {
+ handleResult() {},
+ handleCompletion() {
+ resolve();
+ },
+ });
+ });
+});
+
+var FullZoomHelper = {
+ async changeDefaultZoom(newZoom) {
+ let nonPrivateLoadContext = Cu.createLoadContext();
+ /* Because our setGlobal function takes in a browsing context, and
+ * because we want to keep this property consistent across both private
+ * and non-private contexts, we crate a non-private context and use that
+ * to set the property, regardless of our actual context.
+ */
+
+ let parsedZoomValue = parseFloat((parseInt(newZoom) / 100).toFixed(2));
+ await new Promise(resolve => {
+ gContentPrefs.setGlobal(
+ FullZoom.name,
+ parsedZoomValue,
+ nonPrivateLoadContext,
+ {
+ handleCompletion(reason) {
+ resolve();
+ },
+ }
+ );
+ });
+ // The zoom level is used to update the commands associated with
+ // increasing, decreasing or resetting the Zoom levels. There are
+ // a series of async things we need to wait for (writing the content
+ // pref to the database, and then reading that content pref back out
+ // again and reacting to it), so waiting for the zoom level to reach
+ // the expected level is actually simplest to make sure we're okay to
+ // proceed.
+ await TestUtils.waitForCondition(() => {
+ return ZoomManager.zoom == parsedZoomValue;
+ });
+ },
+
+ async getGlobalValue() {
+ return new Promise(resolve => {
+ let cachedVal = parseFloat(
+ gContentPrefs.getCachedGlobal(FullZoom.name, gLoadContext)
+ );
+ if (cachedVal) {
+ // We've got cached information, though it may be we've cached
+ // an undefined value, or the cached info is invalid. To ensure
+ // a valid return, we opt to return the default 1.0 in the
+ // undefined and invalid cases.
+ resolve(parseFloat(cachedVal.value) || 1.0);
+ return;
+ }
+ let value = 1.0;
+ gContentPrefs.getGlobal(FullZoom.name, gLoadContext, {
+ handleResult(pref) {
+ if (pref.value) {
+ value = parseFloat(pref.value);
+ }
+ },
+ handleCompletion(reason) {
+ resolve(value);
+ },
+ handleError(error) {
+ console.error(error);
+ },
+ });
+ });
+ },
+
+ waitForLocationChange: function waitForLocationChange() {
+ return new Promise(resolve => {
+ Services.obs.addObserver(function obs(subj, topic, data) {
+ Services.obs.removeObserver(obs, topic);
+ resolve();
+ }, "browser-fullZoom:location-change");
+ });
+ },
+
+ selectTabAndWaitForLocationChange: function selectTabAndWaitForLocationChange(
+ tab
+ ) {
+ if (!tab) {
+ throw new Error("tab must be given.");
+ }
+ if (gBrowser.selectedTab == tab) {
+ return Promise.resolve();
+ }
+
+ return Promise.all([
+ BrowserTestUtils.switchTab(gBrowser, tab),
+ this.waitForLocationChange(),
+ ]);
+ },
+
+ removeTabAndWaitForLocationChange: function removeTabAndWaitForLocationChange(
+ tab
+ ) {
+ tab = tab || gBrowser.selectedTab;
+ let selected = gBrowser.selectedTab == tab;
+ gBrowser.removeTab(tab);
+ if (selected) {
+ return this.waitForLocationChange();
+ }
+ return Promise.resolve();
+ },
+
+ load: function load(tab, url) {
+ return new Promise(resolve => {
+ let didLoad = false;
+ let didZoom = false;
+
+ promiseTabLoadEvent(tab, url).then(event => {
+ didLoad = true;
+ if (didZoom) {
+ resolve();
+ }
+ }, true);
+
+ this.waitForLocationChange().then(function () {
+ didZoom = true;
+ if (didLoad) {
+ resolve();
+ }
+ });
+ });
+ },
+
+ zoomTest: function zoomTest(tab, val, msg) {
+ is(ZoomManager.getZoomForBrowser(tab.linkedBrowser), val, msg);
+ },
+
+ BACK: 0,
+ FORWARD: 1,
+ navigate: function navigate(direction) {
+ return new Promise(resolve => {
+ let didPs = false;
+ let didZoom = false;
+
+ BrowserTestUtils.waitForContentEvent(
+ gBrowser.selectedBrowser,
+ "pageshow",
+ true
+ ).then(() => {
+ didPs = true;
+ if (didZoom) {
+ resolve();
+ }
+ });
+
+ if (direction == this.BACK) {
+ gBrowser.goBack();
+ } else if (direction == this.FORWARD) {
+ gBrowser.goForward();
+ }
+
+ this.waitForLocationChange().then(function () {
+ didZoom = true;
+ if (didPs) {
+ resolve();
+ }
+ });
+ });
+ },
+
+ failAndContinue: function failAndContinue(func) {
+ return function (err) {
+ console.error(err);
+ ok(false, err);
+ func();
+ };
+ },
+};
+
+/**
+ * Waits for a load (or custom) event to finish in a given tab. If provided
+ * load an uri into the tab.
+ *
+ * @param tab
+ * The tab to load into.
+ * @param [optional] url
+ * The url to load, or the current url.
+ * @return {Promise} resolved when the event is handled.
+ * @resolves to the received event
+ * @rejects if a valid load event is not received within a meaningful interval
+ */
+async function promiseTabLoadEvent(tab, url) {
+ console.info("Wait tab event: load");
+ if (url) {
+ console.info("Expecting load for: ", url);
+ }
+ function handle(loadedUrl) {
+ if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
+ console.info(`Skipping spurious load event for ${loadedUrl}`);
+ return false;
+ }
+
+ console.info("Tab event received: load");
+ return true;
+ }
+
+ let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
+
+ if (url) {
+ BrowserTestUtils.loadURIString(tab.linkedBrowser, url);
+ }
+
+ return loaded;
+}
diff --git a/browser/base/content/test/zoom/zoom_test.html b/browser/base/content/test/zoom/zoom_test.html
new file mode 100644
index 0000000000..bf80490cad
--- /dev/null
+++ b/browser/base/content/test/zoom/zoom_test.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=416661
+-->
+ <head>
+ <title>Test for zoom setting</title>
+
+ </head>
+ <body>
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=416661">Bug 416661</a>
+ <p>Site specific zoom settings should not apply to image documents.</p>
+ </body>
+</html>