mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 668361: File ctor should fail if passed a directory. r=sicking
This commit is contained in:
parent
5ad465dcb3
commit
3b073151cf
@ -424,6 +424,11 @@ nsDOMFile::Initialize(nsISupports* aOwner,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
NS_ENSURE_TRUE(exists, NS_ERROR_FILE_NOT_FOUND);
|
NS_ENSURE_TRUE(exists, NS_ERROR_FILE_NOT_FOUND);
|
||||||
|
|
||||||
|
PRBool isDir;
|
||||||
|
rv = file->IsDirectory(&isDir);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
NS_ENSURE_FALSE(isDir, NS_ERROR_FILE_IS_DIRECTORY);
|
||||||
|
|
||||||
mFile = file;
|
mFile = file;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,18 @@ try {
|
|||||||
var nonexistentfile = new File("i/sure/hope/this/does/not/exist/anywhere.txt");
|
var nonexistentfile = new File("i/sure/hope/this/does/not/exist/anywhere.txt");
|
||||||
ok(false, "This should never be reached!");
|
ok(false, "This should never be reached!");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ok(true, "Attempt to construct a non-existent file should fail.")
|
ok(true, "Attempt to construct a non-existent file should fail.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var dir = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
|
.getService(Components.interfaces.nsIProperties)
|
||||||
|
.get("CurWorkD", Components.interfaces.nsIFile);
|
||||||
|
var dirfile = new File(dir);
|
||||||
|
ok(false, "This should never be reached!");
|
||||||
|
} catch (e) {
|
||||||
|
ok(true, "Attempt to construct a file from a directory should fail.");
|
||||||
|
}
|
||||||
]]>
|
]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -110,6 +110,18 @@ FileComponent.prototype =
|
|||||||
}
|
}
|
||||||
do_check_true(threw, "Passing a random object should fail");
|
do_check_true(threw, "Passing a random object should fail");
|
||||||
|
|
||||||
|
var threw = false
|
||||||
|
try {
|
||||||
|
// Directories fail
|
||||||
|
var dir = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
|
.getService(Ci.nsIProperties)
|
||||||
|
.get("CurWorkD", Ci.nsIFile);
|
||||||
|
var f7 = File(dir)
|
||||||
|
} catch (e) {
|
||||||
|
threw = true;
|
||||||
|
}
|
||||||
|
do_check_true(threw, "Can't create a File object for a directory");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user