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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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