Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 start() { |
michael@0 | 20 | var a = new MessageChannel(); |
michael@0 | 21 | ok(a, "MessageChannel created"); |
michael@0 | 22 | |
michael@0 | 23 | window.addEventListener('message', receiveMessage, false); |
michael@0 | 24 | function receiveMessage(evt) { |
michael@0 | 25 | if (evt.data.status == 'READY') { |
michael@0 | 26 | runTest(); |
michael@0 | 27 | } else { |
michael@0 | 28 | ok(false, "Unknown message"); |
michael@0 | 29 | } |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | var div = document.getElementById("content"); |
michael@0 | 33 | ok(div, "Parent exists"); |
michael@0 | 34 | |
michael@0 | 35 | var ifr = document.createElement("iframe"); |
michael@0 | 36 | ifr.addEventListener("load", iframeLoaded, false); |
michael@0 | 37 | ifr.setAttribute('src', "iframe_messageChannel_post.html"); |
michael@0 | 38 | div.appendChild(ifr); |
michael@0 | 39 | |
michael@0 | 40 | function iframeLoaded() { |
michael@0 | 41 | ifr.contentWindow.postMessage({ port: a.port2 }, '*', [a.port2]); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | a.port1.addEventListener('message', receivePortMessage, false); |
michael@0 | 45 | function receivePortMessage(evt) { |
michael@0 | 46 | is(evt.data.ab.byteLength, size, "The size is: " + size + " == " + ab.byteLength); |
michael@0 | 47 | SimpleTest.finish(); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | // Start() is not implicity invoked when addEventListener is used. |
michael@0 | 51 | a.port1.start(); |
michael@0 | 52 | |
michael@0 | 53 | var size = 1024 * 1024 * 32; |
michael@0 | 54 | var ab = new ArrayBuffer(size); |
michael@0 | 55 | is(ab.byteLength, size, "The size is: " + size + " == " + ab.byteLength); |
michael@0 | 56 | |
michael@0 | 57 | function runTest() { |
michael@0 | 58 | a.port1.postMessage({ab: ab, cb: ab}, [ab]); |
michael@0 | 59 | ok(ab.byteLength == 0, "PostMessage - The size is: 0 == " + ab.byteLength) |
michael@0 | 60 | } |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 64 | SpecialPowers.pushPrefEnv({"set": [["dom.messageChannel.enabled", true]]}, start); |
michael@0 | 65 | </script> |
michael@0 | 66 | </body> |
michael@0 | 67 | </html> |