mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
0a8ff0ad85
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D35951 --HG-- extra : source : 62f3501af4bc1c0bd1ee1977a28aee04706a6663
26 lines
578 B
JavaScript
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);
|
|
};
|
|
}
|
|
};
|