1 var channel = new MessageChannel();
2 var channel2 = new MessageChannel();
3 var channel3 = new MessageChannel();
6 postMessage("zero ports", []);
7 postMessage("two ports", [channel2.port1, channel2.port2]);
9 // Now test various failure cases
11 postMessage("null port", [channel3.port1, null, channel3.port2]);
12 testFailed("posting a null port did not throw");
14 testPassed("posting a null port did throw: " + e);
18 postMessage("notAPort", [channel3.port1, {}, channel3.port2]);
19 testFailed("posting a non-port did not throw");
21 testPassed("posting a non-port did throw: " + e);
25 postMessage("failed ports", [channel3.port1, channel3.port2]);
27 testFailed("reposting ports threw an exception: " + e);
31 postMessage("notAnArray", channel3.port1);
32 testFailed("posting a non-array should throw");
34 testPassed("posting a non-array did throw: " + e);
38 postMessage("notASequence", [{length: 3}]);
39 testFailed("posting a non-sequence should throw");
41 testPassed("posting a non-sequence did throw: " + e);
45 postMessage("done", [channel.port2]);
46 channel.port1.postMessage("done");
49 function testFailed(msg) {
50 postMessage("FAIL"+msg);
54 function testPassed(msg) {
55 postMessage("PASS"+msg);