michael@0: // Used to test XHR in the worker. michael@0: onconnect = function(e) { michael@0: let port = e.ports[0]; michael@0: let req; michael@0: try { michael@0: importScripts("relative_import.js"); michael@0: // the import should have exposed "testVar" and "testFunc" from the module. michael@0: if (testVar != "oh hai" || testFunc() != "oh hai") { michael@0: port.postMessage({topic: "done", result: "import worked but global is not available"}); michael@0: return; michael@0: } michael@0: michael@0: // causeError will cause a script error, so that we can check the michael@0: // error location for importScripts'ed files is correct. michael@0: try { michael@0: causeError(); michael@0: } catch(e) { michael@0: let fileName = e.fileName; michael@0: if (fileName.startsWith("http") && michael@0: fileName.endsWith("/relative_import.js") && michael@0: e.lineNumber == 4) michael@0: port.postMessage({topic: "done", result: "ok"}); michael@0: else michael@0: port.postMessage({topic: "done", result: "invalid error location: " + fileName + ":" + e.lineNumber}); michael@0: return; michael@0: } michael@0: } catch(e) { michael@0: port.postMessage({topic: "done", result: "FAILED to importScripts, " + e.toString() }); michael@0: return; michael@0: } michael@0: port.postMessage({topic: "done", result: "FAILED to importScripts, no exception" }); michael@0: }