зеркало из https://github.com/mozilla/gecko-dev.git
Bug 787899 - Don't cancel the loading of a multipart/x-mixed-replace stream of we fail to initialize a part. r=jrmuizel
This commit is contained in:
Родитель
acf54d18ef
Коммит
b2e7fd1d96
|
@ -1105,7 +1105,10 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
|
||||||
// instantiates a decoder behind the scenes, so if we don't have a decoder
|
// instantiates a decoder behind the scenes, so if we don't have a decoder
|
||||||
// for this mimetype we'll find out about it here.
|
// for this mimetype we'll find out about it here.
|
||||||
rv = mImage->Init(this, mContentType.get(), uriString.get(), imageFlags);
|
rv = mImage->Init(this, mContentType.get(), uriString.get(), imageFlags);
|
||||||
if (NS_FAILED(rv)) { // Probably bad mimetype
|
|
||||||
|
// We allow multipart images to fail to initialize without cancelling the
|
||||||
|
// load because subsequent images might be fine.
|
||||||
|
if (NS_FAILED(rv) && !mIsMultiPartChannel) { // Probably bad mimetype
|
||||||
|
|
||||||
this->Cancel(rv);
|
this->Cancel(rv);
|
||||||
return NS_BINDING_ABORTED;
|
return NS_BINDING_ABORTED;
|
||||||
|
|
|
@ -58,6 +58,9 @@ MOCHITEST_FILES = imgutils.js \
|
||||||
bug733553.sjs \
|
bug733553.sjs \
|
||||||
bug733553-informant.sjs \
|
bug733553-informant.sjs \
|
||||||
animated-gif2.gif \
|
animated-gif2.gif \
|
||||||
|
invalid.jpg \
|
||||||
|
bad.jpg \
|
||||||
|
rillybad.jpg \
|
||||||
test_bug767779.html \
|
test_bug767779.html \
|
||||||
bug767779.sjs \
|
bug767779.sjs \
|
||||||
animated-gif_trailing-garbage.gif \
|
animated-gif_trailing-garbage.gif \
|
||||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 2.4 KiB |
|
@ -14,7 +14,12 @@ var bodyParts = [
|
||||||
["damon.jpg", "image/jpeg"],
|
["damon.jpg", "image/jpeg"],
|
||||||
["damon.jpg", "application/octet-stream"],
|
["damon.jpg", "application/octet-stream"],
|
||||||
["damon.jpg", "image/jpeg"],
|
["damon.jpg", "image/jpeg"],
|
||||||
["lime100x100.svg", "image/svg+xml"]
|
["rillybad.jpg", "application/x-unknown-content-type"],
|
||||||
|
["damon.jpg", "image/jpeg"],
|
||||||
|
["bad.jpg", "image/jpeg"],
|
||||||
|
["red.png", "image/png"],
|
||||||
|
["invalid.jpg", "image/jpeg"],
|
||||||
|
["animated-gif2.gif", "image/gif"]
|
||||||
];
|
];
|
||||||
var timer = Components.classes["@mozilla.org/timer;1"];
|
var timer = Components.classes["@mozilla.org/timer;1"];
|
||||||
var partTimer = timer.createInstance(Components.interfaces.nsITimer);
|
var partTimer = timer.createInstance(Components.interfaces.nsITimer);
|
||||||
|
|
Двоичный файл не отображается.
|
@ -28,7 +28,19 @@ var testParts = [
|
||||||
[1, "red.png"],
|
[1, "red.png"],
|
||||||
[80, "damon.jpg"],
|
[80, "damon.jpg"],
|
||||||
[80, "damon.jpg"],
|
[80, "damon.jpg"],
|
||||||
[80, "damon.jpg"]
|
[80, "damon.jpg"],
|
||||||
|
// An invalid image (from bug 787899) that is further delivered with a
|
||||||
|
// "special" bad MIME type that indicates that the necko
|
||||||
|
// multipart/x-mixed-replace parser wasn't able to parse it.
|
||||||
|
[0, "rillybad.jpg"],
|
||||||
|
// Bad.jpg is bad such that it sniffs as a JPEG, and therefore doesn't change
|
||||||
|
// what's been decoded (since the RasterImage isn't deleted), so its width
|
||||||
|
// needs to be the same as the previous image.
|
||||||
|
[80, "damon.jpg"],
|
||||||
|
[80, "bad.jpg"],
|
||||||
|
[1, "red.png"],
|
||||||
|
[0, "invalid.jpg"],
|
||||||
|
[40, "animated-gif2.gif"]
|
||||||
];
|
];
|
||||||
|
|
||||||
// We'll append the part number to this, and tell the informant
|
// We'll append the part number to this, and tell the informant
|
||||||
|
@ -51,17 +63,14 @@ function readyForNext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function imageLoad(aEvent) {
|
function imageLoad(aEvent) {
|
||||||
if (testParts.length > testIndex) {
|
|
||||||
var [width, fileName] = testParts[testIndex];
|
var [width, fileName] = testParts[testIndex];
|
||||||
is(aEvent.target.width, width,
|
is(aEvent.target.width, width,
|
||||||
"Test " + testIndex + " " + fileName + " width correct");
|
"Test " + testIndex + " " + fileName + " width correct");
|
||||||
readyForNext();
|
|
||||||
} else {
|
if ((testParts.length - 1) == testIndex) {
|
||||||
aEvent.target.removeEventListener("load", imageLoad, false);
|
|
||||||
aEvent.target.removeEventListener("error", imageLoad, false);
|
|
||||||
var loader = document.getElementById("loader");
|
|
||||||
readyForNext();
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
|
} else {
|
||||||
|
readyForNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче