MessageEvent-trusted.any.js (850B)
1 // META: title=MessagePort message events are trusted 2 3 // See also: 4 // - https://github.com/whatwg/html/issues/1602 5 // - https://github.com/whatwg/html/pull/1935 6 7 "use strict"; 8 9 async_test(t => { 10 assert_true("MessageChannel" in self, "The browser must support MessageChannel"); 11 12 const channel = new MessageChannel(); 13 14 channel.port2.onmessage = t.step_func_done(e => { 15 assert_equals(e.isTrusted, true); 16 }); 17 18 channel.port1.postMessage("ping"); 19 }, "With a MessageChannel and its MessagePorts"); 20 21 async_test(t => { 22 assert_true("BroadcastChannel" in self, "The browser must support BroadcastChannel"); 23 24 const channel = new BroadcastChannel("channel name"); 25 26 channel.onmessage = t.step_func_done(e => { 27 assert_equals(e.isTrusted, true); 28 }); 29 30 new Worker("support/MessageEvent-trusted-worker.js"); 31 }, "With a BroadcastChannel");