https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 410fe8465f4c5a51d25d95c62a53b569d980c1cf authored by Robert Ma on 19 March 2018, 15:34:37 UTC
Exit check_stability with an error when no tests run
Tip revision: 410fe84
postMessage_clone_port.htm
<!DOCTYPE html>
<title> postMessage(): clone a port </title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function(t) {
  var channelA = new MessageChannel();
  var channelB = new MessageChannel();
  var originalPort = channelB.port2;
  channelA.port2.onmessage = t.step_func(function(e) {
    assert_equals(e.data, "ports");
    var clonedPort = e.ports[0];
    assert_not_equals(clonedPort, originalPort, "new cloned port object should not equal to the original port!");
    clonedPort.onmessage = t.step_func_done(function(e) {
      assert_equals(e.data, "ping", "Data sent through remote port is received by the new cloned port");
    });
  });
  channelA.port1.postMessage("ports", [channelB.port2]);
  channelB.port1.postMessage("ping");
});
</script>
back to top