Bug 1496621 - reject Fetch promises with (informative) TypeErrors when decoding fails, per spec; r=baku

reject Fetch promises with (informative) TypeErrors when decoding fails, per spec

Differential Revision: https://phabricator.services.mozilla.com/D7970

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Thomas Wisniewski 2018-10-08 23:57:23 +00:00
Родитель 1b619b4d1e
Коммит ba1f0dc311
3 изменённых файлов: 10 добавлений и 35 удалений

Просмотреть файл

@ -767,7 +767,15 @@ FetchBodyConsumer<Derived>::ContinueConsumeBody(nsresult aStatus,
}
if (NS_WARN_IF(NS_FAILED(aStatus))) {
localPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
// Per https://fetch.spec.whatwg.org/#concept-read-all-bytes-from-readablestream
// Decoding errors should reject with a TypeError
if (aStatus == NS_ERROR_INVALID_CONTENT_ENCODING) {
IgnoredErrorResult rv;
rv.ThrowTypeError<MSG_DOM_DECODING_FAILED>();
localPromise->MaybeReject(rv);
} else {
localPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
}
}
// Don't warn here since we warned above.

Просмотреть файл

@ -1221,7 +1221,7 @@ FetchDriver::OnStopRequest(nsIRequest* aRequest,
if (NS_FAILED(aStatusCode) || !mObserver) {
nsCOMPtr<nsIAsyncOutputStream> outputStream = do_QueryInterface(mPipeOutputStream);
if (outputStream) {
outputStream->CloseWithStatus(NS_BINDING_FAILED);
outputStream->CloseWithStatus(NS_FAILED(aStatusCode) ? aStatusCode : NS_BINDING_FAILED);
}
if (altDataListener) {
altDataListener->Cancel();

Просмотреть файл

@ -1,33 +0,0 @@
[bad-gzip-body.any.html]
[Consuming the body of a resource with bad gzip content with arrayBuffer() should reject]
expected: FAIL
[Consuming the body of a resource with bad gzip content with blob() should reject]
expected: FAIL
[Consuming the body of a resource with bad gzip content with formData() should reject]
expected: FAIL
[Consuming the body of a resource with bad gzip content with json() should reject]
expected: FAIL
[Consuming the body of a resource with bad gzip content with text() should reject]
expected: FAIL
[bad-gzip-body.any.worker.html]
[Consuming the body of a resource with bad gzip content with arrayBuffer() should reject]
expected: FAIL
[Consuming the body of a resource with bad gzip content with blob() should reject]
expected: FAIL
[Consuming the body of a resource with bad gzip content with formData() should reject]
expected: FAIL
[Consuming the body of a resource with bad gzip content with json() should reject]
expected: FAIL
[Consuming the body of a resource with bad gzip content with text() should reject]
expected: FAIL