Bug 463122 - Propagate mozJSComponentLoader exceptions that occur while executing the script. r=mrbkap

This commit is contained in:
Josh Matthews 2011-12-28 11:55:11 -05:00
parent 188ae5dc61
commit a18ebbe4ab
4 changed files with 23 additions and 1 deletions

View File

@ -964,10 +964,20 @@ mozJSComponentLoader::GlobalForLocation(nsILocalFile *aComponentFile,
// See bug 384168.
*aGlobal = global;
if (!JS_ExecuteScriptVersion(cx, global, script, NULL, JSVERSION_LATEST)) {
uint32 oldopts = JS_GetOptions(cx);
JS_SetOptions(cx, oldopts |
(exception ? JSOPTION_DONT_REPORT_UNCAUGHT : 0));
bool ok = JS_ExecuteScriptVersion(cx, global, script, NULL, JSVERSION_LATEST);
JS_SetOptions(cx, oldopts);
if (!ok) {
#ifdef DEBUG_shaver_off
fprintf(stderr, "mJCL: failed to execute %s\n", nativePath.get());
#endif
if (exception) {
JS_GetPendingException(cx, exception);
JS_ClearPendingException(cx);
}
*aGlobal = nsnull;
return NS_ERROR_FAILURE;
}

View File

@ -0,0 +1 @@
Components.utils.import("resource://test/syntax_error.jsm");

View File

@ -0,0 +1,10 @@
function run_test()
{
try {
Components.utils.import("resource://test/importer.jsm");
do_check_true(false, "import should not succeed.");
} catch (x) {
do_check_neq(x.fileName.indexOf("syntax_error.jsm"), -1);
do_check_eq(x.lineNumber, 1);
}
}

View File

@ -14,6 +14,7 @@ tail =
[test_bug_442086.js]
[test_file.js]
[test_import.js]
[test_import_fail.js]
[test_js_weak_references.js]
[test_reflect_parse.js]
[test_localeCompare.js]