Channel_postMessage_clone_port.any.js (1100B)
1 // META: title=postMessage(): clone a port 2 3 var OriginalPort = null; 4 var ClonedPort = null; 5 var description = "Test Description: When the user agent is to clone a port original port, with " 6 + "the clone being owned by owner, it must return a new MessagePort object"; 7 8 var t = async_test("Test Description: " + description); 9 10 var ChannelA = new MessageChannel(); 11 var ChannelB = new MessageChannel(); 12 OriginalPort = ChannelB.port2; 13 14 ChannelA.port2.onmessage = t.step_func(function(evt) 15 { 16 if(evt.data == "ports") 17 { 18 ClonedPort = evt.ports[0]; 19 20 assert_not_equals(ClonedPort, OriginalPort, "new cloned port object should not equal to the original port!"); 21 22 ClonedPort.onmessage = function(e) 23 { 24 test(function(){ assert_equals(e.data, "ping"); }, "Data sent through remote port is received by the new cloned port"); 25 t.done(); 26 } 27 } 28 }); 29 30 ChannelA.port1.postMessage("ports", [OriginalPort]); 31 ChannelB.port1.postMessage("ping");