relativeLoad_sub_worker.js (743B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 /* eslint-env worker */ 6 /* global workerSubURL */ 7 const importSubURL = "relativeLoad_sub_import.js"; 8 9 onmessage = function (_) { 10 var xhr = new XMLHttpRequest(); 11 xhr.open("GET", "testXHR.txt", false); 12 xhr.send(null); 13 if (xhr.status != 404) { 14 throw new Error("Loaded an xhr from the wrong location!"); 15 } 16 17 importScripts(importSubURL); 18 var worker = new Worker("relativeLoad_sub_worker2.js"); 19 worker.onerror = function (event) { 20 throw event.data; 21 }; 22 worker.onmessage = function (event) { 23 if (event.data != workerSubURL) { 24 throw new Error("Bad data!"); 25 } 26 postMessage(workerSubURL); 27 }; 28 };