test_broadcastchannel_self.html (679B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for BroadcastChannel</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 7 </head> 8 <body> 9 10 <div id="content"></div> 11 12 <script type="application/javascript"> 13 14 function runTest() { 15 let x = new BroadcastChannel("foo"); 16 let y = new BroadcastChannel("foo"); 17 18 function func(e) { 19 is(e.target, y, "The target is !x"); 20 21 SimpleTest.executeSoon(function() { 22 SimpleTest.finish(); 23 }); 24 } 25 26 x.onmessage = func; 27 y.onmessage = func; 28 29 x.postMessage("foo"); 30 } 31 32 SimpleTest.waitForExplicitFinish(); 33 runTest(); 34 35 </script> 36 </body> 37 </html>