test_WorkerDebuggerGlobalScope.setImmediate.xul 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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="Test for WorkerDebuggerGlobalScope.setImmediate"
  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. const WORKER_URL = "WorkerDebuggerGlobalScope.setImmediate_worker.js";
  17. const DEBUGGER_URL = BASE_URL + "WorkerDebuggerGlobalScope.setImmediate_debugger.js";
  18. function test() {
  19. Task.spawn(function* () {
  20. SimpleTest.waitForExplicitFinish();
  21. let promise = waitForRegister(WORKER_URL, DEBUGGER_URL);
  22. let worker = new Worker(WORKER_URL);
  23. let dbg = yield promise;
  24. info("Send a request to the worker debugger. This should cause a " +
  25. "the worker debugger to send two responses. The worker debugger " +
  26. "should send the second response before the first one, since " +
  27. "the latter is delayed until the next tick of the event loop.");
  28. promise = waitForMultiple([
  29. waitForDebuggerMessage(dbg, "pong2"),
  30. waitForDebuggerMessage(dbg, "pong1")
  31. ]);
  32. dbg.postMessage("ping");
  33. yield promise;
  34. SimpleTest.finish();
  35. });
  36. }
  37. ]]>
  38. </script>
  39. <body xmlns="http://www.w3.org/1999/xhtml">
  40. <p id="display"></p>
  41. <div id="content" style="display:none;"></div>
  42. <pre id="test"></pre>
  43. </body>
  44. <label id="test-result"/>
  45. </window>