зеркало из https://github.com/mozilla/pjs.git
Backout ff1f86491512:29e94992504b due to orange.
This commit is contained in:
Родитель
2bc23713a8
Коммит
c4f0612bd6
|
@ -312,14 +312,10 @@ nsFileChannel::MakeFileInputStream(nsIFile *file,
|
|||
bool isDir;
|
||||
nsresult rv = file->IsDirectory(&isDir);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_ERROR_FILE_NOT_FOUND == rv ||
|
||||
NS_ERROR_FILE_TARGET_DOES_NOT_EXIST == rv) {
|
||||
// We don't return "Not Found" errors here. Since we could not find
|
||||
// the file, it's not a directory anyway.
|
||||
isDir = false;
|
||||
} else {
|
||||
return rv;
|
||||
}
|
||||
// canonicalize error message
|
||||
if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)
|
||||
rv = NS_ERROR_FILE_NOT_FOUND;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (isDir) {
|
||||
|
@ -327,8 +323,7 @@ nsFileChannel::MakeFileInputStream(nsIFile *file,
|
|||
if (NS_SUCCEEDED(rv) && !HasContentTypeHint())
|
||||
contentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
|
||||
} else {
|
||||
rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file, -1, -1,
|
||||
nsIFileInputStream::DEFER_OPEN);
|
||||
rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file);
|
||||
if (NS_SUCCEEDED(rv) && !HasContentTypeHint()) {
|
||||
// Use file extension to infer content type
|
||||
nsCOMPtr<nsIMIMEService> mime = do_GetService("@mozilla.org/mime;1", &rv);
|
||||
|
@ -412,14 +407,8 @@ nsFileChannel::OpenContentStream(bool async, nsIInputStream **result,
|
|||
if (ContentLength64() < 0) {
|
||||
PRInt64 size;
|
||||
rv = file->GetFileSize(&size);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_ERROR_FILE_NOT_FOUND == rv ||
|
||||
NS_ERROR_FILE_TARGET_DOES_NOT_EXIST == rv) {
|
||||
size = 0;
|
||||
} else {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
SetContentLength64(size);
|
||||
}
|
||||
if (!contentType.IsEmpty())
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
function run_test() {
|
||||
do_test_pending();
|
||||
|
||||
function StreamListener() {}
|
||||
|
||||
StreamListener.prototype = {
|
||||
QueryInterface: function(aIID) {
|
||||
if (aIID.equals(Components.interfaces.nsIStreamListener) ||
|
||||
aIID.equals(Components.interfaces.nsIRequestObserver) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
|
||||
onStartRequest: function(aRequest, aContext) {},
|
||||
|
||||
onStopRequest: function(aRequest, aContext, aStatusCode) {
|
||||
// Make sure we can catch the error NS_ERROR_FILE_NOT_FOUND here.
|
||||
do_check_eq(aStatusCode, Components.results.NS_ERROR_FILE_NOT_FOUND);
|
||||
do_test_finished();
|
||||
},
|
||||
|
||||
onDataAvailable: function(aRequest, aContext, aStream, aOffset, aCount) {
|
||||
do_throw("The channel must not call onDataAvailable().");
|
||||
}
|
||||
};
|
||||
|
||||
let listener = new StreamListener();
|
||||
let ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
// This file does not exist.
|
||||
let file = do_get_file("_NOT_EXIST_.txt", true);
|
||||
do_check_false(file.exists());
|
||||
|
||||
let channel = ios.newChannelFromURI(ios.newFileURI(file));
|
||||
channel.asyncOpen(listener, null);
|
||||
}
|
|
@ -17,7 +17,6 @@ skip-if = os == "android"
|
|||
[test_bug248970_cookie.js]
|
||||
[test_bug261425.js]
|
||||
[test_bug263127.js]
|
||||
[test_bug282432.js]
|
||||
[test_bug321706.js]
|
||||
[test_bug331825.js]
|
||||
[test_bug336501.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче