summaryrefslogtreecommitdiffstats
path: root/dom/localstorage/test/browser_private_ls.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/localstorage/test/browser_private_ls.js')
-rw-r--r--dom/localstorage/test/browser_private_ls.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/dom/localstorage/test/browser_private_ls.js b/dom/localstorage/test/browser_private_ls.js
new file mode 100644
index 0000000000..d4708c8e23
--- /dev/null
+++ b/dom/localstorage/test/browser_private_ls.js
@@ -0,0 +1,44 @@
+/**
+ * This test is mainly to verify that datastores are cleared when the last
+ * private browsing context exited.
+ */
+
+async function lsCheckFunc() {
+ let storage = content.localStorage;
+
+ if (storage.length) {
+ return false;
+ }
+
+ // Store non-ASCII value to verify bug 1552428.
+ storage.setItem("foo", "úžasné");
+
+ return true;
+}
+
+function checkTabWindowLS(tab) {
+ return SpecialPowers.spawn(tab.linkedBrowser, [], lsCheckFunc);
+}
+
+add_task(async function() {
+ const pageUrl =
+ "http://example.com/browser/dom/localstorage/test/page_private_ls.html";
+
+ for (let i = 0; i < 2; i++) {
+ let privateWin = await BrowserTestUtils.openNewBrowserWindow({
+ private: true,
+ });
+
+ let privateTab = await BrowserTestUtils.openNewForegroundTab(
+ privateWin.gBrowser,
+ pageUrl
+ );
+
+ ok(
+ await checkTabWindowLS(privateTab),
+ "LS works correctly in a private-browsing page."
+ );
+
+ await BrowserTestUtils.closeWindow(privateWin);
+ }
+});