WorkerDebugger_promise_worker.js (844B)
1 "use strict"; 2 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 worker's global. 9 Promise.resolve().then(function () { 10 self.onmessage = function (e) { 11 if (e.data !== "pause") { 12 return; 13 } 14 // This then-handler should be executed inside the top-level event loop, 15 // within the context of the worker's global. Because the debugger 16 // statement here below enters a nested event loop, the then-handler 17 // should not be executed until the debugger statement returns. 18 Promise.resolve().then(function () { 19 postMessage("resumed"); 20 }); 21 // eslint-disable-next-line no-debugger 22 debugger; 23 }; 24 postMessage("resolved"); 25 }); 26 };