Bug 1384522 - Add automated test for TextZoomChange and the urlbar-zoom-button. r=dao
authorJared Wein <jwein@mozilla.com>
Wed, 26 Jul 2017 07:30:03 -0400
changeset 419788 db8bba429daa2c2c9aa5cac79fefcb84b46dced1
parent 419787 39910d1c80f9d0e8f4c4154cc399ae066bd8b07d
child 419789 0886a662636dd8ed8fceb7fbb139f35332c4dd87
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1384522
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1384522 - Add automated test for TextZoomChange and the urlbar-zoom-button. r=dao MozReview-Commit-ID: adhZCyStXz
browser/modules/test/browser/browser_urlBar_zoom.js
--- a/browser/modules/test/browser/browser_urlBar_zoom.js
+++ b/browser/modules/test/browser/browser_urlBar_zoom.js
@@ -2,40 +2,48 @@
   * 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";
 
 var initialPageZoom = ZoomManager.zoom;
 const kTimeoutInMS = 20000;
 
-add_task(async function() {
+async function testZoomButtonAppearsAndDisappearsBasedOnZoomChanges(zoomEventType) {
+  info("Running this test with " + zoomEventType.substring(0, 9));
   info("Confirm whether the browser zoom is set to the default level");
   is(initialPageZoom, 1, "Page zoom is set to default (100%)");
   let zoomResetButton = document.getElementById("urlbar-zoom-button");
   is(zoomResetButton.hidden, true, "Zoom reset button is currently hidden");
 
   info("Change zoom and confirm zoom button appears");
   let labelUpdatePromise = BrowserTestUtils.waitForAttribute("label", zoomResetButton);
   FullZoom.enlarge();
   await labelUpdatePromise;
   info("Zoom increased to " + Math.floor(ZoomManager.zoom * 100) + "%");
   is(zoomResetButton.hidden, false, "Zoom reset button is now visible");
   let pageZoomLevel = Math.floor(ZoomManager.zoom * 100);
   let expectedZoomLevel = 110;
   let buttonZoomLevel = parseInt(zoomResetButton.getAttribute("label"), 10);
   is(buttonZoomLevel, expectedZoomLevel, ("Button label updated successfully to " + Math.floor(ZoomManager.zoom * 100) + "%"));
 
-  let zoomResetPromise = BrowserTestUtils.waitForEvent(window, "FullZoomChange");
+  let zoomResetPromise = BrowserTestUtils.waitForEvent(window, zoomEventType);
   zoomResetButton.click();
   await zoomResetPromise;
   pageZoomLevel = Math.floor(ZoomManager.zoom * 100);
   expectedZoomLevel = 100;
   is(pageZoomLevel, expectedZoomLevel, "Clicking zoom button successfully resets browser zoom to 100%");
   is(zoomResetButton.hidden, true, "Zoom reset button returns to being hidden");
+}
+
+add_task(async function() {
+  await testZoomButtonAppearsAndDisappearsBasedOnZoomChanges("FullZoomChange");
+  await SpecialPowers.pushPrefEnv({"set": [["browser.zoom.full", false]]});
+  await testZoomButtonAppearsAndDisappearsBasedOnZoomChanges("TextZoomChange");
+  await SpecialPowers.pushPrefEnv({"set": [["browser.zoom.full", true]]});
 });
 
 add_task(async function() {
   info("Confirm that URL bar zoom button doesn't appear when customizable zoom widget is added to toolbar");
   CustomizableUI.addWidgetToArea("zoom-controls", CustomizableUI.AREA_NAVBAR);
   let zoomCustomizableWidget = document.getElementById("zoom-reset-button");
   let zoomResetButton = document.getElementById("urlbar-zoom-button");
   let zoomChangePromise = BrowserTestUtils.waitForEvent(window, "FullZoomChange");