summaryrefslogtreecommitdiffstats
path: root/dom/fetch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:11:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:11:27 +0000
commitf3bcaf9f88aad2c423ebcd61121562f9834187d4 (patch)
treef22238c29b57707b645a350940e3e9bdf3ce1f5d /dom/fetch
parentAdding debian version 115.7.0esr-1~deb12u1. (diff)
downloadfirefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.tar.xz
firefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.zip
Merging upstream version 115.8.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/fetch')
-rw-r--r--dom/fetch/FetchDriver.cpp1
-rw-r--r--dom/fetch/FetchService.cpp36
2 files changed, 29 insertions, 8 deletions
diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp
index 8c527ffeae..9fca1de608 100644
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -948,6 +948,7 @@ void FetchDriver::FailWithNetworkError(nsresult rv) {
// mObserver could be null after OnResponseAvailable().
if (mObserver) {
+ mObserver->OnReportPerformanceTiming();
mObserver->OnResponseEnd(FetchDriverObserver::eByNetworking,
JS::UndefinedHandleValue);
mObserver = nullptr;
diff --git a/dom/fetch/FetchService.cpp b/dom/fetch/FetchService.cpp
index e32d6f178e..b285d65692 100644
--- a/dom/fetch/FetchService.cpp
+++ b/dom/fetch/FetchService.cpp
@@ -256,8 +256,13 @@ void FetchService::FetchInstance::Cancel() {
FETCH_LOG(("FetchInstance::Cancel() [%p]", this));
+ // If mFetchDriver is not null here, FetchInstance::Fetch() has already
+ // started, let mFetchDriver::RunAbortAlgorithm() to call
+ // FetchInstance::OnResponseEnd() to resolve the pending promises.
+ // Otherwise, resolving the pending promises here.
if (mFetchDriver) {
mFetchDriver->RunAbortAlgorithm();
+ return;
}
MOZ_ASSERT(mPromises);
@@ -294,18 +299,30 @@ void FetchService::FetchInstance::OnResponseEnd(
MOZ_ASSERT(mPromises);
- // If ResponseTimingPromise is not resolved, it means the fetch is aborted.
- // Resolving ResponseTimingPromise with an emtpy ResponseTiming.
- if (!mPromises->GetResponseTimingPromise()->IsResolved()) {
- mPromises->ResolveResponseTimingPromise(ResponseTiming(), __func__);
- }
- // Resolve the ResponseEndPromise
- mPromises->ResolveResponseEndPromise(ResponseEndArgs(aReason), __func__);
-
if (aReason == eAborted) {
+ // If ResponseAvailablePromise has not resolved yet, resolved with
+ // NS_ERROR_DOM_ABORT_ERR response.
+ if (!mPromises->GetResponseAvailablePromise()->IsResolved()) {
+ mPromises->ResolveResponseAvailablePromise(
+ InternalResponse::NetworkError(NS_ERROR_DOM_ABORT_ERR), __func__);
+ }
+
+ // If ResponseTimingPromise has not resolved yet, resolved with empty
+ // ResponseTiming.
+ if (!mPromises->GetResponseTimingPromise()->IsResolved()) {
+ mPromises->ResolveResponseTimingPromise(ResponseTiming(), __func__);
+ }
+ // Resolve the ResponseEndPromise
+ mPromises->ResolveResponseEndPromise(ResponseEndArgs(aReason), __func__);
return;
}
+ MOZ_ASSERT(mPromises->GetResponseAvailablePromise()->IsResolved() &&
+ mPromises->GetResponseTimingPromise()->IsResolved());
+
+ // Resolve the ResponseEndPromise
+ mPromises->ResolveResponseEndPromise(ResponseEndArgs(aReason), __func__);
+
// Remove the FetchInstance from FetchInstanceTable
RefPtr<FetchService> fetchService = FetchService::GetInstance();
MOZ_ASSERT(fetchService);
@@ -414,7 +431,10 @@ void FetchService::FetchInstance::OnReportPerformanceTiming() {
UniquePtr<PerformanceTimingData> performanceTiming(
mFetchDriver->GetPerformanceTimingData(timing.initiatorType(),
timing.entryName()));
+ // FetchDriver has no corresponding performance timing when fetch() failed.
+ // Resolve the ResponseTimingPromise with empty timing.
if (!performanceTiming) {
+ mPromises->ResolveResponseTimingPromise(ResponseTiming(), __func__);
return;
}
timing.timingData() = performanceTiming->ToIPC();