summaryrefslogtreecommitdiffstats
path: root/browser/components/originattributes/test/browser/browser_localStorageIsolation.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/originattributes/test/browser/browser_localStorageIsolation.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/originattributes/test/browser/browser_localStorageIsolation.js')
-rw-r--r--browser/components/originattributes/test/browser/browser_localStorageIsolation.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/browser/components/originattributes/test/browser/browser_localStorageIsolation.js b/browser/components/originattributes/test/browser/browser_localStorageIsolation.js
new file mode 100644
index 0000000000..68990f6ea4
--- /dev/null
+++ b/browser/components/originattributes/test/browser/browser_localStorageIsolation.js
@@ -0,0 +1,33 @@
+/**
+ * Bug 1264567 - A test case for localStorage isolation.
+ */
+
+const TEST_PAGE =
+ "http://mochi.test:8888/browser/browser/components/" +
+ "originattributes/test/browser/file_firstPartyBasic.html";
+
+// Use a random key so we don't access it in later tests.
+const key = Math.random().toString();
+
+// IsolationTestTools flushes all preferences
+// hence we explicitly pref off https-first mode
+async function prefOffHttpsFirstMode() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["dom.security.https_first", false]],
+ });
+}
+
+// Define the testing function
+function doTest(aBrowser) {
+ return SpecialPowers.spawn(aBrowser, [key], function (contentKey) {
+ let value = content.localStorage.getItem(contentKey);
+ if (value === null) {
+ // No value is found, so we create one.
+ value = Math.random().toString();
+ content.localStorage.setItem(contentKey, value);
+ }
+ return value;
+ });
+}
+
+IsolationTestTools.runTests(TEST_PAGE, doTest, null, prefOffHttpsFirstMode);