Bug 1142240 - Add test for opening private window from about:privatebrowsing; r=mossop
☠☠ backed out by 988afda9eac4 ☠ ☠
authorSteven MacLeod <smacleod@mozilla.com>
Wed, 11 Mar 2015 16:36:50 -0400
changeset 234420 b467fad71782b4dad59ef6e98b20dfccb0c4f78d
parent 234419 5bdecf0d7d63629ec8a9ef5a99b0e11c7e03895b
child 234421 1b23439451a8ec0a5f9343c3699547d2efb628ec
push id11848
push usersmacleod@mozilla.com
push dateThu, 19 Mar 2015 17:23:30 +0000
treeherderfx-team@1b23439451a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1142240
milestone39.0a1
Bug 1142240 - Add test for opening private window from about:privatebrowsing; r=mossop
browser/components/privatebrowsing/test/browser/browser.ini
browser/components/privatebrowsing/test/browser/browser_aboutPrivateBrowsing_openWindow.js
browser/components/privatebrowsing/test/browser/head.js
--- a/browser/components/privatebrowsing/test/browser/browser.ini
+++ b/browser/components/privatebrowsing/test/browser/browser.ini
@@ -47,8 +47,9 @@ skip-if = e10s # Bug 940206 -  nsIWebCon
 [browser_privatebrowsing_ui.js]
 [browser_privatebrowsing_urlbarfocus.js]
 [browser_privatebrowsing_windowtitle.js]
 skip-if = e10s
 [browser_privatebrowsing_zoom.js]
 skip-if = e10s
 [browser_privatebrowsing_zoomrestore.js]
 skip-if = e10s
+[browser_aboutPrivateBrowsing_openWindow.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/privatebrowsing/test/browser/browser_aboutPrivateBrowsing_openWindow.js
@@ -0,0 +1,26 @@
+/* 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";
+
+// Test that clicking "Open a Private Window" button on about:privatebrowsing
+// opens a new private window.
+add_task(function* test_aboutprivatebrowsing_open_window() {
+  let win = yield BrowserTestUtils.openNewBrowserWindow();
+  let browser = win.gBrowser.addTab("about:privatebrowsing").linkedBrowser;
+  yield BrowserTestUtils.browserLoaded(browser);
+
+  let promiseWindowOpened = BrowserTestUtils.domWindowOpened();
+  yield ContentTask.spawn(browser, {}, function* () {
+    content.document.getElementById("startPrivateBrowsing").click();
+  });
+  let private_window = yield promiseWindowOpened;
+
+  ok(PrivateBrowsingUtils.isWindowPrivate(private_window),
+     "The opened window should be private.");
+
+  // Cleanup.
+  yield BrowserTestUtils.closeWindow(private_window);
+  yield BrowserTestUtils.closeWindow(win);
+});
--- a/browser/components/privatebrowsing/test/browser/head.js
+++ b/browser/components/privatebrowsing/test/browser/head.js
@@ -1,12 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let {PromiseUtils} = Cu.import("resource://gre/modules/PromiseUtils.jsm", {});
+let {PrivateBrowsingUtils} = Cu.import('resource://gre/modules/PrivateBrowsingUtils.jsm', {})
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
   "resource://testing-common/PlacesTestUtils.jsm");
 
 function whenNewWindowLoaded(aOptions, aCallback) {
   let win = OpenBrowserWindow(aOptions);
   let gotLoad = false;
   let gotActivate = Services.focus.activeWindow == win;