summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/fetch/worker_wrapper.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/fetch/worker_wrapper.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/fetch/worker_wrapper.js')
-rw-r--r--dom/tests/mochitest/fetch/worker_wrapper.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/dom/tests/mochitest/fetch/worker_wrapper.js b/dom/tests/mochitest/fetch/worker_wrapper.js
new file mode 100644
index 000000000..c2f0ec00e
--- /dev/null
+++ b/dom/tests/mochitest/fetch/worker_wrapper.js
@@ -0,0 +1,58 @@
+importScripts("utils.js");
+var client;
+var context;
+
+function ok(a, msg) {
+ client.postMessage({type: 'status', status: !!a,
+ msg: a + ": " + msg, context: context});
+}
+
+function is(a, b, msg) {
+ client.postMessage({type: 'status', status: a === b,
+ msg: a + " === " + b + ": " + msg, context: context});
+}
+
+addEventListener('message', function workerWrapperOnMessage(e) {
+ removeEventListener('message', workerWrapperOnMessage);
+ var data = e.data;
+
+ function loadTest() {
+ var done = function() {
+ client.postMessage({ type: 'finish', context: context });
+ }
+
+ try {
+ importScripts(data.script);
+ // runTest() is provided by the test.
+ runTest().then(done, done);
+ } catch(e) {
+ client.postMessage({
+ type: 'status',
+ status: false,
+ msg: 'worker failed to import ' + data.script + "; error: " + e.message,
+ context: context
+ });
+ done();
+ }
+ }
+
+ if ("ServiceWorker" in self) {
+ self.clients.matchAll().then(function(clients) {
+ for (var i = 0; i < clients.length; ++i) {
+ if (clients[i].url.indexOf("message_receiver.html") > -1) {
+ client = clients[i];
+ break;
+ }
+ }
+ if (!client) {
+ dump("We couldn't find the message_receiver window, the test will fail\n");
+ }
+ context = "ServiceWorker";
+ loadTest();
+ });
+ } else {
+ client = self;
+ context = "Worker";
+ loadTest();
+ }
+});