fune/dom/workers/test/WorkerDebugger_promise_worker.js
Victor Porof 0a8ff0ad85 Bug 1561435 - Format dom/, a=automatic-formatting
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D35951

--HG--
extra : source : 62f3501af4bc1c0bd1ee1977a28aee04706a6663
2019-07-05 10:44:55 +02:00

25 lines
794 B
JavaScript

"use strict";
self.onmessage = function(event) {
if (event.data !== "resolve") {
return;
}
// This then-handler should be executed inside the top-level event loop,
// within the context of the worker's global.
Promise.resolve().then(function() {
self.onmessage = function(e) {
if (e.data !== "pause") {
return;
}
// This then-handler should be executed inside the top-level event loop,
// within the context of the worker's global. Because the debugger
// statement here below enters a nested event loop, the then-handler
// should not be executed until the debugger statement returns.
Promise.resolve().then(function() {
postMessage("resumed");
});
debugger;
};
postMessage("resolved");
});
};