Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/glue/./../../../ipc/glue/BackgroundUtils.cpp
Warning:line 520, column 7
Value stored to 'rv' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_ipc_glue0.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/glue -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/glue -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D HAVE_UINT64_T -D WEBRTC_MOZILLA_BUILD -D RTC_ENABLE_VP9 -D WEBRTC_POSIX -D WEBRTC_BUILD_LIBEVENT -D WEBRTC_LINUX -D WEBRTC_USE_PIPEWIRE -D WEBRTC_USE_X11 -D MOZ_CHILD_PROCESS_NAME="plugin-container" -D MOZ_CHILD_PROCESS_BUNDLENAME="None" -D MOZ_EME_PROCESS_NAME_BRANDED="None" -D MOZ_EME_PROCESS_BUNDLENAME="None" -D MOZ_GPU_PROCESS_NAME_BRANDED="None" -D MOZ_GPU_PROCESS_BUNDLENAME="None" -D MOZ_PKCS11_PROCESS_NAME_BRANDED="None" -D MOZ_PKCS11_PROCESS_BUNDLENAME="None" -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/ipc/glue -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/glue -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/libwebrtc_overrides -I /root/firefox-clang/caps -I /root/firefox-clang/dom/broadcastchannel -I /root/firefox-clang/dom/indexedDB -I /root/firefox-clang/dom/storage -I /root/firefox-clang/netwerk/base -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/third_party/libwebrtc -I /root/firefox-clang/tools/fuzzing/ipc -I /root/firefox-clang/xpcom/build -I /root/firefox-clang/dom/ipc -I /root/firefox-clang/toolkit/crashreporter -I /root/firefox-clang/toolkit/xre -I /root/firefox-clang/xpcom/base -I /root/firefox-clang/xpcom/threads -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-10-17-231001-351276-1 -x c++ Unified_cpp_ipc_glue0.cpp
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#include "BackgroundUtils.h"
6
7#include "MainThreadUtils.h"
8#include "mozilla/Assertions.h"
9#include "mozilla/BasePrincipal.h"
10#include "mozilla/ContentPrincipal.h"
11#include "mozilla/NullPrincipal.h"
12#include "mozilla/SystemPrincipal.h"
13#include "mozilla/ipc/PBackgroundSharedTypes.h"
14#include "mozilla/ipc/URIUtils.h"
15#include "mozilla/net/CookieJarSettings.h"
16#include "mozilla/net/InterceptionInfo.h"
17#include "mozilla/net/NeckoChannelParams.h"
18#include "ExpandedPrincipal.h"
19#include "nsIContentPolicy.h"
20#include "nsIScriptSecurityManager.h"
21#include "nsIURI.h"
22#include "nsNetUtil.h"
23#include "mozilla/LoadInfo.h"
24#include "nsContentUtils.h"
25#include "nsString.h"
26#include "nsTArray.h"
27#include "mozilla/nsRedirectHistoryEntry.h"
28#include "mozilla/dom/nsCSPUtils.h"
29#include "mozilla/dom/nsCSPContext.h"
30#include "mozilla/dom/BrowsingContext.h"
31#include "mozilla/dom/CanonicalBrowsingContext.h"
32#include "mozilla/dom/Document.h"
33#include "mozilla/dom/PolicyContainer.h"
34#include "mozilla/dom/WindowGlobalParent.h"
35#include "mozilla/LoadInfo.h"
36
37using namespace mozilla::dom;
38using namespace mozilla::net;
39
40namespace mozilla {
41
42namespace ipc {
43
44Result<nsCOMPtr<nsIPrincipal>, nsresult> PrincipalInfoToPrincipal(
45 const PrincipalInfo& aPrincipalInfo) {
46 MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::T__None)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aPrincipalInfo.type() != PrincipalInfo::T__None)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aPrincipalInfo.type() != PrincipalInfo::T__None))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipalInfo.type() != PrincipalInfo::T__None"
, "./../../../ipc/glue/BackgroundUtils.cpp", 46); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aPrincipalInfo.type() != PrincipalInfo::T__None"
")"); do { MOZ_CrashSequence(__null, 46); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
47
48 nsCOMPtr<nsIPrincipal> principal;
49 nsresult rv;
50
51 switch (aPrincipalInfo.type()) {
52 case PrincipalInfo::TSystemPrincipalInfo: {
53 principal = SystemPrincipal::Get();
54 if (NS_WARN_IF(!principal)NS_warn_if_impl(!principal, "!principal", "./../../../ipc/glue/BackgroundUtils.cpp"
, 54)
) {
55 return Err(NS_ERROR_NOT_INITIALIZED);
56 }
57
58 return principal;
59 }
60
61 case PrincipalInfo::TNullPrincipalInfo: {
62 const NullPrincipalInfo& info = aPrincipalInfo.get_NullPrincipalInfo();
63
64 nsCOMPtr<nsIURI> uri;
65 rv = NS_NewURI(getter_AddRefs(uri), info.spec());
66 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 66)
) {
67 return Err(rv);
68 }
69
70 if (!uri->SchemeIs(NS_NULLPRINCIPAL_SCHEME"moz-nullprincipal")) {
71 return Err(NS_ERROR_ILLEGAL_VALUE);
72 }
73
74 principal = NullPrincipal::Create(info.attrs(), uri);
75 return principal;
76 }
77
78 case PrincipalInfo::TContentPrincipalInfo: {
79 const ContentPrincipalInfo& info =
80 aPrincipalInfo.get_ContentPrincipalInfo();
81
82 nsCOMPtr<nsIURI> uri;
83 rv = NS_NewURI(getter_AddRefs(uri), info.spec());
84 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 84)
) {
85 return Err(rv);
86 }
87
88 nsCOMPtr<nsIURI> domain;
89 if (info.domain()) {
90 rv = NS_NewURI(getter_AddRefs(domain), *info.domain());
91 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 91)
) {
92 return Err(rv);
93 }
94 }
95
96 principal =
97 BasePrincipal::CreateContentPrincipal(uri, info.attrs(), domain);
98 if (NS_WARN_IF(!principal)NS_warn_if_impl(!principal, "!principal", "./../../../ipc/glue/BackgroundUtils.cpp"
, 98)
) {
99 return Err(NS_ERROR_NULL_POINTER);
100 }
101
102 // Origin must match what the_new_principal.getOrigin returns.
103 nsAutoCString originNoSuffix;
104 rv = principal->GetOriginNoSuffix(originNoSuffix);
105 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 105)
) {
106 return Err(rv);
107 }
108
109 if (NS_WARN_IF(!info.originNoSuffix().Equals(originNoSuffix))NS_warn_if_impl(!info.originNoSuffix().Equals(originNoSuffix)
, "!info.originNoSuffix().Equals(originNoSuffix)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 109)
) {
110 return Err(NS_ERROR_FAILURE);
111 }
112
113 if (!info.baseDomain().IsVoid()) {
114 nsAutoCString baseDomain;
115 rv = principal->GetBaseDomain(baseDomain);
116 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 116)
) {
117 return Err(rv);
118 }
119
120 if (NS_WARN_IF(!info.baseDomain().Equals(baseDomain))NS_warn_if_impl(!info.baseDomain().Equals(baseDomain), "!info.baseDomain().Equals(baseDomain)"
, "./../../../ipc/glue/BackgroundUtils.cpp", 120)
) {
121 return Err(NS_ERROR_FAILURE);
122 }
123 }
124 return principal;
125 }
126
127 case PrincipalInfo::TExpandedPrincipalInfo: {
128 const ExpandedPrincipalInfo& info =
129 aPrincipalInfo.get_ExpandedPrincipalInfo();
130
131 nsTArray<nsCOMPtr<nsIPrincipal>> allowlist;
132 nsCOMPtr<nsIPrincipal> alPrincipal;
133
134 for (uint32_t i = 0; i < info.allowlist().Length(); i++) {
135 auto principalOrErr = PrincipalInfoToPrincipal(info.allowlist()[i]);
136 if (NS_WARN_IF(principalOrErr.isErr())NS_warn_if_impl(principalOrErr.isErr(), "principalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 136)
) {
137 nsresult ret = principalOrErr.unwrapErr();
138 return Err(ret);
139 }
140 // append that principal to the allowlist
141 allowlist.AppendElement(principalOrErr.unwrap());
142 }
143
144 RefPtr<ExpandedPrincipal> expandedPrincipal =
145 ExpandedPrincipal::Create(allowlist, info.attrs());
146 if (!expandedPrincipal) {
147 return Err(NS_ERROR_FAILURE);
148 }
149
150 principal = expandedPrincipal;
151 return principal;
152 }
153
154 default:
155 return Err(NS_ERROR_FAILURE);
156 }
157}
158
159bool StorageKeysEqual(const PrincipalInfo& aLeft, const PrincipalInfo& aRight) {
160 MOZ_RELEASE_ASSERT(aLeft.type() == PrincipalInfo::TContentPrincipalInfo ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aLeft.type() == PrincipalInfo::TContentPrincipalInfo
|| aLeft.type() == PrincipalInfo::TSystemPrincipalInfo)>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aLeft.type() == PrincipalInfo::TContentPrincipalInfo
|| aLeft.type() == PrincipalInfo::TSystemPrincipalInfo))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo"
, "./../../../ipc/glue/BackgroundUtils.cpp", 161); AnnotateMozCrashReason
("MOZ_RELEASE_ASSERT" "(" "aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo"
")"); do { MOZ_CrashSequence(__null, 161); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
161 aLeft.type() == PrincipalInfo::TSystemPrincipalInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aLeft.type() == PrincipalInfo::TContentPrincipalInfo
|| aLeft.type() == PrincipalInfo::TSystemPrincipalInfo)>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aLeft.type() == PrincipalInfo::TContentPrincipalInfo
|| aLeft.type() == PrincipalInfo::TSystemPrincipalInfo))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo"
, "./../../../ipc/glue/BackgroundUtils.cpp", 161); AnnotateMozCrashReason
("MOZ_RELEASE_ASSERT" "(" "aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo"
")"); do { MOZ_CrashSequence(__null, 161); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
162 MOZ_RELEASE_ASSERT(aRight.type() == PrincipalInfo::TContentPrincipalInfo ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aRight.type() == PrincipalInfo::TContentPrincipalInfo
|| aRight.type() == PrincipalInfo::TSystemPrincipalInfo)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aRight.type() == PrincipalInfo::TContentPrincipalInfo
|| aRight.type() == PrincipalInfo::TSystemPrincipalInfo))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo"
, "./../../../ipc/glue/BackgroundUtils.cpp", 163); AnnotateMozCrashReason
("MOZ_RELEASE_ASSERT" "(" "aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo"
")"); do { MOZ_CrashSequence(__null, 163); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
163 aRight.type() == PrincipalInfo::TSystemPrincipalInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aRight.type() == PrincipalInfo::TContentPrincipalInfo
|| aRight.type() == PrincipalInfo::TSystemPrincipalInfo)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aRight.type() == PrincipalInfo::TContentPrincipalInfo
|| aRight.type() == PrincipalInfo::TSystemPrincipalInfo))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo"
, "./../../../ipc/glue/BackgroundUtils.cpp", 163); AnnotateMozCrashReason
("MOZ_RELEASE_ASSERT" "(" "aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo"
")"); do { MOZ_CrashSequence(__null, 163); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
164
165 if (aLeft.type() != aRight.type()) {
166 return false;
167 }
168
169 if (aLeft.type() == PrincipalInfo::TContentPrincipalInfo) {
170 const ContentPrincipalInfo& leftContent = aLeft.get_ContentPrincipalInfo();
171 const ContentPrincipalInfo& rightContent =
172 aRight.get_ContentPrincipalInfo();
173
174 return leftContent.attrs() == rightContent.attrs() &&
175 leftContent.originNoSuffix() == rightContent.originNoSuffix();
176 }
177
178 // Storage keys for the System principal always equal.
179 return true;
180}
181
182already_AddRefed<nsIContentSecurityPolicy> CSPInfoToCSP(
183 const CSPInfo& aCSPInfo, Document* aRequestingDoc,
184 nsresult* aOptionalResult) {
185 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 185); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence
(__null, 185); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
186
187 nsresult stackResult;
188 nsresult& rv = aOptionalResult ? *aOptionalResult : stackResult;
189
190 RefPtr csp = MakeRefPtr<nsCSPContext>();
191
192 if (aRequestingDoc) {
193 rv = csp->SetRequestContextWithDocument(aRequestingDoc);
194 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 194)
) {
195 return nullptr;
196 }
197 } else {
198 auto principalOrErr =
199 PrincipalInfoToPrincipal(aCSPInfo.requestPrincipalInfo());
200 if (NS_WARN_IF(principalOrErr.isErr())NS_warn_if_impl(principalOrErr.isErr(), "principalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 200)
) {
201 return nullptr;
202 }
203
204 nsCOMPtr<nsIURI> selfURI;
205 if (!aCSPInfo.selfURISpec().IsEmpty()) {
206 rv = NS_NewURI(getter_AddRefs(selfURI), aCSPInfo.selfURISpec());
207 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 207)
) {
208 return nullptr;
209 }
210 }
211
212 nsCOMPtr<nsIPrincipal> principal = principalOrErr.unwrap();
213
214 rv = csp->SetRequestContextWithPrincipal(
215 principal, selfURI, aCSPInfo.referrer(), aCSPInfo.innerWindowID());
216 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 216)
) {
217 return nullptr;
218 }
219 }
220 csp->SetSkipAllowInlineStyleCheck(aCSPInfo.skipAllowInlineStyleCheck());
221
222 for (uint32_t i = 0; i < aCSPInfo.policyInfos().Length(); i++) {
223 csp->AddIPCPolicy(aCSPInfo.policyInfos()[i]);
224 }
225 return csp.forget();
226}
227
228nsresult CSPToCSPInfo(nsIContentSecurityPolicy* aCSP, CSPInfo* aCSPInfo) {
229 MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(NS_IsMainThread())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 229); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { MOZ_CrashSequence
(__null, 229); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
230 MOZ_ASSERT(aCSP)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aCSP)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(aCSP))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("aCSP", "./../../../ipc/glue/BackgroundUtils.cpp"
, 230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCSP" ")"); do
{ MOZ_CrashSequence(__null, 230); __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
231 MOZ_ASSERT(aCSPInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aCSPInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aCSPInfo))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("aCSPInfo", "./../../../ipc/glue/BackgroundUtils.cpp"
, 231); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCSPInfo" ")"
); do { MOZ_CrashSequence(__null, 231); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
232
233 if (!aCSP || !aCSPInfo) {
234 return NS_ERROR_FAILURE;
235 }
236
237 nsCOMPtr<nsIPrincipal> requestPrincipal = aCSP->GetRequestPrincipal();
238
239 PrincipalInfo requestingPrincipalInfo;
240 nsresult rv =
241 PrincipalToPrincipalInfo(requestPrincipal, &requestingPrincipalInfo);
242 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 242)
) {
243 return rv;
244 }
245
246 nsCOMPtr<nsIURI> selfURI = aCSP->GetSelfURI();
247 nsAutoCString selfURISpec;
248 if (selfURI) {
249 selfURI->GetSpec(selfURISpec);
250 }
251
252 nsAutoCString referrer;
253 aCSP->GetReferrer(referrer);
254
255 uint64_t windowID = aCSP->GetInnerWindowID();
256 bool skipAllowInlineStyleCheck = aCSP->GetSkipAllowInlineStyleCheck();
257
258 RequireTrustedTypesForDirectiveState requireTrustedTypesForDirectiveState =
259 aCSP->GetRequireTrustedTypesForDirectiveState();
260
261 nsTArray<ContentSecurityPolicy> policies;
262 static_cast<nsCSPContext*>(aCSP)->SerializePolicies(policies);
263
264 *aCSPInfo = CSPInfo(std::move(policies), requestingPrincipalInfo, selfURISpec,
265 referrer, windowID, requireTrustedTypesForDirectiveState,
266 skipAllowInlineStyleCheck);
267 return NS_OK;
268}
269
270nsresult PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
271 PrincipalInfo* aPrincipalInfo,
272 bool aSkipBaseDomain) {
273 MOZ_ASSERT(aPrincipal)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aPrincipal)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aPrincipal))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aPrincipal", "./../../../ipc/glue/BackgroundUtils.cpp"
, 273); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipal" ")"
); do { MOZ_CrashSequence(__null, 273); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
274 MOZ_ASSERT(aPrincipalInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aPrincipalInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aPrincipalInfo))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("aPrincipalInfo"
, "./../../../ipc/glue/BackgroundUtils.cpp", 274); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aPrincipalInfo" ")"); do { MOZ_CrashSequence
(__null, 274); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
275
276 nsresult rv;
277 if (aPrincipal->GetIsNullPrincipal()) {
278 nsAutoCString spec;
279 rv = aPrincipal->GetAsciiSpec(spec);
280 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 280)
) {
281 return rv;
282 }
283
284 *aPrincipalInfo =
285 NullPrincipalInfo(aPrincipal->OriginAttributesRef(), spec);
286 return NS_OK;
287 }
288
289 if (aPrincipal->IsSystemPrincipal()) {
290 *aPrincipalInfo = SystemPrincipalInfo();
291 return NS_OK;
292 }
293
294 // might be an expanded principal
295 auto* basePrin = BasePrincipal::Cast(aPrincipal);
296 if (basePrin->Is<ExpandedPrincipal>()) {
297 auto* expanded = basePrin->As<ExpandedPrincipal>();
298
299 nsTArray<PrincipalInfo> allowlistInfo;
300 PrincipalInfo info;
301
302 for (auto& prin : expanded->AllowList()) {
303 rv = PrincipalToPrincipalInfo(prin, &info, aSkipBaseDomain);
304 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 304)
) {
305 return rv;
306 }
307 // append that spec to the allowlist
308 allowlistInfo.AppendElement(info);
309 }
310
311 *aPrincipalInfo = ExpandedPrincipalInfo(aPrincipal->OriginAttributesRef(),
312 std::move(allowlistInfo));
313 return NS_OK;
314 }
315
316 nsAutoCString spec;
317 rv = aPrincipal->GetAsciiSpec(spec);
318 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 318)
) {
319 return rv;
320 }
321
322 nsCString originNoSuffix;
323 rv = aPrincipal->GetOriginNoSuffix(originNoSuffix);
324 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 324)
) {
325 return rv;
326 }
327
328 nsCOMPtr<nsIURI> domainUri;
329 rv = aPrincipal->GetDomain(getter_AddRefs(domainUri));
330 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 330)
) {
331 return rv;
332 }
333
334 Maybe<nsCString> domain;
335 if (domainUri) {
336 domain.emplace();
337 rv = domainUri->GetSpec(domain.ref());
338 if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv
)), 0))), "NS_FAILED(rv)", "./../../../ipc/glue/BackgroundUtils.cpp"
, 338)
) {
339 return rv;
340 }
341 }
342
343 // This attribute is not crucial.
344 nsCString baseDomain;
345 if (aSkipBaseDomain) {
346 baseDomain.SetIsVoid(true);
347 } else {
348 if (NS_FAILED(aPrincipal->GetBaseDomain(baseDomain))((bool)(__builtin_expect(!!(NS_FAILED_impl(aPrincipal->GetBaseDomain
(baseDomain))), 0)))
) {
349 // No warning here. Some principal URLs do not have a base-domain.
350 baseDomain.SetIsVoid(true);
351 }
352 }
353
354 *aPrincipalInfo =
355 ContentPrincipalInfo(aPrincipal->OriginAttributesRef(), originNoSuffix,
356 spec, domain, baseDomain);
357 return NS_OK;
358}
359
360bool IsPrincipalInfoPrivate(const PrincipalInfo& aPrincipalInfo) {
361 if (aPrincipalInfo.type() != ipc::PrincipalInfo::TContentPrincipalInfo) {
362 return false;
363 }
364
365 const ContentPrincipalInfo& info = aPrincipalInfo.get_ContentPrincipalInfo();
366 return info.attrs().IsPrivateBrowsing();
367}
368
369already_AddRefed<nsIRedirectHistoryEntry> RHEntryInfoToRHEntry(
370 const RedirectHistoryEntryInfo& aRHEntryInfo) {
371 auto principalOrErr = PrincipalInfoToPrincipal(aRHEntryInfo.principalInfo());
372 if (NS_WARN_IF(principalOrErr.isErr())NS_warn_if_impl(principalOrErr.isErr(), "principalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 372)
) {
373 return nullptr;
374 }
375
376 nsCOMPtr<nsIPrincipal> principal = principalOrErr.unwrap();
377 nsCOMPtr<nsIURI> referrerUri = DeserializeURI(aRHEntryInfo.referrerUri());
378
379 nsCOMPtr<nsIRedirectHistoryEntry> entry = new nsRedirectHistoryEntry(
380 principal, referrerUri, aRHEntryInfo.remoteAddress());
381
382 return entry.forget();
383}
384
385nsresult RHEntryToRHEntryInfo(nsIRedirectHistoryEntry* aRHEntry,
386 RedirectHistoryEntryInfo* aRHEntryInfo) {
387 MOZ_ASSERT(aRHEntry)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aRHEntry)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aRHEntry))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("aRHEntry", "./../../../ipc/glue/BackgroundUtils.cpp"
, 387); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aRHEntry" ")"
); do { MOZ_CrashSequence(__null, 387); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
388 MOZ_ASSERT(aRHEntryInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aRHEntryInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aRHEntryInfo))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("aRHEntryInfo", "./../../../ipc/glue/BackgroundUtils.cpp"
, 388); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aRHEntryInfo"
")"); do { MOZ_CrashSequence(__null, 388); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
389
390 nsresult rv;
391 aRHEntry->GetRemoteAddress(aRHEntryInfo->remoteAddress());
392
393 nsCOMPtr<nsIURI> referrerUri;
394 rv = aRHEntry->GetReferrerURI(getter_AddRefs(referrerUri));
395 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 395); return rv; } } while (false)
;
396 SerializeURI(referrerUri, aRHEntryInfo->referrerUri());
397
398 nsCOMPtr<nsIPrincipal> principal;
399 rv = aRHEntry->GetPrincipal(getter_AddRefs(principal));
400 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 400); return rv; } } while (false)
;
401
402 return PrincipalToPrincipalInfo(principal, &aRHEntryInfo->principalInfo());
403}
404
405nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
406 LoadInfoArgs* outLoadInfoArgs) {
407 nsresult rv = NS_OK;
408 Maybe<PrincipalInfo> loadingPrincipalInfo;
409 if (nsIPrincipal* loadingPrin = aLoadInfo->GetLoadingPrincipal()) {
410 loadingPrincipalInfo.emplace();
411 rv = PrincipalToPrincipalInfo(loadingPrin, loadingPrincipalInfo.ptr());
412 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 412); return rv; } } while (false)
;
413 }
414
415 PrincipalInfo triggeringPrincipalInfo;
416 rv = PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
417 &triggeringPrincipalInfo);
418 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 418); return rv; } } while (false)
;
419
420 Maybe<PrincipalInfo> principalToInheritInfo;
421 if (nsIPrincipal* principalToInherit = aLoadInfo->PrincipalToInherit()) {
422 principalToInheritInfo.emplace();
423 rv = PrincipalToPrincipalInfo(principalToInherit,
424 principalToInheritInfo.ptr());
425 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 425); return rv; } } while (false)
;
426 }
427
428 Maybe<PrincipalInfo> topLevelPrincipalInfo;
429 if (nsIPrincipal* topLevenPrin = aLoadInfo->GetTopLevelPrincipal()) {
430 topLevelPrincipalInfo.emplace();
431 rv = PrincipalToPrincipalInfo(topLevenPrin, topLevelPrincipalInfo.ptr());
432 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 432); return rv; } } while (false)
;
433 }
434
435 Maybe<URIParams> optionalResultPrincipalURI;
436 nsCOMPtr<nsIURI> resultPrincipalURI;
437 (void)aLoadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
438 if (resultPrincipalURI) {
439 SerializeURI(resultPrincipalURI, optionalResultPrincipalURI);
440 }
441
442 RemoteType triggeringRemoteType;
443 rv = aLoadInfo->GetTriggeringRemoteType(triggeringRemoteType);
444 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 444); return rv; } } while (false)
;
445
446 nsTArray<RedirectHistoryEntryInfo> redirectChainIncludingInternalRedirects;
447 for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry :
448 aLoadInfo->RedirectChainIncludingInternalRedirects()) {
449 RedirectHistoryEntryInfo* entry =
450 redirectChainIncludingInternalRedirects.AppendElement();
451 rv = RHEntryToRHEntryInfo(redirectEntry, entry);
452 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 452); return rv; } } while (false)
;
453 }
454
455 nsTArray<RedirectHistoryEntryInfo> redirectChain;
456 for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry :
457 aLoadInfo->RedirectChain()) {
458 RedirectHistoryEntryInfo* entry = redirectChain.AppendElement();
459 rv = RHEntryToRHEntryInfo(redirectEntry, entry);
460 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 460); return rv; } } while (false)
;
461 }
462
463 Maybe<IPCClientInfo> ipcClientInfo;
464 const Maybe<ClientInfo>& clientInfo = aLoadInfo->GetClientInfo();
465 if (clientInfo.isSome()) {
466 ipcClientInfo.emplace(clientInfo.ref().ToIPC());
467 }
468
469 Maybe<IPCClientInfo> ipcReservedClientInfo;
470 const Maybe<ClientInfo>& reservedClientInfo =
471 aLoadInfo->GetReservedClientInfo();
472 if (reservedClientInfo.isSome()) {
473 ipcReservedClientInfo.emplace(reservedClientInfo.ref().ToIPC());
474 }
475
476 Maybe<IPCClientInfo> ipcInitialClientInfo;
477 const Maybe<ClientInfo>& initialClientInfo =
478 aLoadInfo->GetInitialClientInfo();
479 if (initialClientInfo.isSome()) {
480 ipcInitialClientInfo.emplace(initialClientInfo.ref().ToIPC());
481 }
482
483 Maybe<IPCServiceWorkerDescriptor> ipcController;
484 const Maybe<ServiceWorkerDescriptor>& controller = aLoadInfo->GetController();
485 if (controller.isSome()) {
486 ipcController.emplace(controller.ref().ToIPC());
487 }
488
489 nsAutoString cspNonce;
490 (void)NS_WARN_IF(NS_FAILED(aLoadInfo->GetCspNonce(cspNonce)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aLoadInfo
->GetCspNonce(cspNonce))), 0))), "NS_FAILED(aLoadInfo->GetCspNonce(cspNonce))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 490)
;
491
492 nsAutoString integrityMetadata;
493 (void)NS_WARN_IF(NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aLoadInfo
->GetIntegrityMetadata(integrityMetadata))), 0))), "NS_FAILED(aLoadInfo->GetIntegrityMetadata(integrityMetadata))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 494)
494 NS_FAILED(aLoadInfo->GetIntegrityMetadata(integrityMetadata)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aLoadInfo
->GetIntegrityMetadata(integrityMetadata))), 0))), "NS_FAILED(aLoadInfo->GetIntegrityMetadata(integrityMetadata))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 494)
;
495
496 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
497 rv = aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
498 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 498); return rv; } } while (false)
;
499
500 CookieJarSettingsArgs cookieJarSettingsArgs;
501 static_cast<CookieJarSettings*>(cookieJarSettings.get())
502 ->Serialize(cookieJarSettingsArgs);
503
504 nsCOMPtr<nsIURI> unstrippedURI;
505 (void)aLoadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI));
506
507 Maybe<bool> isThirdPartyContextToTopWindow;
508 if (static_cast<LoadInfo*>(aLoadInfo)
509 ->HasIsThirdPartyContextToTopWindowSet()) {
510 isThirdPartyContextToTopWindow.emplace(
511 aLoadInfo->GetIsThirdPartyContextToTopWindow());
512 }
513
514 Maybe<InterceptionInfoArg> interceptionInfoArg;
515 nsIInterceptionInfo* interceptionInfo = aLoadInfo->InterceptionInfo();
516 if (interceptionInfo) {
517 Maybe<PrincipalInfo> triggeringPrincipalInfo;
518 if (interceptionInfo->TriggeringPrincipal()) {
519 triggeringPrincipalInfo.emplace();
520 rv = PrincipalToPrincipalInfo(interceptionInfo->TriggeringPrincipal(),
Value stored to 'rv' is never read
521 triggeringPrincipalInfo.ptr());
522 }
523
524 nsTArray<RedirectHistoryEntryInfo> redirectChain;
525 for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry :
526 interceptionInfo->RedirectChain()) {
527 RedirectHistoryEntryInfo* entry = redirectChain.AppendElement();
528 rv = RHEntryToRHEntryInfo(redirectEntry, entry);
529 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 529); return rv; } } while (false)
;
530 }
531
532 interceptionInfoArg = Some(InterceptionInfoArg(
533 triggeringPrincipalInfo, interceptionInfo->ContentPolicyType(),
534 redirectChain, interceptionInfo->FromThirdParty()));
535 }
536
537 Maybe<RFPTargetSet> overriddenFingerprintingSettingsArg;
538 Maybe<RFPTargetSet> overriddenFingerprintingSettings =
539 aLoadInfo->GetOverriddenFingerprintingSettings();
540
541 if (overriddenFingerprintingSettings) {
542 overriddenFingerprintingSettingsArg =
543 Some(overriddenFingerprintingSettings.ref());
544 }
545
546 Maybe<RequestMode> requestMode;
547 aLoadInfo->GetRequestMode(&requestMode);
548
549 Maybe<PolicyContainerArgs> maybePolicyContainerToInherit;
550 nsCOMPtr<nsIPolicyContainer> policyContainerToInherit =
551 aLoadInfo->GetPolicyContainerToInherit();
552 if (policyContainerToInherit) {
553 PolicyContainerArgs args;
554 PolicyContainer::ToArgs(PolicyContainer::Cast(policyContainerToInherit),
555 args);
556 maybePolicyContainerToInherit.emplace(args);
557 }
558
559 *outLoadInfoArgs = LoadInfoArgs(
560 loadingPrincipalInfo, triggeringPrincipalInfo, principalToInheritInfo,
561 topLevelPrincipalInfo, optionalResultPrincipalURI, triggeringRemoteType,
562 aLoadInfo->GetSandboxedNullPrincipalID(), aLoadInfo->GetSecurityFlags(),
563 aLoadInfo->GetSandboxFlags(), aLoadInfo->GetTriggeringSandboxFlags(),
564 aLoadInfo->GetTriggeringWindowId(),
565 aLoadInfo->GetTriggeringFirstPartyClassificationFlags(),
566 aLoadInfo->GetTriggeringThirdPartyClassificationFlags(),
567 aLoadInfo->InternalContentPolicyType(),
568 static_cast<uint32_t>(aLoadInfo->GetTainting()),
569 aLoadInfo->GetBlockAllMixedContent(),
570 aLoadInfo->GetUpgradeInsecureRequests(),
571 aLoadInfo->GetBrowserUpgradeInsecureRequests(),
572 aLoadInfo->GetBrowserDidUpgradeInsecureRequests(),
573 aLoadInfo->GetBrowserWouldUpgradeInsecureRequests(),
574 aLoadInfo->GetForceAllowDataURI(),
575 aLoadInfo->GetAllowInsecureRedirectToDataURI(),
576 aLoadInfo->GetForceMediaDocument(),
577 aLoadInfo->GetSkipContentPolicyCheckForWebRequest(),
578 aLoadInfo->GetOriginalFrameSrcLoad(),
579 aLoadInfo->GetForceInheritPrincipalDropped(),
580 aLoadInfo->GetInnerWindowID(), aLoadInfo->GetBrowsingContextID(),
581 aLoadInfo->GetAssociatedBrowsingContextID(),
582 aLoadInfo->GetFrameBrowsingContextID(),
583 aLoadInfo->GetInitialSecurityCheckDone(),
584 aLoadInfo->GetIsInThirdPartyContext(), isThirdPartyContextToTopWindow,
585 aLoadInfo->GetIsOn3PCBExceptionList(), aLoadInfo->GetIsFormSubmission(),
586 aLoadInfo->GetIsGETRequest(), aLoadInfo->GetSendCSPViolationEvents(),
587 aLoadInfo->GetOriginAttributes(), redirectChainIncludingInternalRedirects,
588 redirectChain, aLoadInfo->GetSchemelessInput(),
589 aLoadInfo->GetHttpsUpgradeTelemetry(), ipcClientInfo,
590 ipcReservedClientInfo, ipcInitialClientInfo, ipcController,
591 aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->GetForcePreflight(),
592 aLoadInfo->GetIsPreflight(), aLoadInfo->GetLoadTriggeredFromExternal(),
593 aLoadInfo->GetServiceWorkerTaintingSynthesized(),
594 aLoadInfo->GetDocumentHasUserInteracted(),
595 aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(),
596 aLoadInfo->GetNeedForCheckingAntiTrackingHeuristic(), cspNonce,
597 integrityMetadata, aLoadInfo->GetSkipContentSniffing(),
598 aLoadInfo->GetHttpsOnlyStatus(), aLoadInfo->GetHstsStatus(),
599 aLoadInfo->GetHasValidUserGestureActivation(),
600 aLoadInfo->GetTextDirectiveUserActivation(),
601 aLoadInfo->GetAllowDeprecatedSystemRequests(),
602 aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(),
603 requestMode, aLoadInfo->GetIsFromProcessingFrameAttributes(),
604 aLoadInfo->GetIsMediaRequest(), cookieJarSettingsArgs,
605 aLoadInfo->GetRequestBlockingReason(), maybePolicyContainerToInherit,
606 aLoadInfo->GetStoragePermission(), aLoadInfo->GetParentIpAddressSpace(),
607 aLoadInfo->GetIpAddressSpace(), overriddenFingerprintingSettingsArg,
608 aLoadInfo->GetIsMetaRefresh(),
609 aLoadInfo->GetActivatedFromNavigationalPrefetch(),
610 aLoadInfo->GetLoadingEmbedderPolicy(),
611 aLoadInfo->GetIsOriginTrialCoepCredentiallessEnabledForTopLevel(),
612 unstrippedURI, interceptionInfoArg, aLoadInfo->GetIsNewWindowTarget(),
613 aLoadInfo->GetUserNavigationInvolvement(),
614 aLoadInfo->GetContainerPermissionsPolicyInfo(), {});
615
616 return NS_OK;
617}
618
619nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
620 const RemoteType& aOriginRemoteType,
621 nsILoadInfo** outLoadInfo) {
622 return LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, nullptr,
623 outLoadInfo);
624}
625nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
626 const RemoteType& aOriginRemoteType,
627 nsINode* aCspToInheritLoadingContext,
628 nsILoadInfo** outLoadInfo) {
629 RefPtr<LoadInfo> loadInfo;
630 nsresult rv = LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType,
631 aCspToInheritLoadingContext,
632 getter_AddRefs(loadInfo));
633 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 633); return rv; } } while (false)
;
634
635 loadInfo.forget(outLoadInfo);
636 return NS_OK;
637}
638
639nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
640 const RemoteType& aOriginRemoteType,
641 LoadInfo** outLoadInfo) {
642 return LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, nullptr,
643 outLoadInfo);
644}
645nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs,
646 const RemoteType& aOriginRemoteType,
647 nsINode* aCspToInheritLoadingContext,
648 LoadInfo** outLoadInfo) {
649 nsCOMPtr<nsIPrincipal> loadingPrincipal;
650 if (loadInfoArgs.requestingPrincipalInfo().isSome()) {
651 auto loadingPrincipalOrErr =
652 PrincipalInfoToPrincipal(loadInfoArgs.requestingPrincipalInfo().ref());
653 if (NS_WARN_IF(loadingPrincipalOrErr.isErr())NS_warn_if_impl(loadingPrincipalOrErr.isErr(), "loadingPrincipalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 653)
) {
654 return loadingPrincipalOrErr.unwrapErr();
655 }
656 loadingPrincipal = loadingPrincipalOrErr.unwrap();
657 }
658
659 auto triggeringPrincipalOrErr =
660 PrincipalInfoToPrincipal(loadInfoArgs.triggeringPrincipalInfo());
661 if (NS_WARN_IF(triggeringPrincipalOrErr.isErr())NS_warn_if_impl(triggeringPrincipalOrErr.isErr(), "triggeringPrincipalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 661)
) {
662 return triggeringPrincipalOrErr.unwrapErr();
663 }
664 nsCOMPtr<nsIPrincipal> triggeringPrincipal =
665 triggeringPrincipalOrErr.unwrap();
666
667 nsCOMPtr<nsIPrincipal> principalToInherit;
668 nsCOMPtr<nsIPrincipal> flattenedPrincipalToInherit;
669 if (loadInfoArgs.principalToInheritInfo().isSome()) {
670 auto principalToInheritOrErr =
671 PrincipalInfoToPrincipal(loadInfoArgs.principalToInheritInfo().ref());
672 if (NS_WARN_IF(principalToInheritOrErr.isErr())NS_warn_if_impl(principalToInheritOrErr.isErr(), "principalToInheritOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 672)
) {
673 return principalToInheritOrErr.unwrapErr();
674 }
675 flattenedPrincipalToInherit = principalToInheritOrErr.unwrap();
676 }
677
678 if (XRE_IsContentProcess()) {
679 auto targetBrowsingContextId = loadInfoArgs.frameBrowsingContextID()
680 ? loadInfoArgs.frameBrowsingContextID()
681 : loadInfoArgs.browsingContextID();
682 if (RefPtr<BrowsingContext> bc =
683 BrowsingContext::Get(targetBrowsingContextId)) {
684 auto [originalTriggeringPrincipal, originalPrincipalToInherit] =
685 bc->GetTriggeringAndInheritPrincipalsForCurrentLoad();
686
687 if (originalTriggeringPrincipal &&
688 originalTriggeringPrincipal->Equals(triggeringPrincipal)) {
689 triggeringPrincipal = originalTriggeringPrincipal;
690 }
691 if (originalPrincipalToInherit &&
692 (loadInfoArgs.securityFlags() &
693 nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL) &&
694 originalPrincipalToInherit->Equals(flattenedPrincipalToInherit)) {
695 principalToInherit = originalPrincipalToInherit;
696 }
697 }
698 }
699 if (!principalToInherit && loadInfoArgs.principalToInheritInfo().isSome()) {
700 principalToInherit = flattenedPrincipalToInherit;
701 }
702
703 nsCOMPtr<nsIPrincipal> topLevelPrincipal;
704 if (loadInfoArgs.topLevelPrincipalInfo().isSome()) {
705 auto topLevelPrincipalOrErr =
706 PrincipalInfoToPrincipal(loadInfoArgs.topLevelPrincipalInfo().ref());
707 if (NS_WARN_IF(topLevelPrincipalOrErr.isErr())NS_warn_if_impl(topLevelPrincipalOrErr.isErr(), "topLevelPrincipalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 707)
) {
708 return topLevelPrincipalOrErr.unwrapErr();
709 }
710 topLevelPrincipal = topLevelPrincipalOrErr.unwrap();
711 }
712
713 nsCOMPtr<nsIURI> resultPrincipalURI;
714 if (loadInfoArgs.resultPrincipalURI().isSome()) {
715 resultPrincipalURI = DeserializeURI(loadInfoArgs.resultPrincipalURI());
716 NS_ENSURE_TRUE(resultPrincipalURI, NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(resultPrincipalURI)), 0))) { NS_DebugBreak
(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "resultPrincipalURI" ") failed"
, nullptr, "./../../../ipc/glue/BackgroundUtils.cpp", 716); return
NS_ERROR_UNEXPECTED; } } while (false)
;
717 }
718
719 // If we received this message from a content process, reset
720 // triggeringRemoteType to the process which sent us the message. If the
721 // parent sent us the message, we trust it to provide the correct triggering
722 // remote type.
723 //
724 // This means that the triggering remote type will be reset if a LoadInfo is
725 // bounced through a content process, as the LoadInfo can no longer be
726 // validated to be coming from the originally specified remote type.
727 RemoteType triggeringRemoteType = loadInfoArgs.triggeringRemoteType();
728 if (!aOriginRemoteType.IsNotRemote() &&
729 aOriginRemoteType != triggeringRemoteType) {
730 triggeringRemoteType = aOriginRemoteType;
731 }
732
733 RedirectHistoryArray redirectChainIncludingInternalRedirects;
734 for (const RedirectHistoryEntryInfo& entryInfo :
735 loadInfoArgs.redirectChainIncludingInternalRedirects()) {
736 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
737 RHEntryInfoToRHEntry(entryInfo);
738 NS_ENSURE_TRUE(redirectHistoryEntry, NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(redirectHistoryEntry)), 0))) {
NS_DebugBreak(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "redirectHistoryEntry"
") failed", nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 738); return NS_ERROR_UNEXPECTED; } } while (false)
;
739 redirectChainIncludingInternalRedirects.AppendElement(
740 redirectHistoryEntry.forget());
741 }
742
743 RedirectHistoryArray redirectChain;
744 for (const RedirectHistoryEntryInfo& entryInfo :
745 loadInfoArgs.redirectChain()) {
746 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
747 RHEntryInfoToRHEntry(entryInfo);
748 NS_ENSURE_TRUE(redirectHistoryEntry, NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(redirectHistoryEntry)), 0))) {
NS_DebugBreak(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "redirectHistoryEntry"
") failed", nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 748); return NS_ERROR_UNEXPECTED; } } while (false)
;
749 redirectChain.AppendElement(redirectHistoryEntry.forget());
750 }
751 nsTArray<nsCOMPtr<nsIPrincipal>> ancestorPrincipals;
752 nsTArray<uint64_t> ancestorBrowsingContextIDs;
753 if (XRE_IsParentProcess() &&
754 (nsContentUtils::InternalContentPolicyTypeToExternal(
755 loadInfoArgs.contentPolicyType()) !=
756 ExtContentPolicy::TYPE_DOCUMENT)) {
757 // Only fill out ancestor principals and browsing context IDs when we
758 // are deserializing LoadInfoArgs to be LoadInfo for a subresource
759 RefPtr<BrowsingContext> parentBC =
760 BrowsingContext::Get(loadInfoArgs.browsingContextID());
761 if (parentBC) {
762 LoadInfo::ComputeAncestors(parentBC->Canonical(), ancestorPrincipals,
763 ancestorBrowsingContextIDs);
764 }
765 } else {
766 // Fill out (possibly redacted) ancestor principals for
767 // Location.ancestorOrigins
768 for (const auto& principalInfo : loadInfoArgs.ancestorOrigins()) {
769 if (principalInfo.isNothing()) {
770 ancestorPrincipals.AppendElement(nullptr);
771 } else {
772 auto principal = PrincipalInfoToPrincipal(principalInfo.value());
773 // If this operation fail, we censor the origin.
774 ancestorPrincipals.AppendElement(principal.unwrapOr(nullptr));
775 }
776 }
777 }
778
779 Maybe<ClientInfo> clientInfo;
780 if (loadInfoArgs.clientInfo().isSome()) {
781 clientInfo.emplace(ClientInfo(loadInfoArgs.clientInfo().ref()));
782 }
783
784 Maybe<ClientInfo> reservedClientInfo;
785 if (loadInfoArgs.reservedClientInfo().isSome()) {
786 reservedClientInfo.emplace(
787 ClientInfo(loadInfoArgs.reservedClientInfo().ref()));
788 }
789
790 Maybe<ClientInfo> initialClientInfo;
791 if (loadInfoArgs.initialClientInfo().isSome()) {
792 initialClientInfo.emplace(
793 ClientInfo(loadInfoArgs.initialClientInfo().ref()));
794 }
795
796 // We can have an initial client info or a reserved client info, but not both.
797 MOZ_DIAGNOSTIC_ASSERT(reservedClientInfo.isNothing() ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reservedClientInfo.isNothing() || initialClientInfo.
isNothing())>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(reservedClientInfo.isNothing() ||
initialClientInfo.isNothing()))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 798); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
")"); do { MOZ_CrashSequence(__null, 798); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
798 initialClientInfo.isNothing())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reservedClientInfo.isNothing() || initialClientInfo.
isNothing())>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(reservedClientInfo.isNothing() ||
initialClientInfo.isNothing()))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 798); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
")"); do { MOZ_CrashSequence(__null, 798); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
799 NS_ENSURE_TRUE(do { if ((__builtin_expect(!!(!(reservedClientInfo.isNothing(
) || initialClientInfo.isNothing())), 0))) { NS_DebugBreak(NS_DEBUG_WARNING
, "NS_ENSURE_TRUE(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
") failed", nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 801); return NS_ERROR_UNEXPECTED; } } while (false)
800 reservedClientInfo.isNothing() || initialClientInfo.isNothing(),do { if ((__builtin_expect(!!(!(reservedClientInfo.isNothing(
) || initialClientInfo.isNothing())), 0))) { NS_DebugBreak(NS_DEBUG_WARNING
, "NS_ENSURE_TRUE(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
") failed", nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 801); return NS_ERROR_UNEXPECTED; } } while (false)
801 NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(reservedClientInfo.isNothing(
) || initialClientInfo.isNothing())), 0))) { NS_DebugBreak(NS_DEBUG_WARNING
, "NS_ENSURE_TRUE(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
") failed", nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 801); return NS_ERROR_UNEXPECTED; } } while (false)
;
802
803 Maybe<ServiceWorkerDescriptor> controller;
804 if (loadInfoArgs.controller().isSome()) {
805 controller.emplace(
806 ServiceWorkerDescriptor(loadInfoArgs.controller().ref()));
807 }
808
809 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
810 CookieJarSettings::Deserialize(loadInfoArgs.cookieJarSettings(),
811 getter_AddRefs(cookieJarSettings));
812
813 Maybe<RFPTargetSet> overriddenFingerprintingSettings;
814 if (loadInfoArgs.overriddenFingerprintingSettings().isSome()) {
815 overriddenFingerprintingSettings.emplace(
816 loadInfoArgs.overriddenFingerprintingSettings().ref());
817 }
818
819 // Restore the loadingContext for frames using the BrowsingContext's
820 // embedder element. Note that this only works if the embedder is
821 // same-process, so won't be fission compatible.
822 nsCOMPtr<nsINode> loadingContext;
823 RefPtr<BrowsingContext> frameBrowsingContext =
824 BrowsingContext::Get(loadInfoArgs.frameBrowsingContextID());
825 if (frameBrowsingContext) {
826 loadingContext = frameBrowsingContext->GetEmbedderElement();
827 }
828
829 Maybe<bool> isThirdPartyContextToTopWindow;
830 if (loadInfoArgs.isThirdPartyContextToTopWindow().isSome()) {
831 isThirdPartyContextToTopWindow.emplace(
832 loadInfoArgs.isThirdPartyContextToTopWindow().ref());
833 }
834
835 nsCOMPtr<nsIInterceptionInfo> interceptionInfo;
836 if (loadInfoArgs.interceptionInfo().isSome()) {
837 const InterceptionInfoArg& interceptionInfoArg =
838 loadInfoArgs.interceptionInfo().ref();
839 nsCOMPtr<nsIPrincipal> triggeringPrincipal;
840 if (interceptionInfoArg.triggeringPrincipalInfo().isSome()) {
841 auto triggeringPrincipalOrErr = PrincipalInfoToPrincipal(
842 interceptionInfoArg.triggeringPrincipalInfo().ref());
843 if (NS_WARN_IF(triggeringPrincipalOrErr.isErr())NS_warn_if_impl(triggeringPrincipalOrErr.isErr(), "triggeringPrincipalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 843)
) {
844 return triggeringPrincipalOrErr.unwrapErr();
845 }
846 triggeringPrincipal = triggeringPrincipalOrErr.unwrap();
847 }
848
849 RedirectHistoryArray redirectChain;
850 for (const RedirectHistoryEntryInfo& entryInfo :
851 interceptionInfoArg.redirectChain()) {
852 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
853 RHEntryInfoToRHEntry(entryInfo);
854 NS_ENSURE_TRUE(redirectHistoryEntry, NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(redirectHistoryEntry)), 0))) {
NS_DebugBreak(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "redirectHistoryEntry"
") failed", nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 854); return NS_ERROR_UNEXPECTED; } } while (false)
;
855 redirectChain.AppendElement(redirectHistoryEntry.forget());
856 }
857
858 interceptionInfo = new InterceptionInfo(
859 triggeringPrincipal, interceptionInfoArg.contentPolicyType(),
860 redirectChain, interceptionInfoArg.fromThirdParty());
861 }
862
863 RefPtr<PolicyContainer> policyContainerToInherit;
864 const auto& policyContainerToInheritArgs =
865 loadInfoArgs.policyContainerToInherit();
866 if (policyContainerToInheritArgs.isSome()) {
867 nsCOMPtr<Document> doc = do_QueryInterface(aCspToInheritLoadingContext);
868 PolicyContainer::FromArgs(policyContainerToInheritArgs.ref(), doc,
869 getter_AddRefs(policyContainerToInherit));
870 }
871
872 RefPtr<mozilla::net::LoadInfo> loadInfo = new mozilla::net::LoadInfo(
873 loadingPrincipal, triggeringPrincipal, principalToInherit,
874 topLevelPrincipal, resultPrincipalURI, cookieJarSettings,
875 policyContainerToInherit, loadInfoArgs.containerPermissionsPolicyInfo(),
876 triggeringRemoteType, loadInfoArgs.sandboxedNullPrincipalID(), clientInfo,
877 reservedClientInfo, initialClientInfo, controller,
878 loadInfoArgs.securityFlags(), loadInfoArgs.sandboxFlags(),
879 loadInfoArgs.contentPolicyType(),
880 loadInfoArgs.serviceWorkerTaintingSynthesized(),
881 static_cast<LoadTainting>(loadInfoArgs.tainting()),
882
883#define DEFINE_ARGUMENT(_t, _n, name, _d) loadInfoArgs.name(),
884 LOADINFO_FOR_EACH_FIELD(DEFINE_ARGUMENT, LOADINFO_DUMMY_SETTER)DEFINE_ARGUMENT(uint32_t, TriggeringSandboxFlags, triggeringSandboxFlags
, 0) DEFINE_ARGUMENT(uint64_t, TriggeringWindowId, triggeringWindowId
, 0) DEFINE_ARGUMENT(uint32_t, TriggeringFirstPartyClassificationFlags
, triggeringFirstPartyClassificationFlags, 0) DEFINE_ARGUMENT
(uint32_t, TriggeringThirdPartyClassificationFlags, triggeringThirdPartyClassificationFlags
, 0) DEFINE_ARGUMENT(bool, BlockAllMixedContent, blockAllMixedContent
, false) DEFINE_ARGUMENT(bool, UpgradeInsecureRequests, upgradeInsecureRequests
, false) DEFINE_ARGUMENT(bool, BrowserUpgradeInsecureRequests
, browserUpgradeInsecureRequests, false) DEFINE_ARGUMENT(bool
, BrowserDidUpgradeInsecureRequests, browserDidUpgradeInsecureRequests
, false) DEFINE_ARGUMENT(bool, BrowserWouldUpgradeInsecureRequests
, browserWouldUpgradeInsecureRequests, false) DEFINE_ARGUMENT
(bool, ForceAllowDataURI, forceAllowDataURI, false) DEFINE_ARGUMENT
(bool, AllowInsecureRedirectToDataURI, allowInsecureRedirectToDataURI
, false) DEFINE_ARGUMENT(dom::ForceMediaDocument, ForceMediaDocument
, forceMediaDocument, dom::ForceMediaDocument(0)) DEFINE_ARGUMENT
(bool, SkipContentPolicyCheckForWebRequest, skipContentPolicyCheckForWebRequest
, false) DEFINE_ARGUMENT(bool, OriginalFrameSrcLoad, originalFrameSrcLoad
, false) DEFINE_ARGUMENT(bool, ForceInheritPrincipalDropped, forceInheritPrincipalDropped
, false) DEFINE_ARGUMENT(uint64_t, InnerWindowID, innerWindowID
, 0) DEFINE_ARGUMENT(uint64_t, BrowsingContextID, browsingContextID
, 0) DEFINE_ARGUMENT(uint64_t, AssociatedBrowsingContextID, associatedBrowsingContextID
, 0) DEFINE_ARGUMENT(uint64_t, FrameBrowsingContextID, frameBrowsingContextID
, 0) DEFINE_ARGUMENT(bool, IsOn3PCBExceptionList, isOn3PCBExceptionList
, false) DEFINE_ARGUMENT(bool, IsFormSubmission, isFormSubmission
, false) DEFINE_ARGUMENT(bool, IsGETRequest, isGETRequest, true
) DEFINE_ARGUMENT(bool, SendCSPViolationEvents, sendCSPViolationEvents
, true) DEFINE_ARGUMENT(uint32_t, RequestBlockingReason, requestBlockingReason
, BLOCKING_REASON_NONE) DEFINE_ARGUMENT(bool, ForcePreflight,
forcePreflight, false) DEFINE_ARGUMENT(bool, IsPreflight, isPreflight
, false) DEFINE_ARGUMENT(bool, DocumentHasUserInteracted, documentHasUserInteracted
, false) DEFINE_ARGUMENT(bool, AllowListFutureDocumentsCreatedFromThisRedirectChain
, allowListFutureDocumentsCreatedFromThisRedirectChain, false
) DEFINE_ARGUMENT(bool, NeedForCheckingAntiTrackingHeuristic,
needForCheckingAntiTrackingHeuristic, false) DEFINE_ARGUMENT
(bool, SkipContentSniffing, skipContentSniffing, false) DEFINE_ARGUMENT
(uint32_t, HttpsOnlyStatus, httpsOnlyStatus, nsILoadInfo::HTTPS_ONLY_UNINITIALIZED
) DEFINE_ARGUMENT(bool, HstsStatus, httpsOnlyStatus, false) DEFINE_ARGUMENT
(bool, HasValidUserGestureActivation, hasValidUserGestureActivation
, false) DEFINE_ARGUMENT(bool, TextDirectiveUserActivation, textDirectiveUserActivation
, false) DEFINE_ARGUMENT(bool, AllowDeprecatedSystemRequests,
allowDeprecatedSystemRequests, false) DEFINE_ARGUMENT(bool, IsInDevToolsContext
, isInDevToolsContext, false) DEFINE_ARGUMENT(bool, ParserCreatedScript
, parserCreatedScript, false) DEFINE_ARGUMENT(Maybe<dom::RequestMode
>, RequestMode, requestMode, Nothing()) DEFINE_ARGUMENT(nsILoadInfo
::StoragePermissionState, StoragePermission, storagePermission
, nsILoadInfo::NoStoragePermission) DEFINE_ARGUMENT(nsILoadInfo
::IPAddressSpace, ParentIpAddressSpace, parentIPAddressSpace,
nsILoadInfo::Unknown) DEFINE_ARGUMENT(nsILoadInfo::IPAddressSpace
, IpAddressSpace, ipAddressSpace, nsILoadInfo::Unknown) DEFINE_ARGUMENT
(bool, IsMetaRefresh, isMetaRefresh, false) DEFINE_ARGUMENT(bool
, ActivatedFromNavigationalPrefetch, activatedFromNavigationalPrefetch
, false) DEFINE_ARGUMENT(bool, IsFromProcessingFrameAttributes
, isFromProcessingFrameAttributes, false) DEFINE_ARGUMENT(bool
, IsMediaRequest, isMediaRequest, false) DEFINE_ARGUMENT(nsILoadInfo
::CrossOriginEmbedderPolicy, LoadingEmbedderPolicy, loadingEmbedderPolicy
, nsILoadInfo::EMBEDDER_POLICY_NULL) DEFINE_ARGUMENT(bool, IsOriginTrialCoepCredentiallessEnabledForTopLevel
, originTrialCoepCredentiallessEnabledForTopLevel, false) DEFINE_ARGUMENT
(nsILoadInfo::HTTPSUpgradeTelemetryType, HttpsUpgradeTelemetry
, httpsUpgradeTelemetry, nsILoadInfo::NOT_INITIALIZED) DEFINE_ARGUMENT
(bool, IsNewWindowTarget, isNewWindowTarget, false)
885#undef DEFINE_ARGUMENT
886
887 loadInfoArgs.initialSecurityCheckDone(),
888 loadInfoArgs.isInThirdPartyContext(), isThirdPartyContextToTopWindow,
889 loadInfoArgs.originAttributes(),
890 std::move(redirectChainIncludingInternalRedirects),
891 std::move(redirectChain), std::move(ancestorPrincipals),
892 ancestorBrowsingContextIDs, loadInfoArgs.corsUnsafeHeaders(),
893 loadInfoArgs.loadTriggeredFromExternal(), loadInfoArgs.cspNonce(),
894 loadInfoArgs.integrityMetadata(),
895 // This function is only called for moving LoadInfo across processes.
896 // Same-document navigation won't cross process boundaries.
897 /* aIsSameDocumentNavigation */ false, overriddenFingerprintingSettings,
898 loadingContext, loadInfoArgs.unstrippedURI(), interceptionInfo,
899 loadInfoArgs.schemelessInput(), loadInfoArgs.userNavigationInvolvement());
900
901 loadInfo.forget(outLoadInfo);
902 return NS_OK;
903}
904
905void LoadInfoToParentLoadInfoForwarder(
906 nsILoadInfo* aLoadInfo, ParentLoadInfoForwarderArgs* aForwarderArgsOut) {
907 Maybe<IPCServiceWorkerDescriptor> ipcController;
908 Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
909 if (controller.isSome()) {
910 ipcController.emplace(controller.ref().ToIPC());
911 }
912
913 uint32_t tainting = nsILoadInfo::TAINTING_BASIC;
914 (void)aLoadInfo->GetTainting(&tainting);
915
916 Maybe<CookieJarSettingsArgs> cookieJarSettingsArgs;
917
918 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
919 nsresult rv =
920 aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
921 CookieJarSettings* cs =
922 static_cast<CookieJarSettings*>(cookieJarSettings.get());
923 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cookieJarSettings && cs->HasBeenChanged()) {
924 CookieJarSettingsArgs args;
925 cs->Serialize(args);
926 cookieJarSettingsArgs = Some(args);
927 }
928
929 nsCOMPtr<nsIURI> unstrippedURI;
930 (void)aLoadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI));
931
932 Maybe<bool> isThirdPartyContextToTopWindow;
933 if (static_cast<LoadInfo*>(aLoadInfo)
934 ->HasIsThirdPartyContextToTopWindowSet()) {
935 isThirdPartyContextToTopWindow.emplace(
936 aLoadInfo->GetIsThirdPartyContextToTopWindow());
937 }
938
939 Maybe<RFPTargetSet> overriddenFingerprintingSettingsArg;
940 Maybe<RFPTargetSet> overriddenFingerprintingSettings =
941 aLoadInfo->GetOverriddenFingerprintingSettings();
942
943 if (overriddenFingerprintingSettings) {
944 overriddenFingerprintingSettingsArg =
945 Some(overriddenFingerprintingSettings.ref());
946 }
947
948 Maybe<RequestMode> requestMode;
949 aLoadInfo->GetRequestMode(&requestMode);
950
951 *aForwarderArgsOut = ParentLoadInfoForwarderArgs(
952 aLoadInfo->GetAllowInsecureRedirectToDataURI(), ipcController, tainting,
953 aLoadInfo->GetSkipContentSniffing(), aLoadInfo->GetHttpsOnlyStatus(),
954 aLoadInfo->GetSchemelessInput(), aLoadInfo->GetHttpsUpgradeTelemetry(),
955 aLoadInfo->GetHstsStatus(), aLoadInfo->GetHasValidUserGestureActivation(),
956 aLoadInfo->GetTextDirectiveUserActivation(),
957 aLoadInfo->GetAllowDeprecatedSystemRequests(),
958 aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(),
959 requestMode, aLoadInfo->GetTriggeringSandboxFlags(),
960 aLoadInfo->GetTriggeringWindowId(),
961 aLoadInfo->GetServiceWorkerTaintingSynthesized(),
962 aLoadInfo->GetDocumentHasUserInteracted(),
963 aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(),
964 cookieJarSettingsArgs, aLoadInfo->GetContainerPermissionsPolicyInfo(),
965 aLoadInfo->GetRequestBlockingReason(), aLoadInfo->GetStoragePermission(),
966 overriddenFingerprintingSettingsArg, aLoadInfo->GetIsMetaRefresh(),
967 isThirdPartyContextToTopWindow, aLoadInfo->GetIsInThirdPartyContext(),
968 aLoadInfo->GetIsOn3PCBExceptionList(), unstrippedURI,
969 aLoadInfo->GetUserNavigationInvolvement());
970}
971
972nsresult MergeParentLoadInfoForwarder(
973 ParentLoadInfoForwarderArgs const& aForwarderArgs, nsILoadInfo* aLoadInfo) {
974 nsresult rv;
975
976 rv = aLoadInfo->SetAllowInsecureRedirectToDataURI(
977 aForwarderArgs.allowInsecureRedirectToDataURI());
978 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 978); return rv; } } while (false)
;
979
980 aLoadInfo->ClearController();
981 auto& controller = aForwarderArgs.controller();
982 if (controller.isSome()) {
983 aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
984 }
985
986 if (aForwarderArgs.serviceWorkerTaintingSynthesized()) {
987 aLoadInfo->SynthesizeServiceWorkerTainting(
988 static_cast<LoadTainting>(aForwarderArgs.tainting()));
989 } else {
990 aLoadInfo->MaybeIncreaseTainting(aForwarderArgs.tainting());
991 }
992 rv = aLoadInfo->SetTextDirectiveUserActivation(
993 aForwarderArgs.textDirectiveUserActivation());
994 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 994); return rv; } } while (false)
;
995
996 rv = aLoadInfo->SetSkipContentSniffing(aForwarderArgs.skipContentSniffing());
997 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 997); return rv; } } while (false)
;
998
999 rv = aLoadInfo->SetHttpsOnlyStatus(aForwarderArgs.httpsOnlyStatus());
1000 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1000); return rv; } } while (false)
;
1001
1002 rv = aLoadInfo->SetSchemelessInput(aForwarderArgs.schemelessInput());
1003 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1003); return rv; } } while (false)
;
1004
1005 rv = aLoadInfo->SetHttpsUpgradeTelemetry(
1006 aForwarderArgs.httpsUpgradeTelemetry());
1007 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1007); return rv; } } while (false)
;
1008
1009 rv = aLoadInfo->SetHstsStatus(aForwarderArgs.hstsStatus());
1010 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1010); return rv; } } while (false)
;
1011
1012 rv = aLoadInfo->SetTriggeringSandboxFlags(
1013 aForwarderArgs.triggeringSandboxFlags());
1014 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1014); return rv; } } while (false)
;
1015
1016 rv = aLoadInfo->SetTriggeringWindowId(aForwarderArgs.triggeringWindowId());
1017 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1017); return rv; } } while (false)
;
1018
1019 rv = aLoadInfo->SetHasValidUserGestureActivation(
1020 aForwarderArgs.hasValidUserGestureActivation());
1021 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1021); return rv; } } while (false)
;
1022
1023 rv = aLoadInfo->SetAllowDeprecatedSystemRequests(
1024 aForwarderArgs.allowDeprecatedSystemRequests());
1025 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1025); return rv; } } while (false)
;
1026
1027 rv = aLoadInfo->SetIsInDevToolsContext(aForwarderArgs.isInDevToolsContext());
1028 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1028); return rv; } } while (false)
;
1029
1030 rv = aLoadInfo->SetParserCreatedScript(aForwarderArgs.parserCreatedScript());
1031 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1031); return rv; } } while (false)
;
1032
1033 rv = aLoadInfo->SetRequestMode(aForwarderArgs.requestMode());
1034 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1034); return rv; } } while (false)
;
1035
1036 MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetDocumentHasUserInteracted(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted
()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash
("" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1037); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
")"); do { MOZ_CrashSequence(__null, 1037); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1037 aForwarderArgs.documentHasUserInteracted()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted
()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash
("" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1037); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
")"); do { MOZ_CrashSequence(__null, 1037); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
;
1038 MOZ_ALWAYS_SUCCEEDS(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain
( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain
()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash
("" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1041); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { MOZ_CrashSequence(__null, 1041); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1039 aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain
( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain
()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash
("" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1041); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { MOZ_CrashSequence(__null, 1041); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1040 aForwarderArgsdo { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain
( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain
()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash
("" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1041); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { MOZ_CrashSequence(__null, 1041); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1041 .allowListFutureDocumentsCreatedFromThisRedirectChain()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain
( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain
()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash
("" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1041); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { MOZ_CrashSequence(__null, 1041); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
;
1042 MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetRequestBlockingReason(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason
()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash
("" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1043); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
")"); do { MOZ_CrashSequence(__null, 1043); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1043 aForwarderArgs.requestBlockingReason()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason
()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash
("" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1043); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
")"); do { MOZ_CrashSequence(__null, 1043); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
;
1044
1045 const Maybe<CookieJarSettingsArgs>& cookieJarSettingsArgs =
1046 aForwarderArgs.cookieJarSettings();
1047 if (cookieJarSettingsArgs.isSome()) {
1048 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
1049 nsresult rv =
1050 aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
1051 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cookieJarSettings) {
1052 nsCOMPtr<nsICookieJarSettings> mergedCookieJarSettings;
1053 mergedCookieJarSettings =
1054 static_cast<CookieJarSettings*>(cookieJarSettings.get())
1055 ->Merge(cookieJarSettingsArgs.ref());
1056 aLoadInfo->SetCookieJarSettings(mergedCookieJarSettings);
1057 }
1058 }
1059
1060 rv = aLoadInfo->SetStoragePermission(aForwarderArgs.storagePermission());
1061 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1061); return rv; } } while (false)
;
1062
1063 rv = aLoadInfo->SetIsMetaRefresh(aForwarderArgs.isMetaRefresh());
1064 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1064); return rv; } } while (false)
;
1065
1066 const Maybe<RFPTargetSet>& overriddenFingerprintingSettings =
1067 aForwarderArgs.overriddenFingerprintingSettings();
1068 if (overriddenFingerprintingSettings.isSome()) {
1069 aLoadInfo->SetOverriddenFingerprintingSettings(
1070 overriddenFingerprintingSettings.ref());
1071 }
1072
1073 static_cast<LoadInfo*>(aLoadInfo)->ClearIsThirdPartyContextToTopWindow();
1074 if (aForwarderArgs.isThirdPartyContextToTopWindow().isSome()) {
1075 rv = aLoadInfo->SetIsThirdPartyContextToTopWindow(
1076 aForwarderArgs.isThirdPartyContextToTopWindow().ref());
1077 }
1078 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1078); return rv; } } while (false)
;
1079
1080 rv = aLoadInfo->SetIsInThirdPartyContext(
1081 aForwarderArgs.isInThirdPartyContext());
1082 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1082); return rv; } } while (false)
;
1083
1084 rv = aLoadInfo->SetIsOn3PCBExceptionList(
1085 aForwarderArgs.isOn3PCBExceptionList());
1086 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1086); return rv; } } while (false)
;
1087
1088 rv = aLoadInfo->SetUnstrippedURI(aForwarderArgs.unstrippedURI());
1089 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../ipc/glue/BackgroundUtils.cpp"
, 1089); return rv; } } while (false)
;
1090
1091 if (aForwarderArgs.containerPermissionsPolicyInfo()) {
1092 aLoadInfo->SetContainerPermissionsPolicyInfo(
1093 *aForwarderArgs.containerPermissionsPolicyInfo());
1094 }
1095
1096 aLoadInfo->SetUserNavigationInvolvement(
1097 uint8_t(aForwarderArgs.userNavigationInvolvement()));
1098
1099 return NS_OK;
1100}
1101
1102void LoadInfoToChildLoadInfoForwarder(
1103 nsILoadInfo* aLoadInfo, ChildLoadInfoForwarderArgs* aForwarderArgsOut) {
1104 Maybe<IPCClientInfo> ipcReserved;
1105 Maybe<ClientInfo> reserved(aLoadInfo->GetReservedClientInfo());
1106 if (reserved.isSome()) {
1107 ipcReserved.emplace(reserved.ref().ToIPC());
1108 }
1109
1110 Maybe<IPCClientInfo> ipcInitial;
1111 Maybe<ClientInfo> initial(aLoadInfo->GetInitialClientInfo());
1112 if (initial.isSome()) {
1113 ipcInitial.emplace(initial.ref().ToIPC());
1114 }
1115
1116 Maybe<IPCServiceWorkerDescriptor> ipcController;
1117 Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
1118 if (controller.isSome()) {
1119 ipcController.emplace(controller.ref().ToIPC());
1120 }
1121
1122 *aForwarderArgsOut =
1123 ChildLoadInfoForwarderArgs(ipcReserved, ipcInitial, ipcController,
1124 aLoadInfo->GetRequestBlockingReason());
1125}
1126
1127nsresult MergeChildLoadInfoForwarder(
1128 const ChildLoadInfoForwarderArgs& aForwarderArgs, nsILoadInfo* aLoadInfo) {
1129 Maybe<ClientInfo> reservedClientInfo;
1130 auto& ipcReserved = aForwarderArgs.reservedClientInfo();
1131 if (ipcReserved.isSome()) {
1132 reservedClientInfo.emplace(ClientInfo(ipcReserved.ref()));
1133 }
1134
1135 Maybe<ClientInfo> initialClientInfo;
1136 auto& ipcInitial = aForwarderArgs.initialClientInfo();
1137 if (ipcInitial.isSome()) {
1138 initialClientInfo.emplace(ClientInfo(ipcInitial.ref()));
1139 }
1140
1141 // There should only be at most one reserved or initial ClientInfo.
1142 if (NS_WARN_IF(reservedClientInfo.isSome() && initialClientInfo.isSome())NS_warn_if_impl(reservedClientInfo.isSome() && initialClientInfo
.isSome(), "reservedClientInfo.isSome() && initialClientInfo.isSome()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1142)
) {
1143 return NS_ERROR_FAILURE;
1144 }
1145
1146 // If we received no reserved or initial ClientInfo, then we must not
1147 // already have one set. There are no use cases where this should
1148 // happen and we don't have a way to clear the current value.
1149 if (NS_WARN_IF(reservedClientInfo.isNothing() &&NS_warn_if_impl(reservedClientInfo.isNothing() && initialClientInfo
.isNothing() && (aLoadInfo->GetReservedClientInfo(
).isSome() || aLoadInfo->GetInitialClientInfo().isSome()),
"reservedClientInfo.isNothing() && initialClientInfo.isNothing() && (aLoadInfo->GetReservedClientInfo().isSome() || aLoadInfo->GetInitialClientInfo().isSome())"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1152)
1150 initialClientInfo.isNothing() &&NS_warn_if_impl(reservedClientInfo.isNothing() && initialClientInfo
.isNothing() && (aLoadInfo->GetReservedClientInfo(
).isSome() || aLoadInfo->GetInitialClientInfo().isSome()),
"reservedClientInfo.isNothing() && initialClientInfo.isNothing() && (aLoadInfo->GetReservedClientInfo().isSome() || aLoadInfo->GetInitialClientInfo().isSome())"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1152)
1151 (aLoadInfo->GetReservedClientInfo().isSome() ||NS_warn_if_impl(reservedClientInfo.isNothing() && initialClientInfo
.isNothing() && (aLoadInfo->GetReservedClientInfo(
).isSome() || aLoadInfo->GetInitialClientInfo().isSome()),
"reservedClientInfo.isNothing() && initialClientInfo.isNothing() && (aLoadInfo->GetReservedClientInfo().isSome() || aLoadInfo->GetInitialClientInfo().isSome())"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1152)
1152 aLoadInfo->GetInitialClientInfo().isSome()))NS_warn_if_impl(reservedClientInfo.isNothing() && initialClientInfo
.isNothing() && (aLoadInfo->GetReservedClientInfo(
).isSome() || aLoadInfo->GetInitialClientInfo().isSome()),
"reservedClientInfo.isNothing() && initialClientInfo.isNothing() && (aLoadInfo->GetReservedClientInfo().isSome() || aLoadInfo->GetInitialClientInfo().isSome())"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1152)
) {
1153 return NS_ERROR_FAILURE;
1154 }
1155
1156 if (reservedClientInfo.isSome()) {
1157 // We need to override here instead of simply set the value. This
1158 // allows us to change the reserved client. This is necessary when
1159 // the ClientChannelHelper created a new reserved client in the
1160 // child-side of the redirect.
1161 aLoadInfo->OverrideReservedClientInfoInParent(reservedClientInfo.ref());
1162 } else if (initialClientInfo.isSome()) {
1163 aLoadInfo->SetInitialClientInfo(initialClientInfo.ref());
1164 }
1165
1166 aLoadInfo->ClearController();
1167 auto& controller = aForwarderArgs.controller();
1168 if (controller.isSome()) {
1169 aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
1170 }
1171
1172 uint32_t blockingReason = aForwarderArgs.requestBlockingReason();
1173 if (blockingReason) {
1174 // We only want to override when non-null, so that any earlier set non-null
1175 // value is not reverted to 0.
1176 aLoadInfo->SetRequestBlockingReason(blockingReason);
1177 }
1178
1179 return NS_OK;
1180}
1181
1182} // namespace ipc
1183} // namespace mozilla