Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / workers / resources / worker-context-thread-multi-port.js
blob28eef67123020d050ba41dc6567362bb03bbf32e
1 var channel = new MessageChannel();
2 var channel2 = new MessageChannel();
3 var channel3 = new MessageChannel();
5 postMessage("noport");
6 postMessage("zero ports", []);
7 postMessage("two ports", [channel2.port1, channel2.port2]);
9 // Now test various failure cases
10 try {
11     postMessage("null port", [channel3.port1, null, channel3.port2]);
12     testFailed("posting a null port did not throw");
13 } catch (e) {
14     testPassed("posting a null port did throw: " + e);
17 try {
18     postMessage("notAPort", [channel3.port1, {}, channel3.port2]);
19     testFailed("posting a non-port did not throw");
20 } catch (e) {
21     testPassed("posting a non-port did throw: " + e);
24 try {
25     postMessage("failed ports", [channel3.port1, channel3.port2]);
26 } catch (e) {
27     testFailed("reposting ports threw an exception: " + e);
30 try {
31     postMessage("notAnArray", channel3.port1);
32     testFailed("posting a non-array should throw");
33 } catch (e) {
34     testPassed("posting a non-array did throw: " + e);
37 try {
38     postMessage("notASequence", [{length: 3}]);
39     testFailed("posting a non-sequence should throw");
40 } catch (e) {
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);