From a30f6c598abd0ecd2bb7b3633c792ba3e8826010 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 8 Nov 2012 15:32:24 -0500 Subject: [PATCH] Bug 806698 - Port browser_privatebrowsing_theming.js to the new per-window PB APIs; r=jdm --HG-- rename : browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_theming.js => browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_theming.js --- .../test/browser/perwindow/Makefile.in | 1 + .../browser_privatebrowsing_theming.js | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_theming.js diff --git a/browser/components/privatebrowsing/test/browser/perwindow/Makefile.in b/browser/components/privatebrowsing/test/browser/perwindow/Makefile.in index ea1d7f68391..1264b1f4d69 100644 --- a/browser/components/privatebrowsing/test/browser/perwindow/Makefile.in +++ b/browser/components/privatebrowsing/test/browser/perwindow/Makefile.in @@ -19,6 +19,7 @@ MOCHITEST_BROWSER_FILES = \ browser_privatebrowsing_crh.js \ browser_privatebrowsing_lastpbcontextexited.js \ browser_privatebrowsing_opendir.js \ + browser_privatebrowsing_theming.js \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_theming.js b/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_theming.js new file mode 100644 index 00000000000..432f47748e0 --- /dev/null +++ b/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_theming.js @@ -0,0 +1,38 @@ +/* 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 makes sure that privatebrowsingmode attribute of the window is correctly +// adjusted based on whether the window is a private window. + +var windowsToClose = []; +function testOnWindow(options, callback) { + var win = OpenBrowserWindow(options); + win.addEventListener("load", function onLoad() { + win.removeEventListener("load", onLoad, false); + windowsToClose.push(win); + executeSoon(function() callback(win)); + }, false); +} + +registerCleanupFunction(function() { + windowsToClose.forEach(function(win) { + win.close(); + }); +}); + +function test() { + // initialization + waitForExplicitFinish(); + + ok(!document.documentElement.hasAttribute("privatebrowsingmode"), + "privatebrowsingmode should not be present in normal mode"); + + // open a private window + testOnWindow({private: true}, function(win) { + is(win.document.documentElement.getAttribute("privatebrowsingmode"), "temporary", + "privatebrowsingmode should be \"temporary\" inside the private browsing mode"); + + finish(); + }); +}