|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=822094 |
|
5 --> |
|
6 <head><meta charset=utf-8> |
|
7 <title>postMessage transferable tests</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="text/javascript" src="browserFu.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822094">Mozilla Bug 822094</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 |
|
17 <iframe src="postMessage_transfer_helper.html" |
|
18 name="sameDomain"></iframe> |
|
19 <iframe src="http://example.org:8000/tests/dom/tests/mochitest/whatwg/postMessage_transfer_helper.html" |
|
20 name="crossDomain"></iframe> |
|
21 |
|
22 </div> |
|
23 <pre id="test"> |
|
24 <script class="testbody" type="application/javascript"> |
|
25 |
|
26 SimpleTest.waitForExplicitFinish(); |
|
27 |
|
28 var tests = [ |
|
29 function() { testFunc(window, "http://mochi.test:8888"); }, |
|
30 function() { testFunc(frames.sameDomain, "http://mochi.test:8888"); }, |
|
31 function() { testFunc(frames.crossDomain, "http://example.org:8000"); }, |
|
32 function() { SimpleTest.finish(); }, |
|
33 ]; |
|
34 |
|
35 function testFunc(target, origin) { |
|
36 var ab = new ArrayBuffer(1); |
|
37 var cd = new ArrayBuffer(1); |
|
38 |
|
39 target.postMessage([ab, cd], origin, [ab]); |
|
40 is(ab.byteLength, 0, "ab should be neutered"); |
|
41 is(cd.byteLength, 1, "cd should not be neutered"); |
|
42 |
|
43 onmessage = function(e) { |
|
44 is(e.data[0].byteLength, 1, "ab should be transfered"); |
|
45 is(e.data[1].byteLength, 1, "cd should be cloned"); |
|
46 nextTest(); |
|
47 }; |
|
48 } |
|
49 |
|
50 function nextTest() { |
|
51 var t = tests.shift(); |
|
52 t(); |
|
53 }; |
|
54 |
|
55 onload = function() { |
|
56 nextTest(); |
|
57 }; |
|
58 |
|
59 </script> |
|
60 </pre> |
|
61 </body> |
|
62 </html> |