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