summaryrefslogtreecommitdiffstats
path: root/netwerk/base/LoadInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/base/LoadInfo.cpp')
-rw-r--r--netwerk/base/LoadInfo.cpp48
1 files changed, 40 insertions, 8 deletions
diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp
index 6be031113f..7a9f8905b6 100644
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -423,20 +423,47 @@ LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
}
#endif
- // If we think we should not resist fingerprinting, defer to the opener's
- // RFP bit (if there is an opener.) If the opener is also exempted, it stays
- // true, otherwise we will put a false into the CJS and that will be respected
- // on this document.
+ // This code path can be taken when loading an about:blank document, which
+ // means we might think that we should be exempted from resist fingerprinting.
+ // If we think that, we should defer to any opener, if it is present. If the
+ // opener is also exempted, then it continues to be exempted. Regardless of
+ // what ShouldRFP says, we _also_ need to propagate any RandomizationKey we
+ // have.
bool shouldResistFingerprinting =
nsContentUtils::ShouldResistFingerprinting_dangerous(
aURI, mOriginAttributes,
"We are creating CookieJarSettings, so we can't have one already.",
RFPTarget::IsAlwaysEnabledForPrecompute);
+
+ nsresult rv = NS_ERROR_NOT_AVAILABLE;
+ nsTArray<uint8_t> randomKey;
RefPtr<BrowsingContext> opener = aBrowsingContext->GetOpener();
- if (!shouldResistFingerprinting && opener &&
- opener->GetCurrentWindowContext()) {
- shouldResistFingerprinting =
- opener->GetCurrentWindowContext()->ShouldResistFingerprinting();
+ if (opener) {
+ MOZ_ASSERT(opener->GetCurrentWindowContext());
+ if (opener->GetCurrentWindowContext()) {
+ shouldResistFingerprinting |=
+ opener->GetCurrentWindowContext()->ShouldResistFingerprinting();
+ }
+
+ // In the parent, we need to get the CJS from the CanonicalBrowsingContext's
+ // WindowGlobalParent If we're in the child, we probably have a reference to
+ // the opener's document, and can get it from there.
+ if (XRE_IsParentProcess()) {
+ MOZ_ASSERT(opener->Canonical()->GetCurrentWindowGlobal());
+ if (opener->Canonical()->GetCurrentWindowGlobal()) {
+ MOZ_ASSERT(
+ opener->Canonical()->GetCurrentWindowGlobal()->CookieJarSettings());
+ rv = opener->Canonical()
+ ->GetCurrentWindowGlobal()
+ ->CookieJarSettings()
+ ->GetFingerprintingRandomizationKey(randomKey);
+ }
+ } else if (opener->GetDocument()) {
+ MOZ_ASSERT(false, "Code is in child");
+ rv = opener->GetDocument()
+ ->CookieJarSettings()
+ ->GetFingerprintingRandomizationKey(randomKey);
+ }
}
const bool isPrivate = mOriginAttributes.mPrivateBrowsingId > 0;
@@ -447,6 +474,11 @@ LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
mCookieJarSettings = CookieJarSettings::Create(
isPrivate ? CookieJarSettings::ePrivate : CookieJarSettings::eRegular,
shouldResistFingerprinting);
+
+ if (NS_SUCCEEDED(rv)) {
+ net::CookieJarSettings::Cast(mCookieJarSettings)
+ ->SetFingerprintingRandomizationKey(randomKey);
+ }
}
LoadInfo::LoadInfo(dom::WindowGlobalParent* aParentWGP,