зеркало из https://github.com/mozilla/gecko-dev.git
Bug 381499 - Components.utils.import reports NS_ERROR_FAILURE when the file not existsswitch to NS_ERROR_FILE_NOT_FOUND and update testsr=sayrer, sr=brendan
This commit is contained in:
Родитель
e8cd3eb3c4
Коммит
72244a2fb8
|
@ -1421,7 +1421,7 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation,
|
|||
&newEntry->location);
|
||||
if (NS_FAILED(rv)) {
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
mod = newEntry;
|
||||
|
|
|
@ -36,22 +36,26 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function test_BrokenFile(path, shouldThrow) {
|
||||
var f = do_get_file(path);
|
||||
function test_BrokenFile(path, shouldThrow, expectedName) {
|
||||
var f = do_get_file(path, true);
|
||||
var uri = "abs:" + f.path;
|
||||
print(uri);
|
||||
var didThrow = false;
|
||||
var didThrow;
|
||||
try {
|
||||
Components.utils.import(uri);
|
||||
Components.utils.import(uri);
|
||||
} catch (ex) {
|
||||
print("ex: " + ex);
|
||||
didThrow = true;
|
||||
var exceptionName = ex.name;
|
||||
print("ex: " + ex + "; name = " + ex.name);
|
||||
didThrow = true;
|
||||
}
|
||||
|
||||
do_check_true(didThrow == shouldThrow);
|
||||
|
||||
do_check_eq(didThrow, shouldThrow);
|
||||
if (didThrow)
|
||||
do_check_eq(exceptionName, expectedName);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
test_BrokenFile("js/src/xpconnect/tests/unit/bogus_exports_type.jsm", true);
|
||||
test_BrokenFile("js/src/xpconnect/tests/unit/bogus_element_type.jsm", true);
|
||||
test_BrokenFile("js/src/xpconnect/tests/unit/bogus_exports_type.jsm", true, "Error");
|
||||
test_BrokenFile("js/src/xpconnect/tests/unit/bogus_element_type.jsm", true, "Error");
|
||||
test_BrokenFile("js/src/xpconnect/tests/unit/non_existing.jsm", true, "NS_ERROR_FILE_NOT_FOUND");
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ function do_import_script(topsrcdirRelativePath) {
|
|||
load(scriptPath);
|
||||
}
|
||||
|
||||
function do_get_file(path) {
|
||||
function do_get_file(path, allowInexistent) {
|
||||
var comps = path.split("/");
|
||||
try {
|
||||
// The following always succeeds on Windows because we use cygpath with
|
||||
|
@ -168,7 +168,12 @@ function do_get_file(path) {
|
|||
lf.append(comps[i]);
|
||||
}
|
||||
|
||||
do_check_true(lf.exists());
|
||||
if (!allowInexistent) {
|
||||
if (!lf.exists()) {
|
||||
print(lf.path + " doesn't exist\n");
|
||||
}
|
||||
do_check_true(lf.exists());
|
||||
}
|
||||
|
||||
return lf;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче