Sat, 03 Jan 2015 20:18:00 +0100
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=677638 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 677638 - port cloning</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=677638">Mozilla Bug 677638</a> |
michael@0 | 14 | <div id="content"></div> |
michael@0 | 15 | <pre id="test"> |
michael@0 | 16 | </pre> |
michael@0 | 17 | <script type="application/javascript"> |
michael@0 | 18 | |
michael@0 | 19 | function runTest() { |
michael@0 | 20 | var MAX = 100; |
michael@0 | 21 | |
michael@0 | 22 | var a = new MessageChannel(); |
michael@0 | 23 | ok(a, "MessageChannel created"); |
michael@0 | 24 | |
michael@0 | 25 | // Populate the message queue of this port. |
michael@0 | 26 | for (var i = 0; i < MAX; ++i) { |
michael@0 | 27 | a.port1.postMessage(i); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | window.addEventListener('message', receiveMessage, false); |
michael@0 | 31 | function receiveMessage(evt) { |
michael@0 | 32 | |
michael@0 | 33 | // This test sends the port from this window to the iframe and viceversa. |
michael@0 | 34 | if (evt.data.type == 'PORT') { |
michael@0 | 35 | var port = evt.data.port; |
michael@0 | 36 | var counter = 0; |
michael@0 | 37 | port.onmessage = function(evt) { |
michael@0 | 38 | // only 1 message should be received by this port. |
michael@0 | 39 | if (counter++ == 0) { |
michael@0 | 40 | ok(evt.data % 2, "The number " + evt.data + " has been received correctly by the main window"); |
michael@0 | 41 | |
michael@0 | 42 | if (evt.data < MAX - 1) { |
michael@0 | 43 | ifr.contentWindow.postMessage({ type: 'PORT', port: port }, '*', [port]); |
michael@0 | 44 | } else { |
michael@0 | 45 | SimpleTest.finish(); |
michael@0 | 46 | } |
michael@0 | 47 | } else { |
michael@0 | 48 | ok(false, "Wrong message!"); |
michael@0 | 49 | } |
michael@0 | 50 | } |
michael@0 | 51 | } else if (evt.data.type == 'OK') { |
michael@0 | 52 | ok(true, evt.data.msg); |
michael@0 | 53 | } else if (evt.data.type == 'KO') { |
michael@0 | 54 | ok(false, evt.data.msg); |
michael@0 | 55 | } else { |
michael@0 | 56 | ok(false, "Unknown message"); |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | var div = document.getElementById("content"); |
michael@0 | 61 | ok(div, "Parent exists"); |
michael@0 | 62 | |
michael@0 | 63 | var ifr = document.createElement("iframe"); |
michael@0 | 64 | ifr.addEventListener("load", iframeLoaded, false); |
michael@0 | 65 | ifr.setAttribute('src', "iframe_messageChannel_pingpong.html"); |
michael@0 | 66 | div.appendChild(ifr); |
michael@0 | 67 | |
michael@0 | 68 | function iframeLoaded() { |
michael@0 | 69 | ifr.contentWindow.postMessage({ type: 'PORT', port: a.port2 }, '*', [a.port2]); |
michael@0 | 70 | } |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 74 | SpecialPowers.pushPrefEnv({"set": [["dom.messageChannel.enabled", true]]}, runTest); |
michael@0 | 75 | </script> |
michael@0 | 76 | </body> |
michael@0 | 77 | </html> |