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.

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

mercurial