summaryrefslogtreecommitdiffstats
path: root/browser/components/originattributes/test/browser/browser_cookieIsolation.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/originattributes/test/browser/browser_cookieIsolation.js')
-rw-r--r--browser/components/originattributes/test/browser/browser_cookieIsolation.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/browser/components/originattributes/test/browser/browser_cookieIsolation.js b/browser/components/originattributes/test/browser/browser_cookieIsolation.js
new file mode 100644
index 000000000..6259723ba
--- /dev/null
+++ b/browser/components/originattributes/test/browser/browser_cookieIsolation.js
@@ -0,0 +1,31 @@
+/**
+ * Bug 1312541 - A test case for document.cookie 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 = "key" + Math.random().toString();
+const re = new RegExp(key + "=([0-9\.]+)");
+
+// Define the testing function
+function* doTest(aBrowser) {
+ return yield ContentTask.spawn(aBrowser, {key, re},
+ function ({key, re}) {
+ let result = re.exec(content.document.cookie);
+ if (result) {
+ return result[1];
+ }
+ // No value is found, so we create one.
+ let value = Math.random().toString();
+ content.document.cookie = key + "=" + value;
+ return value;
+ });
+}
+
+registerCleanupFunction(() => {
+ Services.cookies.removeAll();
+});
+
+IsolationTestTools.runTests(TEST_PAGE, doTest);