content/html/document/test/test_bug445004.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 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=445004
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 445004</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=445004">Mozilla Bug 445004</a>
michael@0 13 <div id="content" style="display: none">
michael@0 14
michael@0 15 </div>
michael@0 16 <pre id="test">
michael@0 17 <script type="application/javascript">
michael@0 18
michael@0 19 /** Test for Bug 445004 **/
michael@0 20 is(window.location.hostname, "mochi.test", "Unexpected hostname");
michael@0 21 is(window.location.port, "8888", "Unexpected port; fix testcase");
michael@0 22
michael@0 23 SimpleTest.waitForExplicitFinish();
michael@0 24
michael@0 25 var loads = 1;
michael@0 26
michael@0 27 function loadStarted() {
michael@0 28 ++loads;
michael@0 29 }
michael@0 30 function loadEnded() {
michael@0 31 --loads;
michael@0 32 if (loads == 0) {
michael@0 33 doTest();
michael@0 34 }
michael@0 35 }
michael@0 36
michael@0 37 window.onload = loadEnded;
michael@0 38
michael@0 39 function getMessage(evt) {
michael@0 40 ok(evt.data == "start" || evt.data == "end", "Must have start or end");
michael@0 41 if (evt.data == "start")
michael@0 42 loadStarted();
michael@0 43 else
michael@0 44 loadEnded();
michael@0 45 }
michael@0 46
michael@0 47 window.addEventListener("message", getMessage, false);
michael@0 48
michael@0 49 function checkURI(uri, name, type) {
michael@0 50 var host = uri.match(/^http:\/\/([a-z.0-9]*)/)[1];
michael@0 51 var file = uri.match(/([^\/]*).png$/)[1];
michael@0 52 is(host, file, "Unexpected base URI for test " + name +
michael@0 53 " when testing " + type);
michael@0 54 }
michael@0 55
michael@0 56 function checkFrame(num) {
michael@0 57 // Just snarf our data
michael@0 58 var outer = SpecialPowers.wrap(window.frames[num]);
michael@0 59 name = outer.name;
michael@0 60
michael@0 61 is(outer.document.baseURI,
michael@0 62 "http://example.org/tests/content/html/document/test/bug445004-outer.html",
michael@0 63 "Unexpected base URI for " + name);
michael@0 64
michael@0 65 var iswrite = name.match(/write/);
michael@0 66
michael@0 67 var inner = outer.frames[0];
michael@0 68 if (iswrite) {
michael@0 69 is(inner.document.baseURI,
michael@0 70 "http://example.org/tests/content/html/document/test/bug445004-outer.html",
michael@0 71 "Unexpected inner base URI for " + name);
michael@0 72 } else {
michael@0 73 is(inner.document.baseURI,
michael@0 74 "http://test1.example.org/tests/content/html/document/test/bug445004-inner.html",
michael@0 75 "Unexpected inner base URI for " + name);
michael@0 76 }
michael@0 77
michael@0 78 var isrel = name.match(/rel/);
michael@0 79 var offsite = name.match(/offsite/);
michael@0 80
michael@0 81 if (!iswrite) {
michael@0 82 if ((isrel && !offsite) || (!isrel && offsite)) {
michael@0 83 is(inner.location.hostname, outer.location.hostname,
michael@0 84 "Unexpected hostnames for " + name);
michael@0 85 } else {
michael@0 86 isnot(inner.location.hostname, outer.location.hostname,
michael@0 87 "Unexpected hostnames for " + name);
michael@0 88 }
michael@0 89 }
michael@0 90
michael@0 91 checkURI(inner.frames[0].location.href, name, "direct location");
michael@0 92 checkURI(inner.frames[1].document.getElementsByTagName("img")[0].src,
michael@0 93 name, "direct write");
michael@0 94 if (!iswrite) {
michael@0 95 is(inner.frames[1].location.hostname, inner.location.hostname,
michael@0 96 "Incorrect hostname for " + name + " direct write")
michael@0 97 }
michael@0 98 checkURI(inner.frames[2].location.href, name, "indirect location");
michael@0 99 checkURI(inner.frames[3].document.getElementsByTagName("img")[0].src,
michael@0 100 name, "indirect write");
michael@0 101 if (!iswrite) {
michael@0 102 is(inner.frames[3].location.hostname, outer.location.hostname,
michael@0 103 "Incorrect hostname for " + name + " indirect write")
michael@0 104 }
michael@0 105 checkURI(inner.document.getElementsByTagName("img")[0].src,
michael@0 106 name, "direct image load");
michael@0 107 }
michael@0 108
michael@0 109
michael@0 110 function doTest() {
michael@0 111 for (var num = 0; num < 5; ++num) {
michael@0 112 checkFrame(num);
michael@0 113 }
michael@0 114
michael@0 115 SimpleTest.finish();
michael@0 116 }
michael@0 117
michael@0 118 </script>
michael@0 119 </pre>
michael@0 120 <p id="display">
michael@0 121 <iframe
michael@0 122 src="http://example.org/tests/content/html/document/test/bug445004-outer-rel.html"
michael@0 123 name="bug445004-outer-rel.html"></iframe>
michael@0 124 <iframe
michael@0 125 src="http://test1.example.org/tests/content/html/document/test/bug445004-outer-rel.html"
michael@0 126 name="bug445004-outer-rel.html offsite"></iframe>
michael@0 127 <iframe
michael@0 128 src="http://example.org/tests/content/html/document/test/bug445004-outer-abs.html"
michael@0 129 name="bug445004-outer-abs.html"></iframe>
michael@0 130 <iframe
michael@0 131 src="http://test1.example.org/tests/content/html/document/test/bug445004-outer-abs.html"
michael@0 132 name="bug445004-outer-abs.html offsite"></iframe>
michael@0 133 <iframe
michael@0 134 src="http://example.org/tests/content/html/document/test/bug445004-outer-write.html"
michael@0 135 name="bug445004-outer-write.html"></iframe>
michael@0 136 </p>
michael@0 137 </body>
michael@0 138 </html>

mercurial