зеркало из https://github.com/mozilla/gecko-dev.git
Bug 926902 - Incorrect error locations for errors from scripts importScripts'ed by the frameworker, r=markh.
This commit is contained in:
Родитель
70ec735ff9
Коммит
16cde4fe4b
|
@ -137,8 +137,10 @@ FrameWorker.prototype = {
|
|||
// Our importScripts function needs to 'eval' the script code from inside
|
||||
// a function, but using eval() directly means functions in the script
|
||||
// don't end up in the global scope.
|
||||
sandbox._evalInSandbox = function(s) {
|
||||
Cu.evalInSandbox(s, sandbox);
|
||||
sandbox._evalInSandbox = function(s, url) {
|
||||
let baseURI = Services.io.newURI(workerWindow.location.href, null, null);
|
||||
Cu.evalInSandbox(s, sandbox, "1.8",
|
||||
Services.io.newURI(url, null, baseURI).spec, 1);
|
||||
};
|
||||
|
||||
// and we delegate ononline and onoffline events to the worker.
|
||||
|
|
|
@ -34,7 +34,7 @@ function importScripts() {
|
|||
xhr.onreadystatechange = function(aEvt) {
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status == 200 || xhr.status == 0) {
|
||||
_evalInSandbox(xhr.responseText);
|
||||
_evalInSandbox(xhr.responseText, scriptURL);
|
||||
}
|
||||
else {
|
||||
throw new Error("Unable to importScripts ["+scriptURL+"], status " + xhr.status)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
dump("relative_import file\n");
|
||||
|
||||
// Please keep 'causeError' on line 4; we test the error location.
|
||||
function causeError() { does_not_exist(); }
|
||||
|
||||
testVar = "oh hai";
|
||||
function testFunc() {
|
||||
return "oh hai";
|
||||
|
|
|
@ -5,12 +5,25 @@ onconnect = function(e) {
|
|||
try {
|
||||
importScripts("relative_import.js");
|
||||
// the import should have exposed "testVar" and "testFunc" from the module.
|
||||
if (testVar == "oh hai" && testFunc() == "oh hai") {
|
||||
port.postMessage({topic: "done", result: "ok"});
|
||||
} else {
|
||||
if (testVar != "oh hai" || testFunc() != "oh hai") {
|
||||
port.postMessage({topic: "done", result: "import worked but global is not available"});
|
||||
return;
|
||||
}
|
||||
|
||||
// causeError will cause a script error, so that we can check the
|
||||
// error location for importScripts'ed files is correct.
|
||||
try {
|
||||
causeError();
|
||||
} catch(e) {
|
||||
let fileName = e.fileName;
|
||||
if (fileName.startsWith("http") &&
|
||||
fileName.endsWith("/relative_import.js") &&
|
||||
e.lineNumber == 4)
|
||||
port.postMessage({topic: "done", result: "ok"});
|
||||
else
|
||||
port.postMessage({topic: "done", result: "invalid error location: " + fileName + ":" + e.lineNumber});
|
||||
return;
|
||||
}
|
||||
return;
|
||||
} catch(e) {
|
||||
port.postMessage({topic: "done", result: "FAILED to importScripts, " + e.toString() });
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче