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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/social/test/browser/worker_relative.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,32 @@
     1.4 +// Used to test XHR in the worker.
     1.5 +onconnect = function(e) {
     1.6 +  let port = e.ports[0];
     1.7 +  let req;
     1.8 +  try {
     1.9 +    importScripts("relative_import.js");
    1.10 +    // the import should have exposed "testVar" and "testFunc" from the module.
    1.11 +    if (testVar != "oh hai" || testFunc() != "oh hai") {
    1.12 +      port.postMessage({topic: "done", result: "import worked but global is not available"});
    1.13 +      return;
    1.14 +    }
    1.15 +
    1.16 +    // causeError will cause a script error, so that we can check the
    1.17 +    // error location for importScripts'ed files is correct.
    1.18 +    try {
    1.19 +      causeError();
    1.20 +    } catch(e) {
    1.21 +      let fileName = e.fileName;
    1.22 +      if (fileName.startsWith("http") &&
    1.23 +          fileName.endsWith("/relative_import.js") &&
    1.24 +          e.lineNumber == 4)
    1.25 +        port.postMessage({topic: "done", result: "ok"});
    1.26 +      else
    1.27 +        port.postMessage({topic: "done", result: "invalid error location: " + fileName + ":" + e.lineNumber});
    1.28 +      return;
    1.29 +    }
    1.30 +  } catch(e) {
    1.31 +    port.postMessage({topic: "done", result: "FAILED to importScripts, " + e.toString() });
    1.32 +    return;
    1.33 +  }
    1.34 +  port.postMessage({topic: "done", result: "FAILED to importScripts, no exception" });
    1.35 +}

mercurial