OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>MessagePort message events are trusted</title> |
| 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/comms.html#dom-mes
sageport-postmessage"> |
| 6 <!-- See also: |
| 7 - https://github.com/whatwg/html/issues/1602 |
| 8 - https://github.com/whatwg/html/pull/1935 |
| 9 --> |
| 10 |
| 11 <script> |
| 12 "use strict"; |
| 13 |
| 14 async_test(t => { |
| 15 assert_true("MessageChannel" in self, "The browser must support MessageChannel
"); |
| 16 |
| 17 const channel = new MessageChannel(); |
| 18 |
| 19 channel.port2.onmessage = t.step_func_done(e => { |
| 20 assert_equals(e.isTrusted, true); |
| 21 }); |
| 22 |
| 23 channel.port1.postMessage("ping"); |
| 24 }, "With a MessageChannel and its MessagePorts"); |
| 25 |
| 26 async_test(t => { |
| 27 assert_true("BroadcastChannel" in self, "The browser must support BroadcastCha
nnel"); |
| 28 |
| 29 const channel = new BroadcastChannel("channel name"); |
| 30 |
| 31 channel.onmessage = t.step_func_done(e => { |
| 32 assert_equals(e.isTrusted, true); |
| 33 }); |
| 34 |
| 35 new Worker("MessageEvent-trusted-worker.js"); |
| 36 }, "With a BroadcastChannel"); |
| 37 |
| 38 async_test(t => { |
| 39 window.onmessage = t.step_func_done(e => { |
| 40 assert_equals(e.isTrusted, true); |
| 41 }); |
| 42 |
| 43 window.postMessage("ping", "*"); |
| 44 }, "With window"); |
| 45 </script> |
OLD | NEW |