gecko-dev/dom/workers/test/csp_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

26 lines
578 B
JavaScript

/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
onmessage = function(event) {
if (event.data.do == "eval") {
var res;
try {
res = eval("40+2");
} catch (ex) {
res = ex + "";
}
postMessage(res);
} else if (event.data.do == "nest") {
var worker = new Worker(event.data.uri);
if (--event.data.level) {
worker.postMessage(event.data);
} else {
worker.postMessage({ do: "eval" });
}
worker.onmessage = e => {
postMessage(e.data);
};
}
};