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

Side by Side Diff: LayoutTests/fast/events/message-port-clone.html

Issue 1022283002: Throw TypeError if value conversion to transferable fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add more tests for TypeError throwing Created 5 years, 9 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 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../resources/js-test.js"></script> 3 <script src="../../resources/js-test.js"></script>
4 </head> 4 </head>
5 <body> 5 <body>
6 <script> 6 <script>
7 description("Tests various use cases when cloning MessagePorts."); 7 description("Tests various use cases when cloning MessagePorts.");
8 window.jsTestIsAsync = true; 8 window.jsTestIsAsync = true;
9 9
10 var channel = new MessageChannel; 10 var channel = new MessageChannel;
(...skipping 18 matching lines...) Expand all
29 channel = new MessageChannel; 29 channel = new MessageChannel;
30 var arrayBuffer = new ArrayBuffer(2); 30 var arrayBuffer = new ArrayBuffer(2);
31 31
32 channel.port1.postMessage("msg", [arrayBuffer]); 32 channel.port1.postMessage("msg", [arrayBuffer]);
33 shouldThrow("channel.port1.postMessage(arrayBuffer, [])", '"DataCloneError: Fail ed to execute \'postMessage\' on \'MessagePort\': An ArrayBuffer is neutered and could not be cloned."'); 33 shouldThrow("channel.port1.postMessage(arrayBuffer, [])", '"DataCloneError: Fail ed to execute \'postMessage\' on \'MessagePort\': An ArrayBuffer is neutered and could not be cloned."');
34 34
35 debug("Posting a neutered ArrayBufferView should throw."); 35 debug("Posting a neutered ArrayBufferView should throw.");
36 channel = new MessageChannel; 36 channel = new MessageChannel;
37 var uint16Array = new Uint16Array(10); 37 var uint16Array = new Uint16Array(10);
38 38
39 shouldThrow("channel.port1.postMessage('msg', [uint16Array])", '"DataCloneError: Failed to execute \'postMessage\' on \'MessagePort\': Value at index 0 does not have a transferable type."'); 39 shouldThrow("channel.port1.postMessage('msg', [uint16Array])", '"TypeError: Fail ed to execute \'postMessage\' on \'MessagePort\': Value at index 0 does not have a transferable type."');
40 40
41 channel.port1.postMessage("msg", [uint16Array.buffer]); 41 channel.port1.postMessage("msg", [uint16Array.buffer]);
42 shouldThrow("channel.port1.postMessage(uint16Array, [])", '"DataCloneError: Fail ed to execute \'postMessage\' on \'MessagePort\': An ArrayBuffer is neutered and could not be cloned."'); 42 shouldThrow("channel.port1.postMessage(uint16Array, [])", '"DataCloneError: Fail ed to execute \'postMessage\' on \'MessagePort\': An ArrayBuffer is neutered and could not be cloned."');
43 43
44 // Should not be able to post a cloned port. 44 // Should not be able to post a cloned port.
45 shouldThrow("channel.port1.postMessage('msg', [channel2.port1])", '"DataCloneErr or: Failed to execute \'postMessage\' on \'MessagePort\': Port at index 0 is alr eady neutered."'); 45 shouldThrow("channel.port1.postMessage('msg', [channel2.port1])", '"DataCloneErr or: Failed to execute \'postMessage\' on \'MessagePort\': Port at index 0 is alr eady neutered."');
46 46
47 // Test posting messages to a port in cloned state. 47 // Test posting messages to a port in cloned state.
48 48
49 var channel = new MessageChannel; 49 var channel = new MessageChannel;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 shouldBe("testEvent.ports.length", "1"); 103 shouldBe("testEvent.ports.length", "1");
104 shouldBe("testEvent.data", "'closed'"); 104 shouldBe("testEvent.data", "'closed'");
105 105
106 finishJSTest(); 106 finishJSTest();
107 } 107 }
108 } 108 }
109 109
110 </script> 110 </script>
111 </body> 111 </body>
112 </html> 112 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698