Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/resources/message-port-multi.js

Issue 2831943002: bindings: Port bindings/core/v8 away from ToImplArray APIs. (Closed)
Patch Set: Check for exception in SerializedScriptValue Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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()"); 13 shouldThrow("channel.port1.postMessage()");
14 14
15 channel.port1.postMessage("noport"); 15 channel.port1.postMessage("noport");
16 channel.port1.postMessage("zero ports", []); 16 channel.port1.postMessage("zero ports", []);
17 channel.port1.postMessage("two ports", [channel2.port1, channel2.port2]); 17 channel.port1.postMessage("two ports", [channel2.port1, channel2.port2]);
18 18
19 // Now test various failure cases 19 // Now test various failure cases
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."'); 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."');
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."'); 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."');
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."'); 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."');
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."'); 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."');
24 // 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).
25 channel.port1.postMessage("entangled ports", [channel3.port1, channel3.port2]); 25 channel.port1.postMessage("entangled ports", [channel3.port1, channel3.port2]);
26 26
27 shouldThrow('channel.port1.postMessage("notAnArray", channel3.port1)', '"TypeErr or: Failed to execute \'postMessage\' on \'MessagePort\': The 2nd argument is ne ither an array, nor does it have indexed properties."'); 27 shouldThrow('channel.port1.postMessage("notAnArray", channel3.port1)', '"TypeErr or: Failed to execute \'postMessage\' on \'MessagePort\': Iterator getter is not callable."');
28 shouldThrow('channel.port1.postMessage("notASequence", [{length: 3}])', '"TypeEr ror: Failed to execute \'postMessage\' on \'MessagePort\': Value at index 0 does not have a transferable type."'); 28 shouldThrow('channel.port1.postMessage("notASequence", [{length: 3}])', '"TypeEr ror: Failed to execute \'postMessage\' on \'MessagePort\': Value at index 0 does not have a transferable type."');
29 var arrayBuffer = new ArrayBuffer(2); 29 var arrayBuffer = new ArrayBuffer(2);
30 shouldThrow('channel.port1.postMessage("duplicate buffer", [arrayBuffer, arrayBu ffer])', '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePort\': ArrayBuffer at index 1 is a duplicate of an earlier ArrayBuffer."'); 30 shouldThrow('channel.port1.postMessage("duplicate buffer", [arrayBuffer, arrayBu ffer])', '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePort\': ArrayBuffer at index 1 is a duplicate of an earlier ArrayBuffer."');
31 31
32 // Should not crash (we should figure out that the array contains undefined 32 // Should not crash (we should figure out that the array contains undefined
33 // entries). 33 // entries).
34 var largePortArray = []; 34 var largePortArray = [];
35 largePortArray[1234567890] = channel4.port1; 35 largePortArray[1234567890] = channel4.port1;
36 shouldThrow('channel.port1.postMessage("largeSequence", largePortArray)', '"Type Error: Failed to execute \'postMessage\' on \'MessagePort\': Value at index 0 is an untransferable \'undefined\' value."'); 36 shouldThrow('channel.port1.postMessage("largeSequence", largePortArray)', '"Rang eError: Failed to execute \'postMessage\' on \'MessagePort\': Array length excee ds supported limit."');
37 37
38 channel.port1.postMessage("done"); 38 channel.port1.postMessage("done");
39 39
40 function testTransfers() { 40 function testTransfers() {
41 var channel0 = new MessageChannel(); 41 var channel0 = new MessageChannel();
42 42
43 var c1 = new MessageChannel(); 43 var c1 = new MessageChannel();
44 channel0.port1.postMessage({id:"send-port", port:c1.port1}, [c1.port1]); 44 channel0.port1.postMessage({id:"send-port", port:c1.port1}, [c1.port1]);
45 var c2 = new MessageChannel(); 45 var c2 = new MessageChannel();
46 channel0.port1.postMessage({id:"send-port-twice", port0:c2.port1, port1:c2.p ort1}, [c2.port1]); 46 channel0.port1.postMessage({id:"send-port-twice", port0:c2.port1, port1:c2.p ort1}, [c2.port1]);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } else if (event.data == "entangled ports") { 140 } else if (event.data == "entangled ports") {
141 if (event.ports.length == 2) 141 if (event.ports.length == 2)
142 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");
143 else 143 else
144 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");
145 } else if (event.data == "done") { 145 } else if (event.data == "done") {
146 testTransfers(); 146 testTransfers();
147 } else 147 } else
148 testFailed("Received unexpected message: " + event.data); 148 testFailed("Received unexpected message: " + event.data);
149 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698