test_chromeWorkerESM.xhtml (1428B)
1 <?xml version="1.0"?> 2 <!-- 3 Any copyright is dedicated to the Public Domain. 4 http://creativecommons.org/publicdomain/zero/1.0/ 5 --> 6 <window title="DOM Worker Threads Test" 7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 8 onload="test();"> 9 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 11 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 12 <script type="application/javascript" src="dom_worker_helper.js"/> 13 14 <script type="application/javascript"> 15 <![CDATA[ 16 17 function test() 18 { 19 waitForWorkerFinish(); 20 21 var worker; 22 23 function done() 24 { 25 worker = null; 26 finish(); 27 } 28 29 function messageCallback(event) { 30 is(event.data, "Done", "Correct message"); 31 done(); 32 } 33 34 function errorCallback(event) { 35 ok(false, "Worker had an error: " + event.message); 36 done(); 37 } 38 39 const {WorkerTest} = ChromeUtils.importESModule( 40 "chrome://mochitests/content/chrome/dom/workers/test/WorkerTest.sys.mjs" 41 ); 42 43 worker = WorkerTest.go(window.location.href, messageCallback, 44 errorCallback); 45 } 46 47 ]]> 48 </script> 49 50 <body xmlns="http://www.w3.org/1999/xhtml"> 51 <p id="display"></p> 52 <div id="content" style="display:none;"></div> 53 <pre id="test"></pre> 54 </body> 55 <label id="test-result"/> 56 </window>