Channel_postMessage_target_source.any.js (699B)
1 // META: title=postMessage(): target port and source port 2 3 var TARGET = null; 4 var SOURCE = null; 5 var description = "The postMessage() method - Let target port be the port with which source " 6 + "port is entangled, if any."; 7 8 var t = async_test("Test Description: " + description); 9 10 var channel = new MessageChannel(); 11 SOURCE = channel.port1; 12 TARGET = channel.port2; 13 TARGET.start(); 14 TARGET.addEventListener("message", t.step_func(TestMessageEvent), true); 15 16 SOURCE.postMessage("ping"); 17 18 function TestMessageEvent(evt) 19 { 20 assert_equals(evt.target, TARGET); 21 assert_not_equals(evt.target, SOURCE); 22 t.done(); 23 }