Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 // This test makes sure that about:privatebrowsing does not appear zoomed in
6 // if there is already a zoom site pref for about:blank (bug 487656).
8 function test() {
9 // initialization
10 waitForExplicitFinish();
11 let windowsToClose = [];
12 let windowsToReset = [];
14 function doTestWhenReady(aIsZoomedWindow, aWindow, aCallback) {
15 // Need to wait on two things, the ordering of which is not guaranteed:
16 // (1) the page load, and (2) FullZoom's update to the new page's zoom
17 // level. FullZoom broadcasts "browser-fullZoom:location-change" when its
18 // update is done. (See bug 856366 for details.)
20 let n = 0;
22 let browser = aWindow.gBrowser.selectedBrowser;
23 browser.addEventListener("load", function onLoad() {
24 browser.removeEventListener("load", onLoad, true);
25 if (++n == 2)
26 doTest(aIsZoomedWindow, aWindow, aCallback);
27 }, true);
29 Services.obs.addObserver(function onLocationChange(subj, topic, data) {
30 Services.obs.removeObserver(onLocationChange, topic);
31 if (++n == 2)
32 doTest(aIsZoomedWindow, aWindow, aCallback);
33 }, "browser-fullZoom:location-change", false);
35 browser.loadURI("about:blank");
36 }
38 function doTest(aIsZoomedWindow, aWindow, aCallback) {
39 if (aIsZoomedWindow) {
40 is(aWindow.ZoomManager.zoom, 1,
41 "Zoom level for freshly loaded about:blank should be 1");
42 // change the zoom on the blank page
43 aWindow.FullZoom.enlarge();
44 isnot(aWindow.ZoomManager.zoom, 1, "Zoom level for about:blank should be changed");
45 aCallback();
46 return;
47 }
48 // make sure the zoom level is set to 1
49 is(aWindow.ZoomManager.zoom, 1, "Zoom level for about:privatebrowsing should be reset");
50 aCallback();
51 }
53 function finishTest() {
54 // cleanup
55 windowsToReset.forEach(function(win) {
56 win.FullZoom.reset();
57 });
58 windowsToClose.forEach(function(win) {
59 win.close();
60 });
61 finish();
62 }
64 function testOnWindow(options, callback) {
65 let win = whenNewWindowLoaded(options,
66 function(win) {
67 windowsToClose.push(win);
68 windowsToReset.push(win);
69 executeSoon(function() { callback(win); });
70 });
71 };
73 testOnWindow({}, function(win) {
74 doTestWhenReady(true, win, function() {
75 testOnWindow({private: true}, function(win) {
76 doTestWhenReady(false, win, finishTest);
77 });
78 });
79 });
80 }