diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /dom/worklet/WorkletFetchHandler.cpp | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/worklet/WorkletFetchHandler.cpp')
-rw-r--r-- | dom/worklet/WorkletFetchHandler.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/dom/worklet/WorkletFetchHandler.cpp b/dom/worklet/WorkletFetchHandler.cpp index b259d6a357..b0c9ec1cfa 100644 --- a/dom/worklet/WorkletFetchHandler.cpp +++ b/dom/worklet/WorkletFetchHandler.cpp @@ -458,11 +458,8 @@ nsresult WorkletFetchHandler::StartFetch(JSContext* aCx, nsIURI* aURI, return NS_ERROR_FAILURE; } - RequestOrUSVString requestInput; - - nsAutoString url; - CopyUTF8toUTF16(spec, url); - requestInput.SetAsUSVString().ShareOrDependUpon(url); + RequestOrUTF8String requestInput; + requestInput.SetAsUTF8String().ShareOrDependUpon(spec); RootedDictionary<RequestInit> requestInit(aCx); requestInit.mCredentials.Construct(mCredentials); @@ -472,30 +469,33 @@ nsresult WorkletFetchHandler::StartFetch(JSContext* aCx, nsIURI* aURI, requestInit.mMode.Construct(RequestMode::Cors); if (aReferrer) { - nsAutoString referrer; - res = aReferrer->GetSpec(spec); + res = aReferrer->GetSpec(requestInit.mReferrer.Construct()); if (NS_WARN_IF(NS_FAILED(res))) { return NS_ERROR_FAILURE; } - - CopyUTF8toUTF16(spec, referrer); - requestInit.mReferrer.Construct(referrer); } nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWorklet->GetParentObject()); MOZ_ASSERT(global); + // Note: added to infer a default credentials mode in the Request setup, + // but we always pass an explicit credentials value in requestInit, so + // this has no effect right now. Bug 1887862 covers fixing worklets to behave + // the same as "normal" fetch calls. + nsIPrincipal* p = global->PrincipalOrNull(); + CallerType callerType = (p && p->IsSystemPrincipal() ? CallerType::System + : CallerType::NonSystem); IgnoredErrorResult rv; - SafeRefPtr<Request> request = - Request::Constructor(global, aCx, requestInput, requestInit, rv); + SafeRefPtr<Request> request = Request::Constructor( + global, aCx, requestInput, requestInit, callerType, rv); if (rv.Failed()) { return NS_ERROR_FAILURE; } request->OverrideContentPolicyType(mWorklet->Impl()->ContentPolicyType()); - RequestOrUSVString finalRequestInput; + RequestOrUTF8String finalRequestInput; finalRequestInput.SetAsRequest() = request.unsafeGetRawPtr(); RefPtr<Promise> fetchPromise = FetchRequest( |