diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /dom/fetch | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/fetch')
-rw-r--r-- | dom/fetch/Fetch.cpp | 20 | ||||
-rw-r--r-- | dom/fetch/FetchDriver.cpp | 7 | ||||
-rw-r--r-- | dom/fetch/FetchDriver.h | 8 | ||||
-rw-r--r-- | dom/fetch/FetchParent.cpp | 4 | ||||
-rw-r--r-- | dom/fetch/FetchParent.h | 1 | ||||
-rw-r--r-- | dom/fetch/FetchService.cpp | 13 | ||||
-rw-r--r-- | dom/fetch/FetchService.h | 13 | ||||
-rw-r--r-- | dom/fetch/PFetch.ipdl | 1 |
8 files changed, 45 insertions, 22 deletions
diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp index e2261d2e88..97c4c82fca 100644 --- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -661,6 +661,8 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal, actor->SetOriginStack(std::move(stack)); } + ipcArgs.isThirdPartyContext() = worker->IsThirdPartyContext(); + actor->DoFetchOp(ipcArgs); return p.forget(); @@ -792,7 +794,7 @@ class WorkerFetchResponseRunnable final : public MainThreadWorkerRunnable { WorkerFetchResponseRunnable(WorkerPrivate* aWorkerPrivate, WorkerFetchResolver* aResolver, SafeRefPtr<InternalResponse> aResponse) - : MainThreadWorkerRunnable(aWorkerPrivate, "WorkerFetchResponseRunnable"), + : MainThreadWorkerRunnable("WorkerFetchResponseRunnable"), mResolver(aResolver), mInternalResponse(std::move(aResponse)) { MOZ_ASSERT(mResolver); @@ -848,7 +850,7 @@ class WorkerDataAvailableRunnable final : public MainThreadWorkerRunnable { public: WorkerDataAvailableRunnable(WorkerPrivate* aWorkerPrivate, WorkerFetchResolver* aResolver) - : MainThreadWorkerRunnable(aWorkerPrivate, "WorkerDataAvailableRunnable"), + : MainThreadWorkerRunnable("WorkerDataAvailableRunnable"), mResolver(aResolver) {} bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override { @@ -889,8 +891,7 @@ class WorkerFetchResponseEndRunnable final : public MainThreadWorkerRunnable, WorkerFetchResponseEndRunnable(WorkerPrivate* aWorkerPrivate, WorkerFetchResolver* aResolver, FetchDriverObserver::EndReason aReason) - : MainThreadWorkerRunnable(aWorkerPrivate, - "WorkerFetchResponseEndRunnable"), + : MainThreadWorkerRunnable("WorkerFetchResponseEndRunnable"), WorkerFetchResponseEndBase(aResolver), mReason(aReason) {} @@ -917,7 +918,8 @@ class WorkerFetchResponseEndControlRunnable final public: WorkerFetchResponseEndControlRunnable(WorkerPrivate* aWorkerPrivate, WorkerFetchResolver* aResolver) - : MainThreadWorkerControlRunnable(aWorkerPrivate), + : MainThreadWorkerControlRunnable( + "WorkerFetchResponseEndControlRunnable"), WorkerFetchResponseEndBase(aResolver) {} bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override { @@ -940,7 +942,7 @@ void WorkerFetchResolver::OnResponseAvailableInternal( RefPtr<WorkerFetchResponseRunnable> r = new WorkerFetchResponseRunnable( mPromiseProxy->GetWorkerPrivate(), this, std::move(aResponse)); - if (!r->Dispatch()) { + if (!r->Dispatch(mPromiseProxy->GetWorkerPrivate())) { NS_WARNING("Could not dispatch fetch response"); } } @@ -960,7 +962,7 @@ void WorkerFetchResolver::OnDataAvailable() { RefPtr<WorkerDataAvailableRunnable> r = new WorkerDataAvailableRunnable(mPromiseProxy->GetWorkerPrivate(), this); - Unused << r->Dispatch(); + Unused << r->Dispatch(mPromiseProxy->GetWorkerPrivate()); } void WorkerFetchResolver::OnResponseEnd(FetchDriverObserver::EndReason aReason, @@ -978,14 +980,14 @@ void WorkerFetchResolver::OnResponseEnd(FetchDriverObserver::EndReason aReason, RefPtr<WorkerFetchResponseEndRunnable> r = new WorkerFetchResponseEndRunnable( mPromiseProxy->GetWorkerPrivate(), this, aReason); - if (!r->Dispatch()) { + if (!r->Dispatch(mPromiseProxy->GetWorkerPrivate())) { RefPtr<WorkerFetchResponseEndControlRunnable> cr = new WorkerFetchResponseEndControlRunnable( mPromiseProxy->GetWorkerPrivate(), this); // This can fail if the worker thread is canceled or killed causing // the PromiseWorkerProxy to give up its WorkerRef immediately, // allowing the worker thread to become Dead. - if (!cr->Dispatch()) { + if (!cr->Dispatch(mPromiseProxy->GetWorkerPrivate())) { NS_WARNING("Failed to dispatch WorkerFetchResponseEndControlRunnable"); } } diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index 79b54f4c4a..3a4099cf0e 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -665,6 +665,13 @@ nsresult FetchDriver::HttpFetch( nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo(); rv = loadInfo->SetWorkerAssociatedBrowsingContextID( mAssociatedBrowsingContextID); + NS_ENSURE_SUCCESS(rv, rv); + } + + if (mIsThirdPartyWorker.isSome()) { + nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo(); + rv = loadInfo->SetIsInThirdPartyContext(mIsThirdPartyWorker.ref()); + NS_ENSURE_SUCCESS(rv, rv); } // If the fetch is created by FetchEvent.request or NavigationPreload request, diff --git a/dom/fetch/FetchDriver.h b/dom/fetch/FetchDriver.h index de01c2a6be..36dd5fb3dd 100644 --- a/dom/fetch/FetchDriver.h +++ b/dom/fetch/FetchDriver.h @@ -145,6 +145,10 @@ class FetchDriver final : public nsIChannelEventSink, mAssociatedBrowsingContextID = aID; } + void SetIsThirdPartyWorker(const Maybe<bool> aIsThirdPartyWorker) { + mIsThirdPartyWorker = aIsThirdPartyWorker; + } + private: nsCOMPtr<nsIPrincipal> mPrincipal; nsCOMPtr<nsILoadGroup> mLoadGroup; @@ -179,6 +183,10 @@ class FetchDriver final : public nsIChannelEventSink, bool mIsTrackingFetch; + // Indicates whether the fetch request is from a third-party worker. Nothing + // if the fetch request is not from a worker. + Maybe<bool> mIsThirdPartyWorker; + RefPtr<AlternativeDataStreamListener> mAltDataListener; bool mOnStopRequestCalled; diff --git a/dom/fetch/FetchParent.cpp b/dom/fetch/FetchParent.cpp index 93e9b9e43e..2784792639 100644 --- a/dom/fetch/FetchParent.cpp +++ b/dom/fetch/FetchParent.cpp @@ -103,6 +103,7 @@ IPCResult FetchParent::RecvFetchOp(FetchOpArgs&& aArgs) { mCookieJarSettings = aArgs.cookieJarSettings(); mNeedOnDataAvailable = aArgs.needOnDataAvailable(); mHasCSPEventListener = aArgs.hasCSPEventListener(); + mIsThirdPartyContext = aArgs.isThirdPartyContext(); if (mHasCSPEventListener) { mCSPEventListener = @@ -173,7 +174,8 @@ IPCResult FetchParent::RecvFetchOp(FetchOpArgs&& aArgs) { self->mWorkerScript, self->mClientInfo, self->mController, self->mCookieJarSettings, self->mNeedOnDataAvailable, self->mCSPEventListener, self->mAssociatedBrowsingContextID, - self->mBackgroundEventTarget, self->mID}))); + self->mBackgroundEventTarget, self->mID, + self->mIsThirdPartyContext}))); self->mResponsePromises->GetResponseEndPromise()->Then( GetMainThreadSerialEventTarget(), __func__, diff --git a/dom/fetch/FetchParent.h b/dom/fetch/FetchParent.h index e373d93b73..59018e8cde 100644 --- a/dom/fetch/FetchParent.h +++ b/dom/fetch/FetchParent.h @@ -97,6 +97,7 @@ class FetchParent final : public PFetchParent { bool mHasCSPEventListener{false}; bool mExtendForCSPEventListener{false}; uint64_t mAssociatedBrowsingContextID{0}; + bool mIsThirdPartyContext{true}; Atomic<bool> mIsDone{false}; Atomic<bool> mActorDestroyed{false}; diff --git a/dom/fetch/FetchService.cpp b/dom/fetch/FetchService.cpp index 77decbc56f..9af967d6af 100644 --- a/dom/fetch/FetchService.cpp +++ b/dom/fetch/FetchService.cpp @@ -65,42 +65,42 @@ FetchServicePromises::GetResponseEndPromise() { } void FetchServicePromises::ResolveResponseAvailablePromise( - FetchServiceResponse&& aResponse, const char* aMethodName) { + FetchServiceResponse&& aResponse, StaticString aMethodName) { if (mAvailablePromise) { mAvailablePromise->Resolve(std::move(aResponse), aMethodName); } } void FetchServicePromises::RejectResponseAvailablePromise( - const CopyableErrorResult&& aError, const char* aMethodName) { + const CopyableErrorResult&& aError, StaticString aMethodName) { if (mAvailablePromise) { mAvailablePromise->Reject(aError, aMethodName); } } void FetchServicePromises::ResolveResponseTimingPromise( - ResponseTiming&& aTiming, const char* aMethodName) { + ResponseTiming&& aTiming, StaticString aMethodName) { if (mTimingPromise) { mTimingPromise->Resolve(std::move(aTiming), aMethodName); } } void FetchServicePromises::RejectResponseTimingPromise( - const CopyableErrorResult&& aError, const char* aMethodName) { + const CopyableErrorResult&& aError, StaticString aMethodName) { if (mTimingPromise) { mTimingPromise->Reject(aError, aMethodName); } } void FetchServicePromises::ResolveResponseEndPromise(ResponseEndArgs&& aArgs, - const char* aMethodName) { + StaticString aMethodName) { if (mEndPromise) { mEndPromise->Resolve(std::move(aArgs), aMethodName); } } void FetchServicePromises::RejectResponseEndPromise( - const CopyableErrorResult&& aError, const char* aMethodName) { + const CopyableErrorResult&& aError, StaticString aMethodName) { if (mEndPromise) { mEndPromise->Reject(aError, aMethodName); } @@ -229,6 +229,7 @@ RefPtr<FetchServicePromises> FetchService::FetchInstance::Fetch() { } mFetchDriver->SetAssociatedBrowsingContextID( args.mAssociatedBrowsingContextID); + mFetchDriver->SetIsThirdPartyWorker(Some(args.mIsThirdPartyContext)); } mFetchDriver->EnableNetworkInterceptControl(); diff --git a/dom/fetch/FetchService.h b/dom/fetch/FetchService.h index 2b9a4d2163..36c2527ef0 100644 --- a/dom/fetch/FetchService.h +++ b/dom/fetch/FetchService.h @@ -48,17 +48,17 @@ class FetchServicePromises final { RefPtr<FetchServiceResponseEndPromise> GetResponseEndPromise(); void ResolveResponseAvailablePromise(FetchServiceResponse&& aResponse, - const char* aMethodName); + StaticString aMethodName); void RejectResponseAvailablePromise(const CopyableErrorResult&& aError, - const char* aMethodName); + StaticString aMethodName); void ResolveResponseTimingPromise(ResponseTiming&& aTiming, - const char* aMethodName); + StaticString aMethodName); void RejectResponseTimingPromise(const CopyableErrorResult&& aError, - const char* aMethodName); + StaticString aMethodName); void ResolveResponseEndPromise(ResponseEndArgs&& aArgs, - const char* aMethodName); + StaticString aMethodName); void RejectResponseEndPromise(const CopyableErrorResult&& aError, - const char* aMethodName); + StaticString aMethodName); private: ~FetchServicePromises() = default; @@ -101,6 +101,7 @@ class FetchService final : public nsIObserver { uint64_t mAssociatedBrowsingContextID; nsCOMPtr<nsISerialEventTarget> mEventTarget; nsID mActorID; + bool mIsThirdPartyContext; }; struct UnknownArgs {}; diff --git a/dom/fetch/PFetch.ipdl b/dom/fetch/PFetch.ipdl index 904ef0738d..7ec1745658 100644 --- a/dom/fetch/PFetch.ipdl +++ b/dom/fetch/PFetch.ipdl @@ -24,6 +24,7 @@ struct FetchOpArgs{ bool needOnDataAvailable; bool hasCSPEventListener; uint64_t associatedBrowsingContextID; + bool isThirdPartyContext; }; protocol PFetch { |