browser/base/content/test/general/browser_bug763468_perwindowpb.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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 opening a new tab in private browsing mode opens about:privatebrowsing
michael@0 6 function test() {
michael@0 7 // initialization
michael@0 8 waitForExplicitFinish();
michael@0 9 let windowsToClose = [];
michael@0 10 let newTab;
michael@0 11 let newTabPrefName = "browser.newtab.url";
michael@0 12 let newTabURL;
michael@0 13 let mode;
michael@0 14
michael@0 15 function doTest(aIsPrivateMode, aWindow, aCallback) {
michael@0 16 whenNewTabLoaded(aWindow, function () {
michael@0 17 if (aIsPrivateMode) {
michael@0 18 mode = "per window private browsing";
michael@0 19 newTabURL = "about:privatebrowsing";
michael@0 20 } else {
michael@0 21 mode = "normal";
michael@0 22 newTabURL = Services.prefs.getCharPref(newTabPrefName) || "about:blank";
michael@0 23 }
michael@0 24
michael@0 25 is(aWindow.gBrowser.currentURI.spec, newTabURL,
michael@0 26 "URL of NewTab should be " + newTabURL + " in " + mode + " mode");
michael@0 27
michael@0 28 aWindow.gBrowser.removeTab(aWindow.gBrowser.selectedTab);
michael@0 29 aCallback()
michael@0 30 });
michael@0 31 };
michael@0 32
michael@0 33 function testOnWindow(aOptions, aCallback) {
michael@0 34 whenNewWindowLoaded(aOptions, function(aWin) {
michael@0 35 windowsToClose.push(aWin);
michael@0 36 // execute should only be called when need, like when you are opening
michael@0 37 // web pages on the test. If calling executeSoon() is not necesary, then
michael@0 38 // call whenNewWindowLoaded() instead of testOnWindow() on your test.
michael@0 39 executeSoon(function() aCallback(aWin));
michael@0 40 });
michael@0 41 };
michael@0 42
michael@0 43 // this function is called after calling finish() on the test.
michael@0 44 registerCleanupFunction(function() {
michael@0 45 windowsToClose.forEach(function(aWin) {
michael@0 46 aWin.close();
michael@0 47 });
michael@0 48 });
michael@0 49
michael@0 50 // test first when not on private mode
michael@0 51 testOnWindow({}, function(aWin) {
michael@0 52 doTest(false, aWin, function() {
michael@0 53 // then test when on private mode
michael@0 54 testOnWindow({private: true}, function(aWin) {
michael@0 55 doTest(true, aWin, function() {
michael@0 56 // then test again when not on private mode
michael@0 57 testOnWindow({}, function(aWin) {
michael@0 58 doTest(false, aWin, finish);
michael@0 59 });
michael@0 60 });
michael@0 61 });
michael@0 62 });
michael@0 63 });
michael@0 64 }

mercurial