michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // This test makes sure that about:privatebrowsing does not appear zoomed in michael@0: // if there is already a zoom site pref for about:blank (bug 487656). michael@0: michael@0: function test() { michael@0: // initialization michael@0: waitForExplicitFinish(); michael@0: let windowsToClose = []; michael@0: let windowsToReset = []; michael@0: michael@0: function doTestWhenReady(aIsZoomedWindow, aWindow, aCallback) { michael@0: // Need to wait on two things, the ordering of which is not guaranteed: michael@0: // (1) the page load, and (2) FullZoom's update to the new page's zoom michael@0: // level. FullZoom broadcasts "browser-fullZoom:location-change" when its michael@0: // update is done. (See bug 856366 for details.) michael@0: michael@0: let n = 0; michael@0: michael@0: let browser = aWindow.gBrowser.selectedBrowser; michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: if (++n == 2) michael@0: doTest(aIsZoomedWindow, aWindow, aCallback); michael@0: }, true); michael@0: michael@0: Services.obs.addObserver(function onLocationChange(subj, topic, data) { michael@0: Services.obs.removeObserver(onLocationChange, topic); michael@0: if (++n == 2) michael@0: doTest(aIsZoomedWindow, aWindow, aCallback); michael@0: }, "browser-fullZoom:location-change", false); michael@0: michael@0: browser.loadURI("about:blank"); michael@0: } michael@0: michael@0: function doTest(aIsZoomedWindow, aWindow, aCallback) { michael@0: if (aIsZoomedWindow) { michael@0: is(aWindow.ZoomManager.zoom, 1, michael@0: "Zoom level for freshly loaded about:blank should be 1"); michael@0: // change the zoom on the blank page michael@0: aWindow.FullZoom.enlarge(); michael@0: isnot(aWindow.ZoomManager.zoom, 1, "Zoom level for about:blank should be changed"); michael@0: aCallback(); michael@0: return; michael@0: } michael@0: // make sure the zoom level is set to 1 michael@0: is(aWindow.ZoomManager.zoom, 1, "Zoom level for about:privatebrowsing should be reset"); michael@0: aCallback(); michael@0: } michael@0: michael@0: function finishTest() { michael@0: // cleanup michael@0: windowsToReset.forEach(function(win) { michael@0: win.FullZoom.reset(); michael@0: }); michael@0: windowsToClose.forEach(function(win) { michael@0: win.close(); michael@0: }); michael@0: finish(); michael@0: } michael@0: michael@0: function testOnWindow(options, callback) { michael@0: let win = whenNewWindowLoaded(options, michael@0: function(win) { michael@0: windowsToClose.push(win); michael@0: windowsToReset.push(win); michael@0: executeSoon(function() { callback(win); }); michael@0: }); michael@0: }; michael@0: michael@0: testOnWindow({}, function(win) { michael@0: doTestWhenReady(true, win, function() { michael@0: testOnWindow({private: true}, function(win) { michael@0: doTestWhenReady(false, win, finishTest); michael@0: }); michael@0: }); michael@0: }); michael@0: }