OLD | NEW |
1 if (window.testRunner) { | 1 if (window.testRunner) { |
2 testRunner.dumpAsText(); | 2 testRunner.dumpAsText(); |
3 testRunner.waitUntilDone(); | 3 testRunner.waitUntilDone(); |
4 } | 4 } |
5 | 5 |
6 description("This test checks the various use cases around sending multiple port
s through MessagePort.postMessage"); | 6 description("This test checks the various use cases around sending multiple port
s through MessagePort.postMessage"); |
7 | 7 |
8 var channel = new MessageChannel(); | 8 var channel = new MessageChannel(); |
9 var channel2 = new MessageChannel(); | 9 var channel2 = new MessageChannel(); |
10 var channel3 = new MessageChannel(); | 10 var channel3 = new MessageChannel(); |
11 var channel4 = new MessageChannel(); | 11 var channel4 = new MessageChannel(); |
12 | 12 |
| 13 shouldThrow("channel.port1.postMessage()"); |
| 14 |
13 channel.port1.postMessage("noport"); | 15 channel.port1.postMessage("noport"); |
14 channel.port1.postMessage("zero ports", []); | 16 channel.port1.postMessage("zero ports", []); |
15 channel.port1.postMessage("two ports", [channel2.port1, channel2.port2]); | 17 channel.port1.postMessage("two ports", [channel2.port1, channel2.port2]); |
16 | 18 |
17 // Now test various failure cases | 19 // Now test various failure cases |
18 shouldThrow('channel.port1.postMessage("same port", [channel.port1])', '"DataClo
neError: Failed to execute \'postMessage\' on \'MessagePort\': Port at index 0 c
ontains the source port."'); | 20 shouldThrow('channel.port1.postMessage("same port", [channel.port1])', '"DataClo
neError: Failed to execute \'postMessage\' on \'MessagePort\': Port at index 0 c
ontains the source port."'); |
19 shouldThrow('channel.port1.postMessage("null port", [channel3.port1, null, chann
el3.port2])', '"TypeError: Failed to execute \'postMessage\' on \'MessagePort\':
Value at index 1 is an untransferable \'null\' value."'); | 21 shouldThrow('channel.port1.postMessage("null port", [channel3.port1, null, chann
el3.port2])', '"TypeError: Failed to execute \'postMessage\' on \'MessagePort\':
Value at index 1 is an untransferable \'null\' value."'); |
20 shouldThrow('channel.port1.postMessage("notAPort", [channel3.port1, {}, channel3
.port2])', '"TypeError: Failed to execute \'postMessage\' on \'MessagePort\': Va
lue at index 1 does not have a transferable type."'); | 22 shouldThrow('channel.port1.postMessage("notAPort", [channel3.port1, {}, channel3
.port2])', '"TypeError: Failed to execute \'postMessage\' on \'MessagePort\': Va
lue at index 1 does not have a transferable type."'); |
21 shouldThrow('channel.port1.postMessage("duplicate port", [channel3.port1, channe
l3.port1])', '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePor
t\': Message port at index 1 is a duplicate of an earlier port."'); | 23 shouldThrow('channel.port1.postMessage("duplicate port", [channel3.port1, channe
l3.port1])', '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePor
t\': Message port at index 1 is a duplicate of an earlier port."'); |
22 // Should be OK to send channel3.port1 (should not have been disentangled by the
previous failed calls). | 24 // Should be OK to send channel3.port1 (should not have been disentangled by the
previous failed calls). |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } else if (event.data == "entangled ports") { | 140 } else if (event.data == "entangled ports") { |
139 if (event.ports.length == 2) | 141 if (event.ports.length == 2) |
140 testPassed("event.ports contains two ports when two ports re-sent af
ter error"); | 142 testPassed("event.ports contains two ports when two ports re-sent af
ter error"); |
141 else | 143 else |
142 testFailed("event.ports contained " + event.ports.length + " when tw
o ports re-sent after error"); | 144 testFailed("event.ports contained " + event.ports.length + " when tw
o ports re-sent after error"); |
143 } else if (event.data == "done") { | 145 } else if (event.data == "done") { |
144 testTransfers(); | 146 testTransfers(); |
145 } else | 147 } else |
146 testFailed("Received unexpected message: " + event.data); | 148 testFailed("Received unexpected message: " + event.data); |
147 } | 149 } |
OLD | NEW |