diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/modules/test/browser_urlBar_zoom.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/modules/test/browser_urlBar_zoom.js')
-rw-r--r-- | browser/modules/test/browser_urlBar_zoom.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/browser/modules/test/browser_urlBar_zoom.js b/browser/modules/test/browser_urlBar_zoom.js new file mode 100644 index 000000000..9cb5c96c6 --- /dev/null +++ b/browser/modules/test/browser_urlBar_zoom.js @@ -0,0 +1,73 @@ +/* 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"; + +var initialPageZoom = ZoomManager.zoom; +const kTimeoutInMS = 20000; + +add_task(function* () { + 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(); + yield 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 = promiseObserverNotification("browser-fullZoom:zoomReset"); + zoomResetButton.click(); + yield 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(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 = promiseObserverNotification("browser-fullZoom:zoomChange"); + FullZoom.enlarge(); + yield zoomChangePromise; + is(zoomResetButton.hidden, true, "URL zoom button remains hidden despite zoom increase"); + is(parseInt(zoomCustomizableWidget.label, 10), 110, "Customizable zoom widget's label has updated to " + zoomCustomizableWidget.label); +}); + +add_task(function* asyncCleanup() { + // reset zoom level and customizable widget + ZoomManager.zoom = initialPageZoom; + is(ZoomManager.zoom, 1, "Zoom level was restored"); + if (document.getElementById("zoom-controls")) { + CustomizableUI.removeWidgetFromArea("zoom-controls", CustomizableUI.AREA_NAVBAR); + ok(!document.getElementById("zoom-controls"), "Customizable zoom widget removed from toolbar"); + } + +}); + +function promiseObserverNotification(aObserver) { + let deferred = Promise.defer(); + function notificationCallback(e) { + Services.obs.removeObserver(notificationCallback, aObserver, false); + clearTimeout(timeoutId); + deferred.resolve(); + } + let timeoutId = setTimeout(() => { + Services.obs.removeObserver(notificationCallback, aObserver, false); + deferred.reject("Notification '" + aObserver + "' did not happen within 20 seconds."); + }, kTimeoutInMS); + Services.obs.addObserver(notificationCallback, aObserver, false); + return deferred.promise; +} |