WorkerDebugger_promise_debugger.js 832 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. var self = this;
  3. self.onmessage = function (event) {
  4. if (event.data !== "resolve") {
  5. return;
  6. }
  7. // This then-handler should be executed inside the top-level event loop,
  8. // within the context of the debugger's global.
  9. Promise.resolve().then(function () {
  10. var dbg = new Debugger(global);
  11. dbg.onDebuggerStatement = function () {
  12. self.onmessage = function (event) {
  13. if (event.data !== "resume") {
  14. return;
  15. }
  16. // This then-handler should be executed inside the nested event loop,
  17. // within the context of the debugger's global.
  18. Promise.resolve().then(function () {
  19. postMessage("resumed");
  20. leaveEventLoop();
  21. });
  22. };
  23. postMessage("paused");
  24. enterEventLoop();
  25. };
  26. postMessage("resolved");
  27. });
  28. };