summaryrefslogtreecommitdiffstats
path: root/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js')
-rw-r--r--browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js
new file mode 100644
index 0000000000..3537236068
--- /dev/null
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.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/. */
+
+// Ensure that a storage instance used by both private and public sessions at different times does not
+// allow any data to leak due to cached values.
+
+// Step 1: Load browser_privatebrowsing_localStorage_before_after_page.html in a private tab, causing a storage
+// item to exist. Close the tab.
+// Step 2: Load the same page in a non-private tab, ensuring that the storage instance reports only one item
+// existing.
+
+add_task(async function test() {
+ let prefix =
+ "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/";
+
+ // Step 1.
+ let privateWin = await BrowserTestUtils.openNewBrowserWindow({
+ private: true,
+ });
+ let testURL =
+ prefix + "browser_privatebrowsing_localStorage_before_after_page.html";
+ await BrowserTestUtils.openNewForegroundTab(privateWin.gBrowser, testURL);
+
+ is(
+ privateWin.gBrowser.selectedBrowser.contentTitle,
+ "1",
+ "localStorage should contain 1 item"
+ );
+
+ // Step 2.
+ let win = await BrowserTestUtils.openNewBrowserWindow();
+ testURL =
+ prefix + "browser_privatebrowsing_localStorage_before_after_page2.html";
+ await BrowserTestUtils.openNewForegroundTab(win.gBrowser, testURL);
+
+ is(
+ win.gBrowser.selectedBrowser.contentTitle,
+ "null|0",
+ "localStorage should contain 0 items"
+ );
+
+ // Cleanup
+ await BrowserTestUtils.closeWindow(privateWin);
+ await BrowserTestUtils.closeWindow(win);
+});