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

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

Issue 138273013: Check for duplicate ArrayBuffer transferables. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update test to current Created 6 years, 11 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 channel.port1.postMessage("noport"); 13 channel.port1.postMessage("noport");
14 channel.port1.postMessage("zero ports", []); 14 channel.port1.postMessage("zero ports", []);
15 channel.port1.postMessage("two ports", [channel2.port1, channel2.port2]); 15 channel.port1.postMessage("two ports", [channel2.port1, channel2.port2]);
16 16
17 // Now test various failure cases 17 // 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."'); 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."');
19 shouldThrow('channel.port1.postMessage("null port", [channel3.port1, null, chann el3.port2])', '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePo rt\': Value at index 1 is an untransferable \'null\' value."'); 19 shouldThrow('channel.port1.postMessage("null port", [channel3.port1, null, chann el3.port2])', '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePo rt\': Value at index 1 is an untransferable \'null\' value."');
20 shouldThrow('channel.port1.postMessage("notAPort", [channel3.port1, {}, channel3 .port2])', '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePort\ ': Value at index 1 does not have a transferable type."'); 20 shouldThrow('channel.port1.postMessage("notAPort", [channel3.port1, {}, channel3 .port2])', '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePort\ ': Value 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."'); 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."');
22 // Should be OK to send channel3.port1 (should not have been disentangled by the previous failed calls). 22 // Should be OK to send channel3.port1 (should not have been disentangled by the previous failed calls).
23 channel.port1.postMessage("entangled ports", [channel3.port1, channel3.port2]); 23 channel.port1.postMessage("entangled ports", [channel3.port1, channel3.port2]);
24 24
25 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."'); 25 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."');
26 shouldThrow('channel.port1.postMessage("notASequence", [{length: 3}])', '"DataCl oneError: Failed to execute \'postMessage\' on \'MessagePort\': Value at index 0 does not have a transferable type."'); 26 shouldThrow('channel.port1.postMessage("notASequence", [{length: 3}])', '"DataCl oneError: Failed to execute \'postMessage\' on \'MessagePort\': Value at index 0 does not have a transferable type."');
27 var arrayBuffer = new ArrayBuffer(2);
28 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."');
27 29
28 // Should not crash (we should figure out that the array contains undefined 30 // Should not crash (we should figure out that the array contains undefined
29 // entries). 31 // entries).
30 var largePortArray = []; 32 var largePortArray = [];
31 largePortArray[1234567890] = channel4.port1; 33 largePortArray[1234567890] = channel4.port1;
32 shouldThrow('channel.port1.postMessage("largeSequence", largePortArray)', '"Data CloneError: Failed to execute \'postMessage\' on \'MessagePort\': Value at index 0 is an untransferable \'undefined\' value."'); 34 shouldThrow('channel.port1.postMessage("largeSequence", largePortArray)', '"Data CloneError: Failed to execute \'postMessage\' on \'MessagePort\': Value at index 0 is an untransferable \'undefined\' value."');
33 35
34 channel.port1.postMessage("done"); 36 channel.port1.postMessage("done");
35 37
36 function testTransfers() { 38 function testTransfers() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (event.ports.length == 2) 139 if (event.ports.length == 2)
138 testPassed("event.ports contains two ports when two ports re-sent af ter error"); 140 testPassed("event.ports contains two ports when two ports re-sent af ter error");
139 else 141 else
140 testFailed("event.ports contained " + event.ports.length + " when tw o ports re-sent after error"); 142 testFailed("event.ports contained " + event.ports.length + " when tw o ports re-sent after error");
141 } else if (event.data == "done") { 143 } else if (event.data == "done") {
142 testTransfers(); 144 testTransfers();
143 } else 145 } else
144 testFailed("Received unexpected message: " + event.data); 146 testFailed("Received unexpected message: " + event.data);
145 } 147 }
146 148
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/message-port-multi-expected.txt ('k') | Source/bindings/v8/V8Utilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698