summaryrefslogtreecommitdiffstats
path: root/dom/worklet/WorkletFetchHandler.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /dom/worklet/WorkletFetchHandler.cpp
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-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.cpp26
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(