test_WorkerDebugger_frozen.xul 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 WorkerDebugger with frozen workers"
  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 CACHE_SUBFRAMES = "browser.sessionhistory.cache_subframes";
  17. const MAX_TOTAL_VIEWERS = "browser.sessionhistory.max_total_viewers";
  18. const IFRAME1_URL = "WorkerDebugger_frozen_iframe1.html";
  19. const IFRAME2_URL = "WorkerDebugger_frozen_iframe2.html";
  20. const WORKER1_URL = "WorkerDebugger_frozen_worker1.js";
  21. const WORKER2_URL = "WorkerDebugger_frozen_worker2.js";
  22. function test() {
  23. Task.spawn(function* () {
  24. SimpleTest.waitForExplicitFinish();
  25. var oldMaxTotalViewers = SpecialPowers.getIntPref(MAX_TOTAL_VIEWERS);
  26. SpecialPowers.setBoolPref(CACHE_SUBFRAMES, true);
  27. SpecialPowers.setIntPref(MAX_TOTAL_VIEWERS, 10);
  28. let iframe = $("iframe");
  29. let promise = waitForMultiple([
  30. waitForRegister(WORKER1_URL),
  31. waitForWindowMessage(window, "ready"),
  32. ]);
  33. iframe.src = IFRAME1_URL;
  34. let [dbg1] = yield promise;
  35. is(dbg1.isClosed, false,
  36. "debugger for worker on page 1 should not be closed");
  37. promise = waitForMultiple([
  38. waitForUnregister(WORKER1_URL),
  39. waitForDebuggerClose(dbg1),
  40. waitForRegister(WORKER2_URL),
  41. waitForWindowMessage(window, "ready"),
  42. ]);
  43. iframe.src = IFRAME2_URL;
  44. let [,, dbg2] = yield promise;
  45. is(dbg1.isClosed, true,
  46. "debugger for worker on page 1 should be closed");
  47. is(dbg2.isClosed, false,
  48. "debugger for worker on page 2 should not be closed");
  49. promise = Promise.all([
  50. waitForUnregister(WORKER2_URL),
  51. waitForDebuggerClose(dbg2),
  52. waitForRegister(WORKER1_URL)
  53. ]);
  54. iframe.contentWindow.history.back();
  55. [,, dbg1] = yield promise;
  56. is(dbg1.isClosed, false,
  57. "debugger for worker on page 1 should not be closed");
  58. is(dbg2.isClosed, true,
  59. "debugger for worker on page 2 should be closed");
  60. SpecialPowers.clearUserPref(CACHE_SUBFRAMES);
  61. SpecialPowers.setIntPref(MAX_TOTAL_VIEWERS, oldMaxTotalViewers);
  62. SimpleTest.finish();
  63. });
  64. }
  65. ]]>
  66. </script>
  67. <body xmlns="http://www.w3.org/1999/xhtml">
  68. <p id="display"></p>
  69. <div id="content" style="display:none;"></div>
  70. <pre id="test"></pre>
  71. <iframe id="iframe"></iframe>
  72. </body>
  73. <label id="test-result"/>
  74. </window>