summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/fetch/nested_worker_wrapper.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/mochitest/fetch/nested_worker_wrapper.js')
-rw-r--r--dom/tests/mochitest/fetch/nested_worker_wrapper.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/dom/tests/mochitest/fetch/nested_worker_wrapper.js b/dom/tests/mochitest/fetch/nested_worker_wrapper.js
new file mode 100644
index 000000000..7e463e7df
--- /dev/null
+++ b/dom/tests/mochitest/fetch/nested_worker_wrapper.js
@@ -0,0 +1,28 @@
+// Hold the nested worker alive until this parent worker closes.
+var worker;
+
+addEventListener('message', function nestedWorkerWrapperOnMessage(evt) {
+ removeEventListener('message', nestedWorkerWrapperOnMessage);
+
+ worker = new Worker('worker_wrapper.js');
+
+ worker.addEventListener('message', function(evt) {
+ self.postMessage({
+ context: 'NestedWorker',
+ type: evt.data.type,
+ status: evt.data.status,
+ msg: evt.data.msg,
+ });
+ });
+
+ worker.addEventListener('error', function(evt) {
+ self.postMessage({
+ context: 'NestedWorker',
+ type: 'status',
+ status: false,
+ msg: 'Nested worker error: ' + evt.message,
+ });
+ });
+
+ worker.postMessage(evt.data);
+});