test_messageChannel.xhtml (1244B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?> 3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 4 <window title="Test for MessageChannel API" 5 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 6 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 7 8 <!-- test results are displayed in the html:body --> 9 <body xmlns="http://www.w3.org/1999/xhtml" id="body"> 10 </body> 11 12 <!-- test code goes here --> 13 <script type="application/javascript"><![CDATA[ 14 15 ok("MessageChannel" in window, "Should MessageChannel exist?"); 16 17 var channel = new MessageChannel(); 18 ok(channel, "MessageChannel is created"); 19 20 channel.port1.onmessage = function() { 21 ok(true, "message received!"); 22 SimpleTest.finish(); 23 } 24 25 var ifr = document.createXULElement('browser'); 26 ifr.setAttribute("src", "iframe_messageChannel_chrome.html"); 27 ifr.setAttribute("flex", "1"); 28 ifr.addEventListener('load', function() { 29 ifr.contentWindow.postMessage(channel.port2, '*', [channel.port2]); 30 }); 31 32 var body = document.getElementById("body"); 33 body.appendChild(ifr); 34 35 SimpleTest.waitForExplicitFinish(); 36 37 ]]></script> 38 </window>