test_extension.xul 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. <script type="application/javascript"
  10. src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  11. <script type="application/javascript"
  12. src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
  13. <script type="application/javascript" src="dom_worker_helper.js"/>
  14. <script type="application/javascript">
  15. <![CDATA[
  16. function test() {
  17. const message = "woohoo";
  18. var workertest =
  19. Cc["@mozilla.org/test/workertest;1"].createInstance(Ci.nsIWorkerTest);
  20. workertest.callback = {
  21. onmessage: function(data) {
  22. is(data, message, "Correct message");
  23. workertest.callback = null;
  24. workertest = null;
  25. SimpleTest.finish();
  26. },
  27. onerror: function(data) {
  28. ok(false, "Worker had an error: " + data.message);
  29. workertest.callback = null;
  30. workertest = null;
  31. SimpleTest.finish();
  32. },
  33. QueryInterface: XPCOMUtils.generateQI([Ci.nsIWorkerTestCallback])
  34. };
  35. workertest.postMessage(message);
  36. SimpleTest.waitForExplicitFinish();
  37. }
  38. ]]>
  39. </script>
  40. <body xmlns="http://www.w3.org/1999/xhtml">
  41. <p id="display"></p>
  42. <div id="content" style="display:none;"></div>
  43. <pre id="test"></pre>
  44. </body>
  45. <label id="test-result"/>
  46. </window>