summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_bug763468_perwindowpb.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/general/browser_bug763468_perwindowpb.js')
-rw-r--r--browser/base/content/test/general/browser_bug763468_perwindowpb.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_bug763468_perwindowpb.js b/browser/base/content/test/general/browser_bug763468_perwindowpb.js
new file mode 100644
index 000000000..23cb14b8c
--- /dev/null
+++ b/browser/base/content/test/general/browser_bug763468_perwindowpb.js
@@ -0,0 +1,70 @@
+/* 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";
+
+/* globals
+ waitForExplicitFinish, whenNewWindowLoaded, whenNewTabLoaded,
+ executeSoon, registerCleanupFunction, finish, is
+*/
+/* exported test */
+
+// This test makes sure that opening a new tab in private browsing mode opens about:privatebrowsing
+function test() {
+ // initialization
+ waitForExplicitFinish();
+
+ let windowsToClose = [];
+ let newTabURL;
+ let mode;
+
+ function doTest(aIsPrivateMode, aWindow, aCallback) {
+ whenNewTabLoaded(aWindow, function() {
+ if (aIsPrivateMode) {
+ mode = "per window private browsing";
+ newTabURL = "about:privatebrowsing";
+ } else {
+ mode = "normal";
+ newTabURL = "about:newtab";
+ }
+
+ is(aWindow.gBrowser.currentURI.spec, newTabURL,
+ "URL of NewTab should be " + newTabURL + " in " + mode + " mode");
+
+ aWindow.gBrowser.removeTab(aWindow.gBrowser.selectedTab);
+ aCallback();
+ });
+ }
+
+ function testOnWindow(aOptions, aCallback) {
+ whenNewWindowLoaded(aOptions, function(aWin) {
+ windowsToClose.push(aWin);
+ // execute should only be called when need, like when you are opening
+ // web pages on the test. If calling executeSoon() is not necesary, then
+ // call whenNewWindowLoaded() instead of testOnWindow() on your test.
+ executeSoon(() => aCallback(aWin));
+ });
+ }
+
+ // this function is called after calling finish() on the test.
+ registerCleanupFunction(function() {
+ windowsToClose.forEach(function(aWin) {
+ aWin.close();
+ });
+ });
+
+ // test first when not on private mode
+ testOnWindow({}, function(aWin) {
+ doTest(false, aWin, function() {
+ // then test when on private mode
+ testOnWindow({private: true}, function(aWin2) {
+ doTest(true, aWin2, function() {
+ // then test again when not on private mode
+ testOnWindow({}, function(aWin3) {
+ doTest(false, aWin3, finish);
+ });
+ });
+ });
+ });
+ });
+}