Bug 856043 - Tests to check that session restore buttons from in-content pages are disabled in private mode. r=ehsan
authorIoana Budnar <ioana.budnar@softvision.ro>
Tue, 07 May 2013 14:11:22 +0300
changeset 131115 330884194efe
parent 131114 865b9be24831
child 131116 56be8e218da0
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 - Tests to check that session restore buttons from in-content pages are disabled in private mode. r=ehsan
browser/components/privatebrowsing/test/browser/Makefile.in
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_aboutHomeButtonAfterWindowClose.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_aboutSessionRestore.js
--- a/browser/components/privatebrowsing/test/browser/Makefile.in
+++ b/browser/components/privatebrowsing/test/browser/Makefile.in
@@ -7,16 +7,18 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_BROWSER_FILES =  \
 		head.js \
+                browser_privatebrowsing_aboutHomeButtonAfterWindowClose.js \
+                browser_privatebrowsing_aboutSessionRestore.js \
 		browser_privatebrowsing_certexceptionsui.js \
 		browser_privatebrowsing_concurrent.js \
 		browser_privatebrowsing_concurrent_page.html \
 		browser_privatebrowsing_cookieacceptdialog.js \
 		browser_privatebrowsing_cookieacceptdialog.html \
 		browser_privatebrowsing_crh.js \
 		browser_privatebrowsing_downloadLastDir.js \
 		browser_privatebrowsing_downloadLastDir_c.js \
new file mode 100644
--- /dev/null
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_aboutHomeButtonAfterWindowClose.js
@@ -0,0 +1,46 @@
+/* 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 about:home button
+// is disabled in private mode
+
+function test() {
+  waitForExplicitFinish();
+
+  function testNoSessionRestoreButton() {
+    let win = OpenBrowserWindow({private: true});
+    win.addEventListener("load", function onLoad() {
+      win.removeEventListener("load", onLoad, false);
+      executeSoon(function() {
+        info("The second private window got loaded");
+        let newTab = win.gBrowser.addTab("about:home");
+        win.gBrowser.selectedTab = newTab;
+        let tabBrowser = win.gBrowser.getBrowserForTab(newTab);
+        tabBrowser.addEventListener("load", function tabLoadListener() {
+          tabBrowser.removeEventListener("load", tabLoadListener, true);
+          executeSoon(function() {
+            info("about:home got loaded");
+            let sessionRestoreButton = win.gBrowser
+                                          .contentDocument
+                                          .getElementById("restorePreviousSession");
+            is(win.getComputedStyle(sessionRestoreButton).display, 
+               "none", "The Session Restore about:home button should be disabled");
+            win.close();
+            finish();
+          });
+        }, true);
+      });
+    }, false);
+  }
+
+  let win = OpenBrowserWindow({private: true});
+  win.addEventListener("load", function onload() {
+    win.removeEventListener("load", onload, false);
+    executeSoon(function() {
+      info("The first private window got loaded");
+      win.close();
+      testNoSessionRestoreButton();
+    });
+  }, false);
+}
new file mode 100644
--- /dev/null
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_aboutSessionRestore.js
@@ -0,0 +1,45 @@
+/* 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 button from about:sessionrestore
+// is disabled in private mode
+
+function test() {
+  waitForExplicitFinish();
+
+  function testNoSessionRestoreButton() {
+    let win = OpenBrowserWindow({private: true});
+    win.addEventListener("load", function onLoad() {
+      win.removeEventListener("load", onLoad, false);
+      executeSoon(function() {
+        info("The second private window got loaded");
+        let newTab = win.gBrowser.addTab("about:sessionrestore");
+        win.gBrowser.selectedTab = newTab;
+        let tabBrowser = win.gBrowser.getBrowserForTab(newTab);
+        tabBrowser.addEventListener("load", function tabLoadListener() {
+          tabBrowser.removeEventListener("load", tabLoadListener, true);
+          executeSoon(function() {
+            info("about:sessionrestore got loaded");
+            let restoreButton = win.gBrowser.contentDocument
+                                            .getElementById("errorTryAgain");
+            ok(restoreButton.disabled,
+               "The Restore about:sessionrestore button should be disabled");
+            win.close();
+            finish();
+          });
+        }, true);
+      });
+    }, false);
+  }
+
+  let win = OpenBrowserWindow({private: true});
+  win.addEventListener("load", function onload() {
+    win.removeEventListener("load", onload, false);
+    executeSoon(function() {
+      info("The first private window got loaded");
+      win.close();
+      testNoSessionRestoreButton();
+    });
+  }, false);
+}