dom/indexedDB/test/test_third_party.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <!--
michael@0 2 Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 -->
michael@0 5 <html>
michael@0 6 <head>
michael@0 7 <title>Indexed Database Test</title>
michael@0 8
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11
michael@0 12 <script type="text/javascript;version=1.7">
michael@0 13 const testData = [
michael@0 14 { host: "http://" + window.location.host, expectedResult: true },
michael@0 15 { host: "http://example.com", expectedResult: false },
michael@0 16 { host: "http://sub1.test2.example.org:8000", expectedResult: false },
michael@0 17 { host: "http://" + window.location.host, expectedResult: true }
michael@0 18 ];
michael@0 19
michael@0 20 const iframe1Path =
michael@0 21 window.location.pathname.replace("test_third_party.html",
michael@0 22 "third_party_iframe1.html");
michael@0 23 const iframe2URL =
michael@0 24 "http://" + window.location.host +
michael@0 25 window.location.pathname.replace("test_third_party.html",
michael@0 26 "third_party_iframe2.html");
michael@0 27
michael@0 28 let testIndex = 0;
michael@0 29 let testRunning = false;
michael@0 30
michael@0 31 function iframeLoaded() {
michael@0 32 let message = { source: "parent", href: iframe2URL };
michael@0 33 let iframe = document.getElementById("iframe1");
michael@0 34 iframe.contentWindow.postMessage(message.toSource(), "*");
michael@0 35 }
michael@0 36
michael@0 37 function setiframe() {
michael@0 38 let iframe = document.getElementById("iframe1");
michael@0 39
michael@0 40 if (!testRunning) {
michael@0 41 testRunning = true;
michael@0 42 iframe.addEventListener("load", iframeLoaded, false);
michael@0 43 }
michael@0 44
michael@0 45 iframe.src = testData[testIndex].host + iframe1Path;
michael@0 46 }
michael@0 47
michael@0 48 function messageListener(event) {
michael@0 49 let message = eval(event.data);
michael@0 50
michael@0 51 is(message.source, "iframe", "Good source");
michael@0 52 is(message.result, testData[testIndex].expectedResult, "Good result");
michael@0 53
michael@0 54 if (testIndex < testData.length - 1) {
michael@0 55 testIndex++;
michael@0 56 setiframe();
michael@0 57 return;
michael@0 58 }
michael@0 59
michael@0 60 SimpleTest.finish();
michael@0 61 }
michael@0 62
michael@0 63 function runTest() {
michael@0 64 SimpleTest.waitForExplicitFinish();
michael@0 65 window.addEventListener("message", messageListener, false);
michael@0 66 setiframe();
michael@0 67 }
michael@0 68 </script>
michael@0 69
michael@0 70 </head>
michael@0 71
michael@0 72 <body onload="runTest();">
michael@0 73 <iframe id="iframe1"></iframe>
michael@0 74 </body>
michael@0 75
michael@0 76 </html>

mercurial