OLD | NEW |
---|---|
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; |
11 channel.port1.onmessage = channel.port2.onmessage = function(evt) { | 11 channel.port1.onmessage = channel.port2.onmessage = function(evt) { |
12 testFailed("Should not have received message: " + evt.data); | 12 testFailed("Should not have received message: " + evt.data); |
13 } | 13 } |
14 | 14 |
15 // Posting port to itself should throw an exception. | 15 // Posting port to itself should throw an exception. |
16 shouldThrow("channel.port1.postMessage('msg', [channel.port1])", '"DataCloneErro r: Failed to execute \'postMessage\' on \'MessagePort\': Item #0 in the array of ports contains the source port."'); | 16 shouldThrow("channel.port1.postMessage('msg', [channel.port1])", '"DataCloneErro r: Failed to execute \'postMessage\' on \'MessagePort\': Item #0 in the array of ports contains the source port."'); |
17 | 17 |
18 debug("Posting port to entangled pair neuters the port and does nothing else:"); | 18 debug("Posting port to entangled pair neuters the port and does nothing else:"); |
19 channel = new MessageChannel; | 19 channel = new MessageChannel; |
20 var channel2 = new MessageChannel; | 20 var channel2 = new MessageChannel; |
21 channel.port1.postMessage("msg", [channel.port2]); | 21 channel.port1.postMessage("msg", [channel.port2]); |
22 shouldThrow("channel2.port1.postMessage('msg', [channel.port2])", '"DataCloneErr or: Failed to execute \'disentanglePorts\' on \'MessagePort\': Item #0 in the ar ray of ports is already neutered."'); | 22 shouldThrow("channel2.port1.postMessage('msg', [channel.port2])", '"DataCloneErr or: Failed to execute \'postMessage\' on \'MessagePort\': Item #0 in the array o f ports is already neutered."'); |
sof
2013/12/03 16:04:29
Can't we just do away with the duplication of exce
Mike West
2013/12/04 08:42:19
It's valuable to have a test fail if the exception
| |
23 | 23 |
24 channel = new MessageChannel; | 24 channel = new MessageChannel; |
25 channel2 = new MessageChannel | 25 channel2 = new MessageChannel |
26 channel.port1.postMessage("msg", [channel2.port1]); | 26 channel.port1.postMessage("msg", [channel2.port1]); |
27 | 27 |
28 // Should not be able to post a cloned port. | 28 // Should not be able to post a cloned port. |
29 shouldThrow("channel.port1.postMessage('msg', [channel2.port1])", '"DataCloneErr or: Failed to execute \'disentanglePorts\' on \'MessagePort\': Item #0 in the ar ray of ports is already neutered."'); | 29 shouldThrow("channel.port1.postMessage('msg', [channel2.port1])", '"DataCloneErr or: Failed to execute \'postMessage\' on \'MessagePort\': Item #0 in the array o f ports is already neutered."'); |
30 | 30 |
31 // Test posting messages to a port in cloned state. | 31 // Test posting messages to a port in cloned state. |
32 | 32 |
33 var channel = new MessageChannel; | 33 var channel = new MessageChannel; |
34 var channel2 = new MessageChannel; | 34 var channel2 = new MessageChannel; |
35 | 35 |
36 // Post messages before and after clone to make sure ordering is preserved and a ll messages are received. | 36 // Post messages before and after clone to make sure ordering is preserved and a ll messages are received. |
37 channel2.port2.postMessage("1"); | 37 channel2.port2.postMessage("1"); |
38 channel.port1.postMessage("msg", [channel2.port1]); | 38 channel.port1.postMessage("msg", [channel2.port1]); |
39 channel2.port2.postMessage("2"); | 39 channel2.port2.postMessage("2"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 shouldNotBe("testEvent.ports", "null"); | 86 shouldNotBe("testEvent.ports", "null"); |
87 shouldBe("testEvent.ports.length", "1"); | 87 shouldBe("testEvent.ports.length", "1"); |
88 shouldBe("testEvent.data", "'closed'"); | 88 shouldBe("testEvent.data", "'closed'"); |
89 | 89 |
90 finishJSTest(); | 90 finishJSTest(); |
91 } | 91 } |
92 } | 92 } |
93 </script> | 93 </script> |
94 </body> | 94 </body> |
95 </html> | 95 </html> |
OLD | NEW |