From b2ebd7b3f22f03fce920d7df3be256ce9b17ca9a Mon Sep 17 00:00:00 2001 From: Ioana Budnar Date: Tue, 7 May 2013 15:10:00 +0300 Subject: [PATCH] Bug 856043 - Test that the Restore Previous Session menu item is not displayed in private mode. r=ehsan --- .../privatebrowsing/test/browser/Makefile.in | 1 + ...vatebrowsing_noSessionRestoreMenuOption.js | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js diff --git a/browser/components/privatebrowsing/test/browser/Makefile.in b/browser/components/privatebrowsing/test/browser/Makefile.in index f6472411522..f15d6056b25 100644 --- a/browser/components/privatebrowsing/test/browser/Makefile.in +++ b/browser/components/privatebrowsing/test/browser/Makefile.in @@ -34,6 +34,7 @@ MOCHITEST_BROWSER_FILES = \ 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 \ diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js new file mode 100644 index 00000000000..32919c83450 --- /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); +}