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/toolkit/components/telemetry -I /root/firefox-clang/xpcom/base -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-09-01-224014-2642839-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->GetTriggeringStorageAccess(),
566 aLoadInfo->GetTriggeringFirstPartyClassificationFlags(),
567 aLoadInfo->GetTriggeringThirdPartyClassificationFlags(),
568 aLoadInfo->InternalContentPolicyType(),
569 static_cast<uint32_t>(aLoadInfo->GetTainting()),
570 aLoadInfo->GetBlockAllMixedContent(),
571 aLoadInfo->GetUpgradeInsecureRequests(),
572 aLoadInfo->GetBrowserUpgradeInsecureRequests(),
573 aLoadInfo->GetBrowserDidUpgradeInsecureRequests(),
574 aLoadInfo->GetBrowserWouldUpgradeInsecureRequests(),
575 aLoadInfo->GetForceAllowDataURI(),
576 aLoadInfo->GetAllowInsecureRedirectToDataURI(),
577 aLoadInfo->GetForceMediaDocument(),
578 aLoadInfo->GetSkipContentPolicyCheckForWebRequest(),
579 aLoadInfo->GetOriginalFrameSrcLoad(),
580 aLoadInfo->GetForceInheritPrincipalDropped(),
581 aLoadInfo->GetInnerWindowID(), aLoadInfo->GetBrowsingContextID(),
582 aLoadInfo->GetAssociatedBrowsingContextID(),
583 aLoadInfo->GetFrameBrowsingContextID(),
584 aLoadInfo->GetInitialSecurityCheckDone(),
585 aLoadInfo->GetIsInThirdPartyContext(), isThirdPartyContextToTopWindow,
586 aLoadInfo->GetIsOn3PCBExceptionList(), aLoadInfo->GetIsFormSubmission(),
587 aLoadInfo->GetIsGETRequest(), aLoadInfo->GetSendCSPViolationEvents(),
588 aLoadInfo->GetOriginAttributes(), redirectChainIncludingInternalRedirects,
589 redirectChain, aLoadInfo->GetSchemelessInput(),
590 aLoadInfo->GetHttpsUpgradeTelemetry(), ipcClientInfo,
591 ipcReservedClientInfo, ipcInitialClientInfo, ipcController,
592 aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->GetForcePreflight(),
593 aLoadInfo->GetIsPreflight(), aLoadInfo->GetLoadTriggeredFromExternal(),
594 aLoadInfo->GetServiceWorkerTaintingSynthesized(),
595 aLoadInfo->GetDocumentHasUserInteracted(),
596 aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(),
597 aLoadInfo->GetNeedForCheckingAntiTrackingHeuristic(), cspNonce,
598 integrityMetadata, aLoadInfo->GetSkipContentSniffing(),
599 aLoadInfo->GetHttpsOnlyStatus(), aLoadInfo->GetHstsStatus(),
600 aLoadInfo->GetHasValidUserGestureActivation(),
601 aLoadInfo->GetTextDirectiveUserActivation(),
602 aLoadInfo->GetAllowDeprecatedSystemRequests(),
603 aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(),
604 requestMode, aLoadInfo->GetIsFromProcessingFrameAttributes(),
605 aLoadInfo->GetIsMediaRequest(), aLoadInfo->GetIsFromObjectOrEmbed(),
606 cookieJarSettingsArgs, aLoadInfo->GetRequestBlockingReason(),
607 maybePolicyContainerToInherit, aLoadInfo->GetStoragePermission(),
608 aLoadInfo->GetParentIpAddressSpace(), aLoadInfo->GetIpAddressSpace(),
609 overriddenFingerprintingSettingsArg, aLoadInfo->GetIsMetaRefresh(),
610 aLoadInfo->GetActivatedFromNavigationalPrefetch(),
611 aLoadInfo->GetLoadingEmbedderPolicy(),
612 aLoadInfo->GetIsOriginTrialCoepCredentiallessEnabledForTopLevel(),
613 unstrippedURI, interceptionInfoArg, aLoadInfo->GetIsNewWindowTarget(),
614 aLoadInfo->GetUserNavigationInvolvement(),
615 aLoadInfo->GetContainerFeaturePolicyInfo(), {});
616
617 return NS_OK;
618}
619
620nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
621 const RemoteType& aOriginRemoteType,
622 nsILoadInfo** outLoadInfo) {
623 return LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, nullptr,
624 outLoadInfo);
625}
626nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
627 const RemoteType& aOriginRemoteType,
628 nsINode* aCspToInheritLoadingContext,
629 nsILoadInfo** outLoadInfo) {
630 RefPtr<LoadInfo> loadInfo;
631 nsresult rv = LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType,
632 aCspToInheritLoadingContext,
633 getter_AddRefs(loadInfo));
634 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"
, 634); return rv; } } while (false)
;
635
636 loadInfo.forget(outLoadInfo);
637 return NS_OK;
638}
639
640nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
641 const RemoteType& aOriginRemoteType,
642 LoadInfo** outLoadInfo) {
643 return LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, nullptr,
644 outLoadInfo);
645}
646nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs,
647 const RemoteType& aOriginRemoteType,
648 nsINode* aCspToInheritLoadingContext,
649 LoadInfo** outLoadInfo) {
650 nsCOMPtr<nsIPrincipal> loadingPrincipal;
651 if (loadInfoArgs.requestingPrincipalInfo().isSome()) {
652 auto loadingPrincipalOrErr =
653 PrincipalInfoToPrincipal(loadInfoArgs.requestingPrincipalInfo().ref());
654 if (NS_WARN_IF(loadingPrincipalOrErr.isErr())NS_warn_if_impl(loadingPrincipalOrErr.isErr(), "loadingPrincipalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 654)
) {
655 return loadingPrincipalOrErr.unwrapErr();
656 }
657 loadingPrincipal = loadingPrincipalOrErr.unwrap();
658 }
659
660 auto triggeringPrincipalOrErr =
661 PrincipalInfoToPrincipal(loadInfoArgs.triggeringPrincipalInfo());
662 if (NS_WARN_IF(triggeringPrincipalOrErr.isErr())NS_warn_if_impl(triggeringPrincipalOrErr.isErr(), "triggeringPrincipalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 662)
) {
663 return triggeringPrincipalOrErr.unwrapErr();
664 }
665 nsCOMPtr<nsIPrincipal> triggeringPrincipal =
666 triggeringPrincipalOrErr.unwrap();
667
668 nsCOMPtr<nsIPrincipal> principalToInherit;
669 nsCOMPtr<nsIPrincipal> flattenedPrincipalToInherit;
670 if (loadInfoArgs.principalToInheritInfo().isSome()) {
671 auto principalToInheritOrErr =
672 PrincipalInfoToPrincipal(loadInfoArgs.principalToInheritInfo().ref());
673 if (NS_WARN_IF(principalToInheritOrErr.isErr())NS_warn_if_impl(principalToInheritOrErr.isErr(), "principalToInheritOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 673)
) {
674 return principalToInheritOrErr.unwrapErr();
675 }
676 flattenedPrincipalToInherit = principalToInheritOrErr.unwrap();
677 }
678
679 if (XRE_IsContentProcess()) {
680 auto targetBrowsingContextId = loadInfoArgs.frameBrowsingContextID()
681 ? loadInfoArgs.frameBrowsingContextID()
682 : loadInfoArgs.browsingContextID();
683 if (RefPtr<BrowsingContext> bc =
684 BrowsingContext::Get(targetBrowsingContextId)) {
685 auto [originalTriggeringPrincipal, originalPrincipalToInherit] =
686 bc->GetTriggeringAndInheritPrincipalsForCurrentLoad();
687
688 if (originalTriggeringPrincipal &&
689 originalTriggeringPrincipal->Equals(triggeringPrincipal)) {
690 triggeringPrincipal = originalTriggeringPrincipal;
691 }
692 if (originalPrincipalToInherit &&
693 (loadInfoArgs.securityFlags() &
694 nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL) &&
695 originalPrincipalToInherit->Equals(flattenedPrincipalToInherit)) {
696 principalToInherit = originalPrincipalToInherit;
697 }
698 }
699 }
700 if (!principalToInherit && loadInfoArgs.principalToInheritInfo().isSome()) {
701 principalToInherit = flattenedPrincipalToInherit;
702 }
703
704 nsCOMPtr<nsIPrincipal> topLevelPrincipal;
705 if (loadInfoArgs.topLevelPrincipalInfo().isSome()) {
706 auto topLevelPrincipalOrErr =
707 PrincipalInfoToPrincipal(loadInfoArgs.topLevelPrincipalInfo().ref());
708 if (NS_WARN_IF(topLevelPrincipalOrErr.isErr())NS_warn_if_impl(topLevelPrincipalOrErr.isErr(), "topLevelPrincipalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 708)
) {
709 return topLevelPrincipalOrErr.unwrapErr();
710 }
711 topLevelPrincipal = topLevelPrincipalOrErr.unwrap();
712 }
713
714 nsCOMPtr<nsIURI> resultPrincipalURI;
715 if (loadInfoArgs.resultPrincipalURI().isSome()) {
716 resultPrincipalURI = DeserializeURI(loadInfoArgs.resultPrincipalURI());
717 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", 717); return
NS_ERROR_UNEXPECTED; } } while (false)
;
718 }
719
720 // If we received this message from a content process, reset
721 // triggeringRemoteType to the process which sent us the message. If the
722 // parent sent us the message, we trust it to provide the correct triggering
723 // remote type.
724 //
725 // This means that the triggering remote type will be reset if a LoadInfo is
726 // bounced through a content process, as the LoadInfo can no longer be
727 // validated to be coming from the originally specified remote type.
728 RemoteType triggeringRemoteType = loadInfoArgs.triggeringRemoteType();
729 if (!aOriginRemoteType.IsNotRemote() &&
730 aOriginRemoteType != triggeringRemoteType) {
731 triggeringRemoteType = aOriginRemoteType;
732 }
733
734 RedirectHistoryArray redirectChainIncludingInternalRedirects;
735 for (const RedirectHistoryEntryInfo& entryInfo :
736 loadInfoArgs.redirectChainIncludingInternalRedirects()) {
737 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
738 RHEntryInfoToRHEntry(entryInfo);
739 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"
, 739); return NS_ERROR_UNEXPECTED; } } while (false)
;
740 redirectChainIncludingInternalRedirects.AppendElement(
741 redirectHistoryEntry.forget());
742 }
743
744 RedirectHistoryArray redirectChain;
745 for (const RedirectHistoryEntryInfo& entryInfo :
746 loadInfoArgs.redirectChain()) {
747 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
748 RHEntryInfoToRHEntry(entryInfo);
749 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"
, 749); return NS_ERROR_UNEXPECTED; } } while (false)
;
750 redirectChain.AppendElement(redirectHistoryEntry.forget());
751 }
752 nsTArray<nsCOMPtr<nsIPrincipal>> ancestorPrincipals;
753 nsTArray<uint64_t> ancestorBrowsingContextIDs;
754 if (XRE_IsParentProcess() &&
755 (nsContentUtils::InternalContentPolicyTypeToExternal(
756 loadInfoArgs.contentPolicyType()) !=
757 ExtContentPolicy::TYPE_DOCUMENT)) {
758 // Only fill out ancestor principals and browsing context IDs when we
759 // are deserializing LoadInfoArgs to be LoadInfo for a subresource
760 RefPtr<BrowsingContext> parentBC =
761 BrowsingContext::Get(loadInfoArgs.browsingContextID());
762 if (parentBC) {
763 LoadInfo::ComputeAncestors(parentBC->Canonical(), ancestorPrincipals,
764 ancestorBrowsingContextIDs);
765 }
766 } else {
767 // Fill out (possibly redacted) ancestor principals for
768 // Location.ancestorOrigins
769 for (const auto& principalInfo : loadInfoArgs.ancestorOrigins()) {
770 if (principalInfo.isNothing()) {
771 ancestorPrincipals.AppendElement(nullptr);
772 } else {
773 auto principal = PrincipalInfoToPrincipal(principalInfo.value());
774 // If this operation fail, we censor the origin.
775 ancestorPrincipals.AppendElement(principal.unwrapOr(nullptr));
776 }
777 }
778 }
779
780 Maybe<ClientInfo> clientInfo;
781 if (loadInfoArgs.clientInfo().isSome()) {
782 clientInfo.emplace(ClientInfo(loadInfoArgs.clientInfo().ref()));
783 }
784
785 Maybe<ClientInfo> reservedClientInfo;
786 if (loadInfoArgs.reservedClientInfo().isSome()) {
787 reservedClientInfo.emplace(
788 ClientInfo(loadInfoArgs.reservedClientInfo().ref()));
789 }
790
791 Maybe<ClientInfo> initialClientInfo;
792 if (loadInfoArgs.initialClientInfo().isSome()) {
793 initialClientInfo.emplace(
794 ClientInfo(loadInfoArgs.initialClientInfo().ref()));
795 }
796
797 // We can have an initial client info or a reserved client info, but not both.
798 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", 799); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
")"); do { MOZ_CrashSequence(__null, 799); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
799 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", 799); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
")"); do { MOZ_CrashSequence(__null, 799); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
800 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"
, 802); return NS_ERROR_UNEXPECTED; } } while (false)
801 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"
, 802); return NS_ERROR_UNEXPECTED; } } while (false)
802 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"
, 802); return NS_ERROR_UNEXPECTED; } } while (false)
;
803
804 Maybe<ServiceWorkerDescriptor> controller;
805 if (loadInfoArgs.controller().isSome()) {
806 controller.emplace(
807 ServiceWorkerDescriptor(loadInfoArgs.controller().ref()));
808 }
809
810 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
811 CookieJarSettings::Deserialize(loadInfoArgs.cookieJarSettings(),
812 getter_AddRefs(cookieJarSettings));
813
814 Maybe<RFPTargetSet> overriddenFingerprintingSettings;
815 if (loadInfoArgs.overriddenFingerprintingSettings().isSome()) {
816 overriddenFingerprintingSettings.emplace(
817 loadInfoArgs.overriddenFingerprintingSettings().ref());
818 }
819
820 // Restore the loadingContext for frames using the BrowsingContext's
821 // embedder element. Note that this only works if the embedder is
822 // same-process, so won't be fission compatible.
823 nsCOMPtr<nsINode> loadingContext;
824 RefPtr<BrowsingContext> frameBrowsingContext =
825 BrowsingContext::Get(loadInfoArgs.frameBrowsingContextID());
826 if (frameBrowsingContext) {
827 loadingContext = frameBrowsingContext->GetEmbedderElement();
828 }
829
830 Maybe<bool> isThirdPartyContextToTopWindow;
831 if (loadInfoArgs.isThirdPartyContextToTopWindow().isSome()) {
832 isThirdPartyContextToTopWindow.emplace(
833 loadInfoArgs.isThirdPartyContextToTopWindow().ref());
834 }
835
836 nsCOMPtr<nsIInterceptionInfo> interceptionInfo;
837 if (loadInfoArgs.interceptionInfo().isSome()) {
838 const InterceptionInfoArg& interceptionInfoArg =
839 loadInfoArgs.interceptionInfo().ref();
840 nsCOMPtr<nsIPrincipal> triggeringPrincipal;
841 if (interceptionInfoArg.triggeringPrincipalInfo().isSome()) {
842 auto triggeringPrincipalOrErr = PrincipalInfoToPrincipal(
843 interceptionInfoArg.triggeringPrincipalInfo().ref());
844 if (NS_WARN_IF(triggeringPrincipalOrErr.isErr())NS_warn_if_impl(triggeringPrincipalOrErr.isErr(), "triggeringPrincipalOrErr.isErr()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 844)
) {
845 return triggeringPrincipalOrErr.unwrapErr();
846 }
847 triggeringPrincipal = triggeringPrincipalOrErr.unwrap();
848 }
849
850 RedirectHistoryArray redirectChain;
851 for (const RedirectHistoryEntryInfo& entryInfo :
852 interceptionInfoArg.redirectChain()) {
853 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
854 RHEntryInfoToRHEntry(entryInfo);
855 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"
, 855); return NS_ERROR_UNEXPECTED; } } while (false)
;
856 redirectChain.AppendElement(redirectHistoryEntry.forget());
857 }
858
859 interceptionInfo = new InterceptionInfo(
860 triggeringPrincipal, interceptionInfoArg.contentPolicyType(),
861 redirectChain, interceptionInfoArg.fromThirdParty());
862 }
863
864 RefPtr<PolicyContainer> policyContainerToInherit;
865 const auto& policyContainerToInheritArgs =
866 loadInfoArgs.policyContainerToInherit();
867 if (policyContainerToInheritArgs.isSome()) {
868 nsCOMPtr<Document> doc = do_QueryInterface(aCspToInheritLoadingContext);
869 PolicyContainer::FromArgs(policyContainerToInheritArgs.ref(), doc,
870 getter_AddRefs(policyContainerToInherit));
871 }
872
873 RefPtr<mozilla::net::LoadInfo> loadInfo = new mozilla::net::LoadInfo(
874 loadingPrincipal, triggeringPrincipal, principalToInherit,
875 topLevelPrincipal, resultPrincipalURI, cookieJarSettings,
876 policyContainerToInherit, loadInfoArgs.containerFeaturePolicyInfo(),
877 triggeringRemoteType, loadInfoArgs.sandboxedNullPrincipalID(), clientInfo,
878 reservedClientInfo, initialClientInfo, controller,
879 loadInfoArgs.securityFlags(), loadInfoArgs.sandboxFlags(),
880 loadInfoArgs.contentPolicyType(),
881 loadInfoArgs.serviceWorkerTaintingSynthesized(),
882 static_cast<LoadTainting>(loadInfoArgs.tainting()),
883
884#define DEFINE_ARGUMENT(_t, _n, name, _d) loadInfoArgs.name(),
885 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(bool, TriggeringStorageAccess, triggeringStorageAccess
, false) 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(bool
, IsFromObjectOrEmbed, isFromObjectOrEmbed, 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)
886#undef DEFINE_ARGUMENT
887
888 loadInfoArgs.initialSecurityCheckDone(),
889 loadInfoArgs.isInThirdPartyContext(), isThirdPartyContextToTopWindow,
890 loadInfoArgs.originAttributes(),
891 std::move(redirectChainIncludingInternalRedirects),
892 std::move(redirectChain), std::move(ancestorPrincipals),
893 ancestorBrowsingContextIDs, loadInfoArgs.corsUnsafeHeaders(),
894 loadInfoArgs.loadTriggeredFromExternal(), loadInfoArgs.cspNonce(),
895 loadInfoArgs.integrityMetadata(),
896 // This function is only called for moving LoadInfo across processes.
897 // Same-document navigation won't cross process boundaries.
898 /* aIsSameDocumentNavigation */ false, overriddenFingerprintingSettings,
899 loadingContext, loadInfoArgs.unstrippedURI(), interceptionInfo,
900 loadInfoArgs.schemelessInput(), loadInfoArgs.userNavigationInvolvement());
901
902 loadInfo.forget(outLoadInfo);
903 return NS_OK;
904}
905
906void LoadInfoToParentLoadInfoForwarder(
907 nsILoadInfo* aLoadInfo, ParentLoadInfoForwarderArgs* aForwarderArgsOut) {
908 Maybe<IPCServiceWorkerDescriptor> ipcController;
909 Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
910 if (controller.isSome()) {
911 ipcController.emplace(controller.ref().ToIPC());
912 }
913
914 uint32_t tainting = nsILoadInfo::TAINTING_BASIC;
915 (void)aLoadInfo->GetTainting(&tainting);
916
917 Maybe<CookieJarSettingsArgs> cookieJarSettingsArgs;
918
919 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
920 nsresult rv =
921 aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
922 CookieJarSettings* cs =
923 static_cast<CookieJarSettings*>(cookieJarSettings.get());
924 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cookieJarSettings && cs->HasBeenChanged()) {
925 CookieJarSettingsArgs args;
926 cs->Serialize(args);
927 cookieJarSettingsArgs = Some(args);
928 }
929
930 nsCOMPtr<nsIURI> unstrippedURI;
931 (void)aLoadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI));
932
933 Maybe<bool> isThirdPartyContextToTopWindow;
934 if (static_cast<LoadInfo*>(aLoadInfo)
935 ->HasIsThirdPartyContextToTopWindowSet()) {
936 isThirdPartyContextToTopWindow.emplace(
937 aLoadInfo->GetIsThirdPartyContextToTopWindow());
938 }
939
940 Maybe<RFPTargetSet> overriddenFingerprintingSettingsArg;
941 Maybe<RFPTargetSet> overriddenFingerprintingSettings =
942 aLoadInfo->GetOverriddenFingerprintingSettings();
943
944 if (overriddenFingerprintingSettings) {
945 overriddenFingerprintingSettingsArg =
946 Some(overriddenFingerprintingSettings.ref());
947 }
948
949 Maybe<RequestMode> requestMode;
950 aLoadInfo->GetRequestMode(&requestMode);
951
952 *aForwarderArgsOut = ParentLoadInfoForwarderArgs(
953 aLoadInfo->GetAllowInsecureRedirectToDataURI(), ipcController, tainting,
954 aLoadInfo->GetSkipContentSniffing(), aLoadInfo->GetHttpsOnlyStatus(),
955 aLoadInfo->GetSchemelessInput(), aLoadInfo->GetHttpsUpgradeTelemetry(),
956 aLoadInfo->GetHstsStatus(), aLoadInfo->GetHasValidUserGestureActivation(),
957 aLoadInfo->GetTextDirectiveUserActivation(),
958 aLoadInfo->GetAllowDeprecatedSystemRequests(),
959 aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(),
960 requestMode, aLoadInfo->GetTriggeringSandboxFlags(),
961 aLoadInfo->GetTriggeringWindowId(),
962 aLoadInfo->GetTriggeringStorageAccess(),
963 aLoadInfo->GetServiceWorkerTaintingSynthesized(),
964 aLoadInfo->GetDocumentHasUserInteracted(),
965 aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(),
966 cookieJarSettingsArgs, aLoadInfo->GetContainerFeaturePolicyInfo(),
967 aLoadInfo->GetRequestBlockingReason(), aLoadInfo->GetStoragePermission(),
968 overriddenFingerprintingSettingsArg, aLoadInfo->GetIsMetaRefresh(),
969 isThirdPartyContextToTopWindow, aLoadInfo->GetIsInThirdPartyContext(),
970 aLoadInfo->GetIsOn3PCBExceptionList(), unstrippedURI,
971 aLoadInfo->GetUserNavigationInvolvement());
972}
973
974nsresult MergeParentLoadInfoForwarder(
975 ParentLoadInfoForwarderArgs const& aForwarderArgs, nsILoadInfo* aLoadInfo) {
976 nsresult rv;
977
978 rv = aLoadInfo->SetAllowInsecureRedirectToDataURI(
979 aForwarderArgs.allowInsecureRedirectToDataURI());
980 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"
, 980); return rv; } } while (false)
;
981
982 aLoadInfo->ClearController();
983 auto& controller = aForwarderArgs.controller();
984 if (controller.isSome()) {
985 aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
986 }
987
988 if (aForwarderArgs.serviceWorkerTaintingSynthesized()) {
989 aLoadInfo->SynthesizeServiceWorkerTainting(
990 static_cast<LoadTainting>(aForwarderArgs.tainting()));
991 } else {
992 aLoadInfo->MaybeIncreaseTainting(aForwarderArgs.tainting());
993 }
994 rv = aLoadInfo->SetTextDirectiveUserActivation(
995 aForwarderArgs.textDirectiveUserActivation());
996 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"
, 996); return rv; } } while (false)
;
997
998 rv = aLoadInfo->SetSkipContentSniffing(aForwarderArgs.skipContentSniffing());
999 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"
, 999); return rv; } } while (false)
;
1000
1001 rv = aLoadInfo->SetHttpsOnlyStatus(aForwarderArgs.httpsOnlyStatus());
1002 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"
, 1002); return rv; } } while (false)
;
1003
1004 rv = aLoadInfo->SetSchemelessInput(aForwarderArgs.schemelessInput());
1005 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"
, 1005); return rv; } } while (false)
;
1006
1007 rv = aLoadInfo->SetHttpsUpgradeTelemetry(
1008 aForwarderArgs.httpsUpgradeTelemetry());
1009 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"
, 1009); return rv; } } while (false)
;
1010
1011 rv = aLoadInfo->SetHstsStatus(aForwarderArgs.hstsStatus());
1012 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"
, 1012); return rv; } } while (false)
;
1013
1014 rv = aLoadInfo->SetTriggeringSandboxFlags(
1015 aForwarderArgs.triggeringSandboxFlags());
1016 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"
, 1016); return rv; } } while (false)
;
1017
1018 rv = aLoadInfo->SetTriggeringWindowId(aForwarderArgs.triggeringWindowId());
1019 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"
, 1019); return rv; } } while (false)
;
1020
1021 rv = aLoadInfo->SetTriggeringStorageAccess(
1022 aForwarderArgs.triggeringStorageAccess());
1023 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"
, 1023); return rv; } } while (false)
;
1024
1025 rv = aLoadInfo->SetHasValidUserGestureActivation(
1026 aForwarderArgs.hasValidUserGestureActivation());
1027 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"
, 1027); return rv; } } while (false)
;
1028
1029 rv = aLoadInfo->SetAllowDeprecatedSystemRequests(
1030 aForwarderArgs.allowDeprecatedSystemRequests());
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->SetIsInDevToolsContext(aForwarderArgs.isInDevToolsContext());
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 rv = aLoadInfo->SetParserCreatedScript(aForwarderArgs.parserCreatedScript());
1037 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"
, 1037); return rv; } } while (false)
;
1038
1039 rv = aLoadInfo->SetRequestMode(aForwarderArgs.requestMode());
1040 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"
, 1040); return rv; } } while (false)
;
1041
1042 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", 1043); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
")"); do { MOZ_CrashSequence(__null, 1043); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1043 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", 1043); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
")"); do { MOZ_CrashSequence(__null, 1043); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
;
1044 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", 1047); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { MOZ_CrashSequence(__null, 1047); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1045 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", 1047); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { MOZ_CrashSequence(__null, 1047); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1046 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", 1047); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { MOZ_CrashSequence(__null, 1047); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1047 .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", 1047); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { MOZ_CrashSequence(__null, 1047); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
;
1048 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", 1049); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
")"); do { MOZ_CrashSequence(__null, 1049); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
1049 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", 1049); AnnotateMozCrashReason
("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
")"); do { MOZ_CrashSequence(__null, 1049); __attribute__((nomerge
)) ::abort(); } while (false); } while (false); } } while (false
)
;
1050
1051 const Maybe<CookieJarSettingsArgs>& cookieJarSettingsArgs =
1052 aForwarderArgs.cookieJarSettings();
1053 if (cookieJarSettingsArgs.isSome()) {
1054 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
1055 nsresult rv =
1056 aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
1057 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cookieJarSettings) {
1058 nsCOMPtr<nsICookieJarSettings> mergedCookieJarSettings;
1059 mergedCookieJarSettings =
1060 static_cast<CookieJarSettings*>(cookieJarSettings.get())
1061 ->Merge(cookieJarSettingsArgs.ref());
1062 aLoadInfo->SetCookieJarSettings(mergedCookieJarSettings);
1063 }
1064 }
1065
1066 rv = aLoadInfo->SetStoragePermission(aForwarderArgs.storagePermission());
1067 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"
, 1067); return rv; } } while (false)
;
1068
1069 rv = aLoadInfo->SetIsMetaRefresh(aForwarderArgs.isMetaRefresh());
1070 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"
, 1070); return rv; } } while (false)
;
1071
1072 const Maybe<RFPTargetSet>& overriddenFingerprintingSettings =
1073 aForwarderArgs.overriddenFingerprintingSettings();
1074 if (overriddenFingerprintingSettings.isSome()) {
1075 aLoadInfo->SetOverriddenFingerprintingSettings(
1076 overriddenFingerprintingSettings.ref());
1077 }
1078
1079 static_cast<LoadInfo*>(aLoadInfo)->ClearIsThirdPartyContextToTopWindow();
1080 if (aForwarderArgs.isThirdPartyContextToTopWindow().isSome()) {
1081 rv = aLoadInfo->SetIsThirdPartyContextToTopWindow(
1082 aForwarderArgs.isThirdPartyContextToTopWindow().ref());
1083 }
1084 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"
, 1084); return rv; } } while (false)
;
1085
1086 rv = aLoadInfo->SetIsInThirdPartyContext(
1087 aForwarderArgs.isInThirdPartyContext());
1088 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"
, 1088); return rv; } } while (false)
;
1089
1090 rv = aLoadInfo->SetIsOn3PCBExceptionList(
1091 aForwarderArgs.isOn3PCBExceptionList());
1092 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"
, 1092); return rv; } } while (false)
;
1093
1094 rv = aLoadInfo->SetUnstrippedURI(aForwarderArgs.unstrippedURI());
1095 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"
, 1095); return rv; } } while (false)
;
1096
1097 if (aForwarderArgs.containerFeaturePolicyInfo()) {
1098 aLoadInfo->SetContainerFeaturePolicyInfo(
1099 *aForwarderArgs.containerFeaturePolicyInfo());
1100 }
1101
1102 aLoadInfo->SetUserNavigationInvolvement(
1103 uint8_t(aForwarderArgs.userNavigationInvolvement()));
1104
1105 return NS_OK;
1106}
1107
1108void LoadInfoToChildLoadInfoForwarder(
1109 nsILoadInfo* aLoadInfo, ChildLoadInfoForwarderArgs* aForwarderArgsOut) {
1110 Maybe<IPCClientInfo> ipcReserved;
1111 Maybe<ClientInfo> reserved(aLoadInfo->GetReservedClientInfo());
1112 if (reserved.isSome()) {
1113 ipcReserved.emplace(reserved.ref().ToIPC());
1114 }
1115
1116 Maybe<IPCClientInfo> ipcInitial;
1117 Maybe<ClientInfo> initial(aLoadInfo->GetInitialClientInfo());
1118 if (initial.isSome()) {
1119 ipcInitial.emplace(initial.ref().ToIPC());
1120 }
1121
1122 Maybe<IPCServiceWorkerDescriptor> ipcController;
1123 Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
1124 if (controller.isSome()) {
1125 ipcController.emplace(controller.ref().ToIPC());
1126 }
1127
1128 *aForwarderArgsOut =
1129 ChildLoadInfoForwarderArgs(ipcReserved, ipcInitial, ipcController,
1130 aLoadInfo->GetRequestBlockingReason());
1131}
1132
1133nsresult MergeChildLoadInfoForwarder(
1134 const ChildLoadInfoForwarderArgs& aForwarderArgs, nsILoadInfo* aLoadInfo) {
1135 Maybe<ClientInfo> reservedClientInfo;
1136 auto& ipcReserved = aForwarderArgs.reservedClientInfo();
1137 if (ipcReserved.isSome()) {
1138 reservedClientInfo.emplace(ClientInfo(ipcReserved.ref()));
1139 }
1140
1141 Maybe<ClientInfo> initialClientInfo;
1142 auto& ipcInitial = aForwarderArgs.initialClientInfo();
1143 if (ipcInitial.isSome()) {
1144 initialClientInfo.emplace(ClientInfo(ipcInitial.ref()));
1145 }
1146
1147 // There should only be at most one reserved or initial ClientInfo.
1148 if (NS_WARN_IF(reservedClientInfo.isSome() && initialClientInfo.isSome())NS_warn_if_impl(reservedClientInfo.isSome() && initialClientInfo
.isSome(), "reservedClientInfo.isSome() && initialClientInfo.isSome()"
, "./../../../ipc/glue/BackgroundUtils.cpp", 1148)
) {
1149 return NS_ERROR_FAILURE;
1150 }
1151
1152 // If we received no reserved or initial ClientInfo, then we must not
1153 // already have one set. There are no use cases where this should
1154 // happen and we don't have a way to clear the current value.
1155 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", 1158)
1156 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", 1158)
1157 (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", 1158)
1158 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", 1158)
) {
1159 return NS_ERROR_FAILURE;
1160 }
1161
1162 if (reservedClientInfo.isSome()) {
1163 // We need to override here instead of simply set the value. This
1164 // allows us to change the reserved client. This is necessary when
1165 // the ClientChannelHelper created a new reserved client in the
1166 // child-side of the redirect.
1167 aLoadInfo->OverrideReservedClientInfoInParent(reservedClientInfo.ref());
1168 } else if (initialClientInfo.isSome()) {
1169 aLoadInfo->SetInitialClientInfo(initialClientInfo.ref());
1170 }
1171
1172 aLoadInfo->ClearController();
1173 auto& controller = aForwarderArgs.controller();
1174 if (controller.isSome()) {
1175 aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
1176 }
1177
1178 uint32_t blockingReason = aForwarderArgs.requestBlockingReason();
1179 if (blockingReason) {
1180 // We only want to override when non-null, so that any earlier set non-null
1181 // value is not reverted to 0.
1182 aLoadInfo->SetRequestBlockingReason(blockingReason);
1183 }
1184
1185 return NS_OK;
1186}
1187
1188} // namespace ipc
1189} // namespace mozilla