forked from mirrors/gecko-dev
Backed out changeset 133c9084af25 (bug 1793736) for causing failures at browser_navigationPreload_read_after_respondWith.js.
This commit is contained in:
parent
b284155a5d
commit
bf0a7fa012
7 changed files with 54 additions and 64 deletions
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "Fetch.h"
|
||||
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/Value.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
|
|
@ -55,18 +54,15 @@ namespace mozilla::dom {
|
|||
namespace {
|
||||
|
||||
void AbortStream(JSContext* aCx, ReadableStream* aReadableStream,
|
||||
ErrorResult& aRv, JS::Handle<JS::Value> aReasonDetails) {
|
||||
ErrorResult& aRv) {
|
||||
if (aReadableStream->State() != ReadableStream::ReaderState::Readable) {
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> value(aCx, aReasonDetails);
|
||||
|
||||
if (aReasonDetails.isUndefined()) {
|
||||
RefPtr<DOMException> e = DOMException::Create(NS_ERROR_DOM_ABORT_ERR);
|
||||
if (!GetOrCreateDOMReflector(aCx, e, &value)) {
|
||||
return;
|
||||
}
|
||||
RefPtr<DOMException> e = DOMException::Create(NS_ERROR_DOM_ABORT_ERR);
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
if (!GetOrCreateDOMReflector(aCx, e, &value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReadableStreamError(aCx, aReadableStream, value, aRv);
|
||||
|
|
@ -284,8 +280,7 @@ class WorkerFetchResolver final : public FetchDriverObserver {
|
|||
void OnResponseAvailableInternal(
|
||||
SafeRefPtr<InternalResponse> aResponse) override;
|
||||
|
||||
void OnResponseEnd(FetchDriverObserver::EndReason aReason,
|
||||
JS::Handle<JS::Value> aReasonDetails) override;
|
||||
void OnResponseEnd(FetchDriverObserver::EndReason aReason) override;
|
||||
|
||||
bool NeedOnDataAvailable() override;
|
||||
|
||||
|
|
@ -361,14 +356,9 @@ class MainThreadFetchResolver final : public FetchDriverObserver {
|
|||
|
||||
void SetLoadGroup(nsILoadGroup* aLoadGroup) { mLoadGroup = aLoadGroup; }
|
||||
|
||||
void OnResponseEnd(FetchDriverObserver::EndReason aReason,
|
||||
JS::Handle<JS::Value> aReasonDetails) override {
|
||||
void OnResponseEnd(FetchDriverObserver::EndReason aReason) override {
|
||||
if (aReason == eAborted) {
|
||||
if (!aReasonDetails.isUndefined()) {
|
||||
mPromise->MaybeReject(aReasonDetails);
|
||||
} else {
|
||||
mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||
}
|
||||
mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||
}
|
||||
|
||||
mFetchObserver = nullptr;
|
||||
|
|
@ -521,14 +511,8 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
|
|||
|
||||
if (signalImpl && signalImpl->Aborted()) {
|
||||
// Already aborted signal rejects immediately.
|
||||
JS::Rooted<JS::Value> reason(cx, signalImpl->RawReason());
|
||||
if (reason.get().isUndefined()) {
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
p->MaybeReject(reason);
|
||||
return p.forget();
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::Realm* realm = JS::GetCurrentRealmOrNull(cx);
|
||||
|
|
@ -881,8 +865,8 @@ void WorkerFetchResolver::OnDataAvailable() {
|
|||
Unused << r->Dispatch();
|
||||
}
|
||||
|
||||
void WorkerFetchResolver::OnResponseEnd(FetchDriverObserver::EndReason aReason,
|
||||
JS::Handle<JS::Value> aReasonDetails) {
|
||||
void WorkerFetchResolver::OnResponseEnd(
|
||||
FetchDriverObserver::EndReason aReason) {
|
||||
AssertIsOnMainThread();
|
||||
MutexAutoLock lock(mPromiseProxy->Lock());
|
||||
if (mPromiseProxy->CleanedUp()) {
|
||||
|
|
@ -891,8 +875,6 @@ void WorkerFetchResolver::OnResponseEnd(FetchDriverObserver::EndReason aReason,
|
|||
|
||||
FlushConsoleReport();
|
||||
|
||||
Unused << aReasonDetails;
|
||||
|
||||
RefPtr<WorkerFetchResponseEndRunnable> r = new WorkerFetchResponseEndRunnable(
|
||||
mPromiseProxy->GetWorkerPrivate(), this, aReason);
|
||||
|
||||
|
|
@ -1211,20 +1193,9 @@ already_AddRefed<Promise> FetchBody<Derived>::ConsumeBody(
|
|||
|
||||
RefPtr<AbortSignalImpl> signalImpl =
|
||||
DerivedClass()->GetSignalImplToConsumeBody();
|
||||
|
||||
if (signalImpl && signalImpl->Aborted()) {
|
||||
JS::Rooted<JS::Value> abortReason(aCx, signalImpl->RawReason());
|
||||
|
||||
if (abortReason.get().isUndefined()) {
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> go = DerivedClass()->GetParentObject();
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(go, aRv);
|
||||
promise->MaybeReject(abortReason);
|
||||
return promise.forget();
|
||||
aRv.Throw(NS_ERROR_DOM_ABORT_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool bodyUsed = GetBodyUsed(aRv);
|
||||
|
|
@ -1369,8 +1340,7 @@ void FetchBody<Derived>::SetReadableStreamBody(JSContext* aCx,
|
|||
bool aborted = signalImpl->Aborted();
|
||||
if (aborted) {
|
||||
IgnoredErrorResult result;
|
||||
JS::Rooted<JS::Value> abortReason(aCx, signalImpl->RawReason());
|
||||
AbortStream(aCx, mReadableStreamBody, result, abortReason);
|
||||
AbortStream(aCx, mReadableStreamBody, result);
|
||||
if (NS_WARN_IF(result.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1425,8 +1395,7 @@ already_AddRefed<ReadableStream> FetchBody<Derived>::GetBody(JSContext* aCx,
|
|||
RefPtr<AbortSignalImpl> signalImpl = DerivedClass()->GetSignalImpl();
|
||||
if (signalImpl) {
|
||||
if (signalImpl->Aborted()) {
|
||||
JS::Rooted<JS::Value> abortReason(aCx, signalImpl->RawReason());
|
||||
AbortStream(aCx, body, aRv, abortReason);
|
||||
AbortStream(aCx, body, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -1530,9 +1499,7 @@ void FetchBody<Derived>::RunAbortAlgorithm() {
|
|||
|
||||
RefPtr<ReadableStream> body(mReadableStreamBody);
|
||||
IgnoredErrorResult result;
|
||||
|
||||
JS::Rooted<JS::Value> abortReason(cx, Signal()->RawReason());
|
||||
AbortStream(cx, body, result, abortReason);
|
||||
AbortStream(cx, body, result);
|
||||
}
|
||||
|
||||
template void FetchBody<Request>::RunAbortAlgorithm();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "js/Value.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/FetchDriver.h"
|
||||
|
||||
|
|
@ -589,7 +588,7 @@ nsresult FetchDriver::HttpFetch(
|
|||
secFlags |= nsILoadInfo::SEC_DONT_FOLLOW_REDIRECTS;
|
||||
}
|
||||
|
||||
// This handles the use credentials flag in "HTTP
|
||||
// This is handles the use credentials flag in "HTTP
|
||||
// network or cache fetch" in the spec and decides whether to transmit
|
||||
// cookies and other identifying information.
|
||||
if (mRequest->GetCredentialsMode() == RequestCredentials::Include) {
|
||||
|
|
@ -932,8 +931,7 @@ void FetchDriver::FailWithNetworkError(nsresult rv) {
|
|||
|
||||
// mObserver could be null after OnResponseAvailable().
|
||||
if (mObserver) {
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eByNetworking,
|
||||
JS::UndefinedHandleValue);
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eByNetworking);
|
||||
mObserver = nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -1462,8 +1460,7 @@ void FetchDriver::FinishOnStopRequest(
|
|||
}
|
||||
|
||||
if (mObserver) {
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eByNetworking,
|
||||
JS::UndefinedHandleValue);
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eByNetworking);
|
||||
mObserver = nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -1637,8 +1634,7 @@ void FetchDriver::RunAbortAlgorithm() {
|
|||
#ifdef DEBUG
|
||||
mResponseAvailableCalled = true;
|
||||
#endif
|
||||
JS::Rooted<JS::Value> reason(RootingCx(), Signal()->RawReason());
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eAborted, reason);
|
||||
mObserver->OnResponseEnd(FetchDriverObserver::eAborted);
|
||||
mObserver = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ class FetchDriverObserver {
|
|||
eByNetworking,
|
||||
};
|
||||
|
||||
virtual void OnResponseEnd(EndReason aReason,
|
||||
JS::Handle<JS::Value> aReasonDetails){};
|
||||
virtual void OnResponseEnd(EndReason aReason){};
|
||||
|
||||
nsIConsoleReportCollector* GetReporter() const { return mReporter; }
|
||||
|
||||
|
|
|
|||
|
|
@ -208,8 +208,7 @@ void FetchService::FetchInstance::Cancel() {
|
|||
}
|
||||
|
||||
void FetchService::FetchInstance::OnResponseEnd(
|
||||
FetchDriverObserver::EndReason aReason,
|
||||
JS::Handle<JS::Value> aReasonDetails) {
|
||||
FetchDriverObserver::EndReason aReason) {
|
||||
FETCH_LOG(("FetchInstance::OnResponseEnd [%p]", this));
|
||||
if (aReason == eAborted) {
|
||||
FETCH_LOG(("FetchInstance::OnResponseEnd end with eAborted"));
|
||||
|
|
|
|||
|
|
@ -116,8 +116,7 @@ class FetchService final : public nsIObserver {
|
|||
void Cancel();
|
||||
|
||||
/* FetchDriverObserver interface */
|
||||
void OnResponseEnd(FetchDriverObserver::EndReason aReason,
|
||||
JS::Handle<JS::Value> aReasonDetails) override;
|
||||
void OnResponseEnd(FetchDriverObserver::EndReason aReason) override;
|
||||
void OnResponseAvailableInternal(
|
||||
SafeRefPtr<InternalResponse> aResponse) override;
|
||||
bool NeedOnDataAvailable() override;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@
|
|||
expected:
|
||||
if (os == "linux") and not fission: [PASS, FAIL]
|
||||
|
||||
[Aborting rejects with abort reason]
|
||||
expected: FAIL
|
||||
|
||||
[Signal on request object should also have abort reason]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[general.any.html]
|
||||
[Stream will not error if body is empty. It's closed with an empty queue before it errors.]
|
||||
|
|
@ -25,6 +31,12 @@
|
|||
expected:
|
||||
if (os == "linux") and debug and not fission and not swgl: [PASS, FAIL]
|
||||
|
||||
[Aborting rejects with abort reason]
|
||||
expected: FAIL
|
||||
|
||||
[Signal on request object should also have abort reason]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[general.any.sharedworker.html]
|
||||
[Stream will not error if body is empty. It's closed with an empty queue before it errors.]
|
||||
|
|
@ -38,6 +50,12 @@
|
|||
if (os == "linux") and not swgl and fission and not debug: [PASS, FAIL]
|
||||
if (os == "linux") and not swgl and not fission and debug: [PASS, FAIL]
|
||||
|
||||
[Aborting rejects with abort reason]
|
||||
expected: FAIL
|
||||
|
||||
[Signal on request object should also have abort reason]
|
||||
expected: FAIL
|
||||
|
||||
[Stream errors once aborted, after reading. Underlying connection closed.]
|
||||
expected:
|
||||
if (os == "linux") and debug and not fission and not swgl: [PASS, FAIL]
|
||||
|
|
@ -61,3 +79,9 @@
|
|||
expected:
|
||||
if (os == "linux") and not swgl and not fission and not debug: [PASS, FAIL]
|
||||
if (os == "linux") and swgl: [PASS, FAIL]
|
||||
|
||||
[Aborting rejects with abort reason]
|
||||
expected: FAIL
|
||||
|
||||
[Signal on request object should also have abort reason]
|
||||
expected: FAIL
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
[serviceworker-intercepted.https.html]
|
||||
expected: TIMEOUT
|
||||
[fetch() rejects with abort reason]
|
||||
expected: FAIL
|
||||
|
||||
[Service Worker can observe the fetch abort and associated abort reason]
|
||||
expected: TIMEOUT
|
||||
|
||||
[Abort reason serialization happens on abort]
|
||||
expected: NOTRUN
|
||||
|
||||
[fetch() response body has abort reason]
|
||||
expected: FAIL
|
||||
|
|
|
|||
Loading…
Reference in a new issue