summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/test_third_party.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/indexedDB/test/test_third_party.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/indexedDB/test/test_third_party.html')
-rw-r--r--dom/indexedDB/test/test_third_party.html103
1 files changed, 103 insertions, 0 deletions
diff --git a/dom/indexedDB/test/test_third_party.html b/dom/indexedDB/test/test_third_party.html
new file mode 100644
index 000000000..91ea44fc3
--- /dev/null
+++ b/dom/indexedDB/test/test_third_party.html
@@ -0,0 +1,103 @@
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+ <title>Indexed Database Test</title>
+
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+ <script type="text/javascript;version=1.7">
+ const BEHAVIOR_ACCEPT = 0;
+ const BEHAVIOR_REJECTFOREIGN = 1;
+ const BEHAVIOR_REJECT = 2;
+ const BEHAVIOR_LIMITFOREIGN = 3;
+
+ const testData = [
+ { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_ACCEPT, expectedResult: true },
+ { host: "http://example.com", cookieBehavior: BEHAVIOR_ACCEPT, expectedResult: true },
+ { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_ACCEPT, expectedResult: true },
+ { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_ACCEPT, expectedResult: true },
+
+ { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECT, expectedResult: false },
+ { host: "http://example.com", cookieBehavior: BEHAVIOR_REJECT, expectedResult: false },
+ { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECT, expectedResult: false },
+ { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECT, expectedResult: false },
+
+ { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResult: true },
+ { host: "http://example.com", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResult: false },
+ { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResult: false },
+ { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResult: true },
+
+ { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResult: true },
+ { host: "http://example.com", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResult: false },
+ { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResult: false },
+ { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResult: true }
+ ];
+
+ const iframe1Path =
+ window.location.pathname.replace("test_third_party.html",
+ "third_party_iframe1.html");
+ const iframe2URL =
+ "http://" + window.location.host +
+ window.location.pathname.replace("test_third_party.html",
+ "third_party_iframe2.html");
+
+ let testIndex = 0;
+ let testRunning = false;
+
+ function iframeLoaded() {
+ let message = { source: "parent", href: iframe2URL };
+ let iframe = document.getElementById("iframe1");
+ iframe.contentWindow.postMessage(message.toSource(), "*");
+ }
+
+ function setiframe() {
+ let iframe = document.getElementById("iframe1");
+
+ if (!testRunning) {
+ testRunning = true;
+ iframe.addEventListener("load", iframeLoaded, false);
+ }
+ SpecialPowers.pushPrefEnv({
+ 'set': [["network.cookie.cookieBehavior", testData[testIndex].cookieBehavior]]
+ }, () => {
+ iframe.src = testData[testIndex].host + iframe1Path;
+ });
+ // SpecialPowers.setIntPref("network.cookie.cookieBehavior", testData[testIndex].cookieBehavior);
+ }
+
+ function messageListener(event) {
+ let message = eval(event.data);
+
+ is(message.source, "iframe", "Good source");
+ is(message.result, testData[testIndex].expectedResult, "Good result");
+
+ if (testIndex < testData.length - 1) {
+ testIndex++;
+ setiframe();
+ return;
+ }
+
+ SimpleTest.finish();
+ }
+
+ function runTest() {
+ SimpleTest.waitForExplicitFinish();
+
+ SpecialPowers.addPermission("indexedDB", true, document);
+
+ window.addEventListener("message", messageListener, false);
+ setiframe();
+ }
+ </script>
+
+</head>
+
+<body onload="runTest();">
+ <iframe id="iframe1"></iframe>
+</body>
+
+</html>