Bug 856043 - Test that the Restore Previous Session menu item is not displayed in private mode. r=ehsan
authorIoana Budnar <ioana.budnar@softvision.ro>
Tue, 07 May 2013 15:10:00 +0300
changeset 131116 56be8e218da0
parent 131115 330884194efe
child 131117 23a6b9f4dc69
push id24649
push userryanvm@gmail.com
push dateWed, 08 May 2013 02:10:32 +0000
treeherdermozilla-central@b980d32c366f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs856043
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 856043 - Test that the Restore Previous Session menu item is not displayed in private mode. r=ehsan
browser/components/privatebrowsing/test/browser/Makefile.in
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js
--- a/browser/components/privatebrowsing/test/browser/Makefile.in
+++ b/browser/components/privatebrowsing/test/browser/Makefile.in
@@ -29,16 +29,17 @@ MOCHITEST_BROWSER_FILES =  \
 		browser_privatebrowsing_lastpbcontextexited.js \
 		browser_privatebrowsing_localStorage.js \
 		browser_privatebrowsing_localStorage_before_after.js \
 		browser_privatebrowsing_localStorage_before_after_page.html \
 		browser_privatebrowsing_localStorage_before_after_page2.html \
 		browser_privatebrowsing_localStorage_page1.html \
 		browser_privatebrowsing_localStorage_page2.html \
 		browser_privatebrowsing_nonbrowser.js \
+                browser_privatebrowsing_noSessionRestoreMenuOption.js \
 		browser_privatebrowsing_opendir.js \
 		browser_privatebrowsing_openlocation.js \
 		browser_privatebrowsing_openLocationLastURL.js \
 		browser_privatebrowsing_placestitle.js \
 		browser_privatebrowsing_placesTitleNoUpdate.js \
 		browser_privatebrowsing_placesTitleNoUpdate.html \
 		browser_privatebrowsing_popupblocker.js \
 		browser_privatebrowsing_protocolhandler.js \
new file mode 100644
--- /dev/null
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js
@@ -0,0 +1,34 @@
+/* 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/. */
+
+// This test checks that the Session Restore menu option is not enabled in private mode
+
+function test() {
+  waitForExplicitFinish();
+
+  function testNoSessionRestoreMenuItem() { 
+    let win = OpenBrowserWindow({private: true});
+    win.addEventListener("load", function onLoad() {
+      win.removeEventListener("load", onLoad, false);
+      ok(true, "The second private window got loaded");
+      let srCommand = win.document.getElementById("Browser:RestoreLastSession");
+      ok(srCommand, "The Session Restore command should exist");
+      is(PrivateBrowsingUtils.isWindowPrivate(win), true,
+         "PrivateBrowsingUtils should report the correct per-window private browsing status");
+      is(srCommand.hasAttribute("disabled"), true,
+         "The Session Restore command should be disabled in private browsing mode");
+      win.close();
+      finish();
+    }, false);
+  }
+
+  let win = OpenBrowserWindow({private: true});
+  win.addEventListener("load", function onload() {
+    win.removeEventListener("load", onload, false);
+    ok(true, "The first private window got loaded");
+    win.gBrowser.addTab("about:mozilla");
+    win.close();
+    testNoSessionRestoreMenuItem();
+  }, false);
+}