4 https://bugzilla.mozilla.org/show_bug.cgi?id=677638
8 <title>Test for Bug
677638 - port cloning
</title>
9 <script type=
"application/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=677638">Mozilla Bug
677638</a>
14 <div id=
"content"></div>
17 <script type=
"application/javascript">
20 var a = new MessageChannel();
21 ok(a,
"MessageChannel created");
23 window.addEventListener('message', receiveMessage, false);
24 function receiveMessage(evt) {
25 if (evt.data.status == 'READY') {
28 ok(false,
"Unknown message");
32 var div = document.getElementById(
"content");
33 ok(div,
"Parent exists");
35 var ifr = document.createElement(
"iframe");
36 ifr.addEventListener(
"load", iframeLoaded, false);
37 ifr.setAttribute('src',
"iframe_messageChannel_post.html");
40 function iframeLoaded() {
41 ifr.contentWindow.postMessage({ port: a.port2 }, '*', [a.port2]);
44 a.port1.addEventListener('message', receivePortMessage, false);
45 function receivePortMessage(evt) {
46 is(evt.data.ab.byteLength, size,
"The size is: " + size +
" == " + ab.byteLength);
50 // Start() is not implicity invoked when addEventListener is used.
53 var size =
1024 *
1024 *
32;
54 var ab = new ArrayBuffer(size);
55 is(ab.byteLength, size,
"The size is: " + size +
" == " + ab.byteLength);
58 a.port1.postMessage({ab: ab, cb: ab}, [ab]);
59 ok(ab.byteLength ==
0,
"PostMessage - The size is: 0 == " + ab.byteLength)
63 SimpleTest.waitForExplicitFinish();
64 SpecialPowers.pushPrefEnv({
"set": [[
"dom.messageChannel.enabled", true]]}, start);