relativeLoad_worker.js (790B)
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 workerURL */ 7 const importURL = "relativeLoad_import.js"; 8 9 onmessage = function () { 10 var xhr = new XMLHttpRequest(); 11 xhr.open("GET", "worker_testXHR.txt", false); 12 xhr.send(null); 13 if ( 14 xhr.status != 200 || 15 xhr.responseText != "A noisy noise annoys an oyster." 16 ) { 17 throw new Error("Couldn't get xhr text from where we wanted it!"); 18 } 19 20 importScripts(importURL); 21 var worker = new Worker("relativeLoad_worker2.js"); 22 worker.onerror = function (e) { 23 throw e.message; 24 }; 25 worker.onmessage = function (e) { 26 if (e.data != workerURL) { 27 throw new Error("Bad data!"); 28 } 29 postMessage(workerURL); 30 }; 31 };