dom/base/test/iframe_messageChannel_pingpong.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 <body>
michael@0 4 <script type="application/javascript">
michael@0 5
michael@0 6 function ok(what, msg) {
michael@0 7 window.parent.postMessage({type: what ? 'OK' : 'KO', msg: msg }, '*');
michael@0 8 }
michael@0 9
michael@0 10 window.addEventListener('message', receiveMessage, false);
michael@0 11 function receiveMessage(evt) {
michael@0 12 if (evt.data.type == 'PORT') {
michael@0 13 var port = evt.data.port;
michael@0 14 var counter = 0;
michael@0 15 port.onmessage = function(evt) {
michael@0 16 if (counter++ == 0) {
michael@0 17 ok(!(evt.data % 2), "The number " + evt.data + " has been received correctly by the iframe");
michael@0 18
michael@0 19 window.parent.postMessage({ type: 'PORT', port: port }, '*', [port]);
michael@0 20 }
michael@0 21 else {
michael@0 22 ok(false, "Wrong message!");
michael@0 23 }
michael@0 24 }
michael@0 25 } else {
michael@0 26 ok(false, "Unknown message");
michael@0 27 }
michael@0 28 }
michael@0 29
michael@0 30 </script>
michael@0 31 </body>
michael@0 32 </html>
michael@0 33

mercurial