toolkit/components/social/test/browser/worker_relative.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Used to test XHR in the worker.
michael@0 2 onconnect = function(e) {
michael@0 3 let port = e.ports[0];
michael@0 4 let req;
michael@0 5 try {
michael@0 6 importScripts("relative_import.js");
michael@0 7 // the import should have exposed "testVar" and "testFunc" from the module.
michael@0 8 if (testVar != "oh hai" || testFunc() != "oh hai") {
michael@0 9 port.postMessage({topic: "done", result: "import worked but global is not available"});
michael@0 10 return;
michael@0 11 }
michael@0 12
michael@0 13 // causeError will cause a script error, so that we can check the
michael@0 14 // error location for importScripts'ed files is correct.
michael@0 15 try {
michael@0 16 causeError();
michael@0 17 } catch(e) {
michael@0 18 let fileName = e.fileName;
michael@0 19 if (fileName.startsWith("http") &&
michael@0 20 fileName.endsWith("/relative_import.js") &&
michael@0 21 e.lineNumber == 4)
michael@0 22 port.postMessage({topic: "done", result: "ok"});
michael@0 23 else
michael@0 24 port.postMessage({topic: "done", result: "invalid error location: " + fileName + ":" + e.lineNumber});
michael@0 25 return;
michael@0 26 }
michael@0 27 } catch(e) {
michael@0 28 port.postMessage({topic: "done", result: "FAILED to importScripts, " + e.toString() });
michael@0 29 return;
michael@0 30 }
michael@0 31 port.postMessage({topic: "done", result: "FAILED to importScripts, no exception" });
michael@0 32 }

mercurial