Backed out 2 changesets (bug 1594529) for causing perma wpt2 with ValueError: badly formed hexadecimal UUID string in /cookies/samesite/iframe-reload.https.html CLOSED TREE

Backed out changeset fbf55a44d7fb (bug 1594529)
Backed out changeset 4ba9a230586a (bug 1594529)
This commit is contained in:
Stefan Hindli 2020-04-15 08:41:10 +03:00
parent 15cb1192a5
commit 1b55e83f7a
27 changed files with 84 additions and 488 deletions

View File

@ -156,14 +156,6 @@ CanonicalBrowsingContext::GetEmbedderWindowGlobal() const {
return WindowGlobalParent::GetByInnerWindowId(windowId);
}
already_AddRefed<WindowGlobalParent>
CanonicalBrowsingContext::GetParentWindowGlobal() const {
if (GetParent()) {
return GetEmbedderWindowGlobal();
}
return nullptr;
}
nsISHistory* CanonicalBrowsingContext::GetSessionHistory() {
if (mSessionHistory) {
return mSessionHistory;

View File

@ -65,9 +65,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
already_AddRefed<WindowGlobalParent> GetEmbedderWindowGlobal() const;
// Same as GetEmbedderWindowGlobal but within the same browsing context group
already_AddRefed<WindowGlobalParent> GetParentWindowGlobal() const;
nsISHistory* GetSessionHistory();
void SetSessionHistory(nsISHistory* aSHistory) {
mSessionHistory = aSHistory;

View File

@ -398,6 +398,7 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
mHasLoadedNonBlankURI(false),
mBlankTiming(false),
mTitleValidForCurrentURI(false),
mIsFrame(false),
mWillChangeProcess(false),
mWatchedByDevtools(false),
mIsNavigating(false) {
@ -9634,17 +9635,11 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
"subframes should have the same docshell type as their parent");
#endif
} else {
if (mIsBeingDestroyed) {
// If this isn't a top-level load and mScriptGlobal's frame element is
// null, then the element got removed from the DOM while we were trying
// to load this resource. This docshell is scheduled for destruction
// already, so bail out here.
return NS_OK;
}
// If we are not being destroyed and we do not have access to the loading
// node, then we are a remote subframe. Set the loading principal
// to be a null principal and then set it correctly in the parent.
loadingPrincipal = NullPrincipal::Create(GetOriginAttributes(), nullptr);
// If this isn't a top-level load and mScriptGlobal's frame element is
// null, then the element got removed from the DOM while we were trying
// to load this resource. This docshell is scheduled for destruction
// already, so bail out here.
return NS_OK;
}
}
@ -11642,6 +11637,8 @@ nsresult nsDocShell::EnsureFind() {
return NS_OK;
}
bool nsDocShell::IsFrame() { return mIsFrame; }
NS_IMETHODIMP
nsDocShell::IsBeingDestroyed(bool* aDoomed) {
NS_ENSURE_ARG(aDoomed);

View File

@ -360,6 +360,8 @@ class nsDocShell final : public nsDocLoader,
void SetInFrameSwap(bool aInSwap) { mInFrameSwap = aInSwap; }
bool InFrameSwap();
void SetIsFrame() { mIsFrame = true; };
const mozilla::Encoding* GetForcedCharset() { return mForcedCharset; }
mozilla::HTMLEditor* GetHTMLEditorInternal();
@ -1000,7 +1002,7 @@ class nsDocShell final : public nsDocLoader,
void RecomputeCanExecuteScripts();
void ClearFrameHistory(nsISHEntry* aEntry);
void UpdateGlobalHistoryTitle(nsIURI* aURI);
bool IsFrame() { return mBrowsingContext->GetParent(); }
bool IsFrame();
bool CanSetOriginAttributes();
bool ShouldBlockLoadingForBackButton();
bool ShouldDiscardLayoutState(nsIHttpChannel* aChannel);
@ -1331,6 +1333,8 @@ class nsDocShell final : public nsDocLoader,
// This flag indicates when the title is valid for the current URI.
bool mTitleValidForCurrentURI : 1;
bool mIsFrame : 1;
// If mWillChangeProcess is set to true, then when the docshell is destroyed,
// we prepare the browsing context to change process.
bool mWillChangeProcess : 1;

View File

@ -3243,11 +3243,6 @@ void Document::ApplySettingsFromCSP(bool aSpeculative) {
if (!mUpgradeInsecurePreloads) {
mUpgradeInsecurePreloads = mUpgradeInsecureRequests;
}
// Update csp settings in the parent process
if (auto* wgc = GetWindowGlobalChild()) {
wgc->SendUpdateDocumentCspSettings(mBlockAllMixedContent,
mUpgradeInsecureRequests);
}
}
return;
}
@ -15008,10 +15003,6 @@ void Document::SetUserHasInteracted() {
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
loadInfo->SetDocumentHasUserInteracted(true);
}
// Tell the parent process about user interaction
if (auto* wgc = GetWindowGlobalChild()) {
wgc->SendUpdateDocumentHasUserInteracted(true);
}
MaybeAllowStorageForOpenerAfterUserInteraction();
}
@ -16159,17 +16150,6 @@ nsICookieJarSettings* Document::CookieJarSettings() {
? net::CookieJarSettings::Create(
inProcessParent->CookieJarSettings()->GetCookieBehavior())
: net::CookieJarSettings::Create();
if (auto* wgc = GetWindowGlobalChild()) {
net::CookieJarSettingsArgs csArgs;
net::CookieJarSettings::Cast(mCookieJarSettings)->Serialize(csArgs);
// Update cookie settings in the parent process
if (!wgc->SendUpdateCookieJarSettings(csArgs)) {
NS_WARNING(
"Failed to update document's cookie jar settings on the "
"WindowGlobalParent");
}
}
}
return mCookieJarSettings;
@ -16211,8 +16191,10 @@ void Document::SetIsInitialDocument(bool aIsInitialDocument) {
// Asynchronously tell the parent process that we are, or are no longer, the
// initial document. This happens async.
if (auto* wgc = GetWindowGlobalChild()) {
wgc->SendSetIsInitialDocument(aIsInitialDocument);
if (RefPtr<nsPIDOMWindowInner> inner = GetInnerWindow()) {
if (RefPtr<WindowGlobalChild> wgc = inner->GetWindowGlobalChild()) {
wgc->SendSetIsInitialDocument(aIsInitialDocument);
}
}
}

View File

@ -1847,14 +1847,6 @@ class Document : public nsINode,
return window ? window->WindowID() : 0;
}
/**
* Return WindowGlobalChild that is associated with the inner window.
*/
WindowGlobalChild* GetWindowGlobalChild() {
return GetInnerWindow() ? GetInnerWindow()->GetWindowGlobalChild()
: nullptr;
}
bool IsTopLevelWindowInactive() const;
/**

View File

@ -274,39 +274,6 @@ ThirdPartyUtil::IsThirdPartyWindow(mozIDOMWindowProxy* aWindow, nsIURI* aURI,
return NS_ERROR_UNEXPECTED;
}
nsresult ThirdPartyUtil::IsThirdPartyGlobal(
mozilla::dom::WindowGlobalParent* aWindowGlobal, bool* aResult) {
NS_ENSURE_ARG(aWindowGlobal);
NS_ASSERTION(aResult, "null outparam pointer");
auto* currentWGP = aWindowGlobal;
do {
MOZ_ASSERT(currentWGP->BrowsingContext());
if (currentWGP->BrowsingContext()->IsTop()) {
*aResult = false;
return NS_OK;
}
nsCOMPtr<nsIPrincipal> currentPrincipal = currentWGP->DocumentPrincipal();
RefPtr<WindowGlobalParent> parent =
currentWGP->BrowsingContext()->GetEmbedderWindowGlobal();
if (!parent) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPrincipal> parentPrincipal = parent->DocumentPrincipal();
nsresult rv =
currentPrincipal->IsThirdPartyPrincipal(parentPrincipal, aResult);
if (NS_FAILED(rv)) {
return rv;
}
if (*aResult) {
return NS_OK;
}
currentWGP = parent;
} while (true);
}
// Determine if the URI associated with aChannel or any URI of the window
// hierarchy associated with the channel is foreign with respect to aSecondURI.
// See docs for mozIThirdPartyUtil.

View File

@ -14,7 +14,6 @@
#include "nsEffectiveTLDService.h"
#include "nsString.h"
#include "nsPIDOMWindow.h"
#include "mozilla/dom/WindowGlobalParent.h"
class nsIURI;
class nsPIDOMWindowOuter;
@ -29,9 +28,6 @@ class ThirdPartyUtil final : public mozIThirdPartyUtil {
static void Startup();
static ThirdPartyUtil* GetInstance();
nsresult IsThirdPartyGlobal(mozilla::dom::WindowGlobalParent* aWindowGlobal,
bool* aResult);
private:
~ThirdPartyUtil();

View File

@ -2147,6 +2147,8 @@ nsresult nsFrameLoader::MaybeCreateDocShell() {
if (OwnerIsMozBrowserFrame()) {
docShell->SetFrameType(nsIDocShell::FRAME_TYPE_BROWSER);
} else if (mPendingBrowsingContext->GetParent()) {
docShell->SetIsFrame();
}
// Apply sandbox flags even if our owner is not an iframe, as this copies

View File

@ -1996,19 +1996,11 @@ nsresult nsGlobalWindowInner::PostHandleEvent(EventChainPostVisitor& aVisitor) {
}
}
mIsDocumentLoaded = false;
// Tell the parent process that the document is not loaded.
if (mWindowGlobalChild) {
mWindowGlobalChild->SendUpdateDocumentHasLoaded(mIsDocumentLoaded);
}
} else if (aVisitor.mEvent->mMessage == eLoad &&
aVisitor.mEvent->IsTrusted()) {
// This is page load event since load events don't propagate to |window|.
// @see Document::GetEventTargetParent.
mIsDocumentLoaded = true;
// Tell the parent process that the document is loaded.
if (mWindowGlobalChild) {
mWindowGlobalChild->SendUpdateDocumentHasLoaded(mIsDocumentLoaded);
}
mTimeoutManager->OnDocumentLoaded();

View File

@ -2415,21 +2415,6 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
WindowGlobalChild* wgc = mInnerWindow->GetWindowGlobalChild();
wgc->SetDocumentURI(aDocument->GetDocumentURI());
wgc->SetDocumentPrincipal(aDocument->NodePrincipal());
wgc->SendUpdateDocumentCspSettings(
aDocument->GetBlockAllMixedContent(false),
aDocument->GetUpgradeInsecureRequests(false));
wgc->SendUpdateSandboxFlags(aDocument->GetSandboxFlags());
net::CookieJarSettingsArgs csArgs;
net::CookieJarSettings::Cast(aDocument->CookieJarSettings())
->Serialize(csArgs);
if (!wgc->SendUpdateCookieJarSettings(csArgs)) {
NS_WARNING(
"Failed to update document's cookie jar settings on the "
"WindowGlobalParent");
}
RefPtr<BrowsingContext> bc = GetBrowsingContext();
bc->SetCurrentInnerWindowId(mInnerWindow->WindowID());

View File

@ -5411,7 +5411,7 @@ nsresult ContentParent::AboutToLoadHttpFtpDocumentForChild(
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<BrowsingContext> browsingContext;
rv = loadInfo->GetTargetBrowsingContext(getter_AddRefs(browsingContext));
rv = loadInfo->GetBrowsingContext(getter_AddRefs(browsingContext));
NS_ENSURE_SUCCESS(rv, rv);
if (browsingContext && !browsingContext->IsDiscarded()) {

View File

@ -12,7 +12,6 @@ include protocol PBrowserBridge;
include DOMTypes;
include ClientIPCTypes;
include NeckoChannelParams;
using JSWindowActorMessageKind from "mozilla/dom/JSWindowActor.h";
using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
@ -84,27 +83,6 @@ parent:
/// Update the URI of the document in this WindowGlobal.
async UpdateDocumentURI(nsIURI aUri);
// We expose frameAncestors to web-extensions and they extract URIs from the
// principals collected. In order to be compatible with that API, we need to
// update the document's principal. This is only allowed if the principals are
// `equals` to each other.
async UpdateDocumentPrincipal(nsIPrincipal aPrincipal);
// Update document's `documentHasLoaded` bit in this WindowGlobal.
async UpdateDocumentHasLoaded(bool aDocumentHasLoaded);
// Update document's 'documentHasUserInteracted' bit in this WindowGlobal.
async UpdateDocumentHasUserInteracted(bool aDocumentHasUserInteracted);
// Update document's sandbox flags in this WindowGlobal.
async UpdateSandboxFlags(uint32_t aSandboxFlags);
// Update document csp's fields in this WindowGlobal.
async UpdateDocumentCspSettings(bool aBlockAllMixedContent, bool aUpgradeInsecureRequests);
// Update document's cookie settings in this WindowGlobal.
async UpdateCookieJarSettings(CookieJarSettingsArgs cookieJarSettings);
// Update the title of the document in this WindowGlobal.
async UpdateDocumentTitle(nsString aTitle);

View File

@ -455,13 +455,6 @@ void WindowGlobalChild::SetDocumentURI(nsIURI* aDocumentURI) {
SendUpdateDocumentURI(aDocumentURI);
}
void WindowGlobalChild::SetDocumentPrincipal(
nsIPrincipal* aNewDocumentPrincipal) {
MOZ_ASSERT(mDocumentPrincipal->Equals(aNewDocumentPrincipal));
mDocumentPrincipal = aNewDocumentPrincipal;
SendUpdateDocumentPrincipal(aNewDocumentPrincipal);
}
const nsAString& WindowGlobalChild::GetRemoteType() {
if (XRE_IsContentProcess()) {
return ContentChild::GetSingleton()->GetRemoteType();

View File

@ -61,9 +61,6 @@ class WindowGlobalChild final : public WindowGlobalActor,
nsIURI* GetDocumentURI() override { return mDocumentURI; }
void SetDocumentURI(nsIURI* aDocumentURI);
// See the corresponding comment for `UpdateDocumentPrincipal` in
// PWindowGlobal on why and when this is allowed
void SetDocumentPrincipal(nsIPrincipal* aNewDocumentPrincipal);
nsIPrincipal* DocumentPrincipal() { return mDocumentPrincipal; }

View File

@ -59,12 +59,7 @@ WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit,
mDocumentURI(aInit.documentURI()),
mInProcess(aInProcess),
mIsInitialDocument(false),
mHasBeforeUnload(false),
mSandboxFlags(0),
mDocumentHasLoaded(false),
mDocumentHasUserInteracted(false),
mBlockAllMixedContent(false),
mUpgradeInsecureRequests(false) {
mHasBeforeUnload(false) {
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(), "Parent process only");
MOZ_RELEASE_ASSERT(
@ -254,46 +249,12 @@ IPCResult WindowGlobalParent::RecvUpdateDocumentURI(nsIURI* aURI) {
return IPC_OK();
}
IPCResult WindowGlobalParent::RecvUpdateDocumentPrincipal(
nsIPrincipal* aNewDocumentPrincipal) {
if (!mDocumentPrincipal->Equals(aNewDocumentPrincipal)) {
return IPC_FAIL(this,
"Trying to reuse WindowGlobalParent but the principal of "
"the new document does not match the old one");
}
mDocumentPrincipal = aNewDocumentPrincipal;
return IPC_OK();
}
mozilla::ipc::IPCResult WindowGlobalParent::RecvUpdateDocumentTitle(
const nsString& aTitle) {
mDocumentTitle = aTitle;
return IPC_OK();
}
IPCResult WindowGlobalParent::RecvUpdateDocumentHasLoaded(
bool aDocumentHasLoaded) {
mDocumentHasLoaded = aDocumentHasLoaded;
return IPC_OK();
}
IPCResult WindowGlobalParent::RecvUpdateDocumentHasUserInteracted(
bool aDocumentHasUserInteracted) {
mDocumentHasUserInteracted = aDocumentHasUserInteracted;
return IPC_OK();
}
IPCResult WindowGlobalParent::RecvUpdateSandboxFlags(uint32_t aSandboxFlags) {
mSandboxFlags = aSandboxFlags;
return IPC_OK();
}
IPCResult WindowGlobalParent::RecvUpdateDocumentCspSettings(
bool aBlockAllMixedContent, bool aUpgradeInsecureRequests) {
mBlockAllMixedContent = aBlockAllMixedContent;
mUpgradeInsecureRequests = aUpgradeInsecureRequests;
return IPC_OK();
}
IPCResult WindowGlobalParent::RecvSetHasBeforeUnload(bool aHasBeforeUnload) {
mHasBeforeUnload = aHasBeforeUnload;
return IPC_OK();
@ -502,13 +463,6 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvGetContentBlockingEvents(
return IPC_OK();
}
mozilla::ipc::IPCResult WindowGlobalParent::RecvUpdateCookieJarSettings(
const CookieJarSettingsArgs& aCookieJarSettingsArgs) {
net::CookieJarSettings::Deserialize(aCookieJarSettingsArgs,
getter_AddRefs(mCookieJarSettings));
return IPC_OK();
}
mozilla::ipc::IPCResult WindowGlobalParent::RecvShare(
IPCWebShareData&& aData, WindowGlobalParent::ShareResolver&& aResolver) {
// Widget Layer handoff...

View File

@ -22,7 +22,6 @@
#include "nsIContentParent.h"
#include "mozilla/dom/WindowGlobalActor.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/net/CookieJarSettings.h"
class nsIPrincipal;
class nsIURI;
@ -163,18 +162,6 @@ class WindowGlobalParent final : public WindowContext,
nsIContentParent* GetContentParent();
nsICookieJarSettings* CookieJarSettings() { return mCookieJarSettings; }
bool DocumentHasLoaded() { return mDocumentHasLoaded; }
bool DocumentHasUserInteracted() { return mDocumentHasUserInteracted; }
uint32_t SandboxFlags() { return mSandboxFlags; }
bool GetDocumentBlockAllMixedContent() { return mBlockAllMixedContent; }
bool GetDocumentUpgradeInsecureRequests() { return mUpgradeInsecureRequests; }
protected:
const nsAString& GetRemoteType() override;
JSWindowActor::Type GetSide() override { return JSWindowActor::Type::Parent; }
@ -187,14 +174,6 @@ class WindowGlobalParent final : public WindowContext,
const MaybeDiscarded<dom::BrowsingContext>& aTargetBC,
nsDocShellLoadState* aLoadState);
mozilla::ipc::IPCResult RecvUpdateDocumentURI(nsIURI* aURI);
mozilla::ipc::IPCResult RecvUpdateDocumentPrincipal(
nsIPrincipal* aNewDocumentPrincipal);
mozilla::ipc::IPCResult RecvUpdateDocumentHasLoaded(bool aDocumentHasLoaded);
mozilla::ipc::IPCResult RecvUpdateDocumentHasUserInteracted(
bool aDocumentHasUserInteracted);
mozilla::ipc::IPCResult RecvUpdateSandboxFlags(uint32_t aSandboxFlags);
mozilla::ipc::IPCResult RecvUpdateDocumentCspSettings(
bool aBlockAllMixedContent, bool aUpgradeInsecureRequests);
mozilla::ipc::IPCResult RecvUpdateDocumentTitle(const nsString& aTitle);
mozilla::ipc::IPCResult RecvSetIsInitialDocument(bool aIsInitialDocument) {
mIsInitialDocument = aIsInitialDocument;
@ -210,8 +189,6 @@ class WindowGlobalParent final : public WindowContext,
mozilla::ipc::IPCResult RecvGetContentBlockingEvents(
GetContentBlockingEventsResolver&& aResolver);
mozilla::ipc::IPCResult RecvUpdateCookieJarSettings(
const CookieJarSettingsArgs& aCookieJarSettingsArgs);
void ActorDestroy(ActorDestroyReason aWhy) override;
@ -246,13 +223,6 @@ class WindowGlobalParent final : public WindowContext,
ContentBlockingLog mContentBlockingLog;
Maybe<ClientInfo> mClientInfo;
// Fields being mirrored from the corresponding document
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
uint32_t mSandboxFlags;
bool mDocumentHasLoaded;
bool mDocumentHasUserInteracted;
bool mBlockAllMixedContent;
bool mUpgradeInsecureRequests;
};
} // namespace dom

View File

@ -53,9 +53,9 @@ class nsIWidget;
namespace mozilla {
class CancelableRunnable;
class HostWebGLCommandSink;
namespace dom {
class HostWebGLCommandSink;
class WebGLParent;
} // namespace dom

View File

@ -22,7 +22,6 @@
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/StaticPrefs_security.h"
#include "mozIThirdPartyUtil.h"
#include "ThirdPartyUtil.h"
#include "nsFrameLoader.h"
#include "nsFrameLoaderOwner.h"
#include "nsIContentSecurityPolicy.h"
@ -39,7 +38,6 @@
#include "nsQueryObject.h"
#include "nsRedirectHistoryEntry.h"
#include "nsSandboxFlags.h"
#include "nsICookieService.h"
using namespace mozilla::dom;
@ -292,6 +290,7 @@ LoadInfo::LoadInfo(
}
}
}
mOriginAttributes = mLoadingPrincipal->OriginAttributesRef();
// We need to do this after inheriting the document's origin attributes
@ -522,195 +521,6 @@ LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
mCookieJarSettings = CookieJarSettings::Create();
}
LoadInfo::LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal,
uint64_t aFrameOuterWindowID, nsSecurityFlags aSecurityFlags,
uint32_t aSandboxFlags)
: mLoadingPrincipal(nullptr),
mTriggeringPrincipal(aTriggeringPrincipal),
mPrincipalToInherit(nullptr),
mClientInfo(Maybe<mozilla::dom::ClientInfo>()),
mController(Maybe<mozilla::dom::ServiceWorkerDescriptor>()),
mLoadingContext(nullptr),
mContextForTopLevelLoad(nullptr),
mSecurityFlags(aSecurityFlags),
mSandboxFlags(aSandboxFlags),
mTainting(LoadTainting::Basic),
mBlockAllMixedContent(false),
mUpgradeInsecureRequests(false),
mBrowserUpgradeInsecureRequests(false),
mBrowserWouldUpgradeInsecureRequests(false),
mForceAllowDataURI(false),
mAllowInsecureRedirectToDataURI(false),
mBypassCORSChecks(false),
mSkipContentPolicyCheckForWebRequest(false),
mOriginalFrameSrcLoad(false),
mForceInheritPrincipalDropped(false),
mInnerWindowID(0),
mOuterWindowID(0),
mParentOuterWindowID(0),
mTopOuterWindowID(0),
mFrameOuterWindowID(aFrameOuterWindowID),
mBrowsingContextID(0),
mFrameBrowsingContextID(0),
// annyG: we are mimicking the old LoadInfo since it has gone through
// security checks in the content and we wouldn't reach this point
// if the load got blocked earlier.
mInitialSecurityCheckDone(true),
mIsThirdPartyContext(false),
mIsFormSubmission(false),
mSendCSPViolationEvents(true),
mRequestBlockingReason(BLOCKING_REASON_NONE),
mForcePreflight(false),
mIsPreflight(false),
mLoadTriggeredFromExternal(false),
mServiceWorkerTaintingSynthesized(false),
mDocumentHasUserInteracted(false),
mDocumentHasLoaded(false),
mAllowListFutureDocumentsCreatedFromThisRedirectChain(false),
mSkipContentSniffing(false),
mHttpsOnlyStatus(nsILoadInfo::HTTPS_ONLY_UNINITIALIZED),
mAllowDeprecatedSystemRequests(false),
mParserCreatedScript(false),
mHasStoragePermission(false),
mIsFromProcessingFrameAttributes(false) {
RefPtr<WindowGlobalParent> embedderWGP =
aBrowsingContext->GetParentWindowGlobal();
BrowsingContext* embedderBC = embedderWGP->BrowsingContext();
MOZ_ASSERT(embedderBC);
nsTArray<nsCOMPtr<nsIPrincipal>> ancestorPrincipals;
nsTArray<uint64_t> ancestorOuterWindowIDs;
CanonicalBrowsingContext* ancestorBC = embedderBC->Canonical();
RefPtr<WindowGlobalParent> topLevelWGP = embedderWGP;
// Iterate over ancestor WindowGlobalParent's - collect principals and
// outer window IDs. Also note the top level WindowGlobalParent.
while (RefPtr<WindowGlobalParent> ancestorWGP =
ancestorBC->GetParentWindowGlobal()) {
nsCOMPtr<nsIPrincipal> parentPrincipal = ancestorWGP->DocumentPrincipal();
MOZ_ASSERT(parentPrincipal, "Ancestor principal is null");
ancestorPrincipals.AppendElement(parentPrincipal.forget());
ancestorOuterWindowIDs.AppendElement(ancestorWGP->OuterWindowId());
topLevelWGP = ancestorWGP;
ancestorBC = ancestorWGP->BrowsingContext();
}
mAncestorPrincipals = ancestorPrincipals;
mAncestorOuterWindowIDs = ancestorOuterWindowIDs;
MOZ_DIAGNOSTIC_ASSERT(mAncestorPrincipals.Length() ==
mAncestorOuterWindowIDs.Length());
if (RefPtr<WindowGlobalParent> ancestorWGP =
embedderWGP->BrowsingContext()->GetParentWindowGlobal()) {
mParentOuterWindowID = ancestorWGP->OuterWindowId();
} else {
mParentOuterWindowID = embedderWGP->OuterWindowId();
}
// if the load is sandboxed, we can not also inherit the principal
if (mSandboxFlags & SANDBOXED_ORIGIN) {
mForceInheritPrincipalDropped =
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
mSecurityFlags &= ~nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
}
const auto& maybeEmbedderElementType =
aBrowsingContext->GetEmbedderElementType();
MOZ_ASSERT(maybeEmbedderElementType.isSome());
auto embedderElementType = maybeEmbedderElementType.value();
// Assign same type as in nsDocShell::DetermineContentType.
// N.B. internal content policy type will never be TYPE_DOCUMENT
mInternalContentPolicyType = nsIContentPolicy::TYPE_INTERNAL_FRAME;
if (embedderElementType.EqualsLiteral("iframe")) {
mInternalContentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IFRAME;
}
// Ensure that all network requests for a window client have the ClientInfo
// properly set.
mClientInfo = embedderWGP->GetClientInfo();
mLoadingPrincipal = embedderWGP->DocumentPrincipal();
ComputeIsThirdPartyContext(embedderWGP);
// When the element being loaded is a frame, we choose the frame's window
// for the window ID (see mInnerWindowID being set below) and the frame
// element's window as the parent window. This is the behavior that Chrome
// exposes to add-ons.
mOuterWindowID = embedderWGP->OuterWindowId();
mTopOuterWindowID = topLevelWGP->OuterWindowId();
mBrowsingContextID = embedderBC->Id();
// Let's inherit the cookie behavior and permission from the embedder
// document.
mCookieJarSettings = embedderWGP->CookieJarSettings();
if (embedderBC->IsContentSubframe()) {
mDocumentHasLoaded = false;
} else {
mDocumentHasLoaded = embedderWGP->DocumentHasLoaded();
}
if (topLevelWGP->BrowsingContext()->IsTop()) {
if (mCookieJarSettings) {
bool stopAtOurLevel = mCookieJarSettings->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER;
if (!stopAtOurLevel ||
topLevelWGP->OuterWindowId() != embedderWGP->OuterWindowId()) {
mTopLevelPrincipal = topLevelWGP->DocumentPrincipal();
}
}
if (embedderBC->IsContentSubframe()) {
// For resources within iframes, we actually want the
// top-level document's flag, not the iframe document's.
mDocumentHasLoaded = topLevelWGP->DocumentHasLoaded();
}
}
// The top-level-storage-area-principal is not null only for the first
// level of iframes (null for top-level contexts, and null for
// sub-iframes). If we are loading a sub-document resource, we must
// calculate what the top-level-storage-area-principal will be for the
// new context.
if (embedderBC->IsTop()) {
if (!Document::StorageAccessSandboxed(embedderWGP->SandboxFlags())) {
mTopLevelStorageAreaPrincipal = embedderWGP->DocumentPrincipal();
}
// If this is the first level iframe, embedder WindowGlobalParent's document
// principal is our top-level principal.
if (!mTopLevelPrincipal) {
mTopLevelPrincipal = embedderWGP->DocumentPrincipal();
}
}
mInnerWindowID = embedderWGP->InnerWindowId();
mFrameBrowsingContextID = aBrowsingContext->Id();
mDocumentHasUserInteracted = embedderWGP->DocumentHasUserInteracted();
// if the document forces all mixed content to be blocked, then we
// store that bit for all requests on the loadinfo.
mBlockAllMixedContent = embedderWGP->GetDocumentBlockAllMixedContent();
// if the document forces all requests to be upgraded from http to https,
// then we should do that for all requests. If it only forces preloads to be
// upgraded then we should enforce upgrade insecure requests only for
// preloads.
mUpgradeInsecureRequests = embedderWGP->GetDocumentUpgradeInsecureRequests();
mOriginAttributes = mLoadingPrincipal->OriginAttributesRef();
// We need to do this after inheriting the document's origin attributes
// above, in case the loading principal ends up being the system principal.
if (embedderBC->IsContent()) {
mOriginAttributes.SyncAttributesWithPrivateBrowsing(
embedderBC->UsePrivateBrowsing());
}
// For chrome BC, the mPrivateBrowsingId remains 0 even its
// UsePrivateBrowsing() is true, so we only update the mPrivateBrowsingId in
// origin attributes if the type of the BC is content.
if (embedderBC->IsChrome()) {
MOZ_ASSERT(mOriginAttributes.mPrivateBrowsingId == 0,
"chrome docshell shouldn't have mPrivateBrowsingId set.");
}
}
LoadInfo::LoadInfo(const LoadInfo& rhs)
: mLoadingPrincipal(rhs.mLoadingPrincipal),
mTriggeringPrincipal(rhs.mTriggeringPrincipal),
@ -909,21 +719,6 @@ void LoadInfo::ComputeIsThirdPartyContext(nsPIDOMWindowOuter* aOuterWindow) {
util->IsThirdPartyWindow(aOuterWindow, nullptr, &mIsThirdPartyContext);
}
void LoadInfo::ComputeIsThirdPartyContext(dom::WindowGlobalParent* aGlobal) {
if (nsILoadInfo::GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_DOCUMENT) {
// Top-level loads are never third-party.
mIsThirdPartyContext = false;
return;
}
ThirdPartyUtil* thirdPartyUtil = ThirdPartyUtil::GetInstance();
if (!thirdPartyUtil) {
return;
}
thirdPartyUtil->IsThirdPartyGlobal(aGlobal, &mIsThirdPartyContext);
}
NS_IMPL_ISUPPORTS(LoadInfo, nsILoadInfo)
already_AddRefed<nsILoadInfo> LoadInfo::Clone() const {

View File

@ -30,7 +30,6 @@ namespace dom {
class PerformanceStorage;
class XMLHttpRequestMainThread;
class CanonicalBrowsingContext;
class WindowGlobalParent;
} // namespace dom
namespace net {
@ -57,7 +56,6 @@ class LoadInfo final : public nsILoadInfo {
NS_DECL_ISUPPORTS
NS_DECL_NSILOADINFO
// Used for TYPE_SUBDOCUMENT load.
// aLoadingPrincipal MUST NOT BE NULL.
LoadInfo(nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
nsINode* aLoadingContext, nsSecurityFlags aSecurityFlags,
@ -67,10 +65,6 @@ class LoadInfo final : public nsILoadInfo {
const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController =
Maybe<mozilla::dom::ServiceWorkerDescriptor>(),
uint32_t aSandboxFlags = 0);
// Used for TYPE_SUBDOCUMENT load.
LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
nsIPrincipal* aTriggeringPrincipal, uint64_t aFrameOuterWindowID,
nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
// Constructor used for TYPE_DOCUMENT loads which have a different
// loadingContext than other loads. This ContextForTopLevelLoad is
@ -185,7 +179,6 @@ class LoadInfo final : public nsILoadInfo {
~LoadInfo() = default;
void ComputeIsThirdPartyContext(nsPIDOMWindowOuter* aOuterWindow);
void ComputeIsThirdPartyContext(dom::WindowGlobalParent* aGlobal);
// This function is the *only* function which can change the securityflags
// of a loadinfo. It only exists because of the XHR code. Don't call it

View File

@ -73,19 +73,20 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
gHttpHandler->OnOpeningDocumentRequest(this);
if (!GetDocShell() || !GetDocShell()->GetBrowsingContext() ||
GetDocShell()->GetBrowsingContext()->IsDiscarded()) {
return NS_ERROR_FAILURE;
}
DocumentChannelCreationArgs args;
args.loadState() = mLoadState->Serialize();
Maybe<LoadInfoArgs> maybeArgs;
rv = LoadInfoToLoadInfoArgs(mLoadInfo, &maybeArgs);
NS_ENSURE_SUCCESS(rv, rv);
MOZ_DIAGNOSTIC_ASSERT(maybeArgs);
args.loadInfo() = *maybeArgs;
args.loadFlags() = mLoadFlags;
args.cacheKey() = mCacheKey;
args.channelId() = mChannelId;
args.asyncOpenTime() = mAsyncOpenTime;
args.outerWindowId() = GetDocShell()->GetOuterWindowID();
args.outerWindowId() = mLoadInfo->GetOuterWindowID();
Maybe<IPCClientInfo> ipcClientInfo;
if (mInitialClientInfo.isSome()) {
@ -106,6 +107,11 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
return NS_ERROR_ILLEGAL_VALUE;
}
if (!GetDocShell() || !GetDocShell()->GetBrowsingContext() ||
GetDocShell()->GetBrowsingContext()->IsDiscarded()) {
return NS_ERROR_FAILURE;
}
args.hasValidTransientUserAction() =
GetDocShell()
->GetBrowsingContext()

View File

@ -39,13 +39,19 @@ bool DocumentChannelParent::Init(const DocumentChannelCreationArgs& aArgs) {
LOG(("DocumentChannelParent Init [this=%p, uri=%s]", this,
loadState->URI()->GetSpecOrDefault().get()));
RefPtr<class LoadInfo> loadInfo;
nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo(Some(aArgs.loadInfo()),
getter_AddRefs(loadInfo));
Maybe<ClientInfo> clientInfo;
if (aArgs.initialClientInfo().isSome()) {
clientInfo.emplace(ClientInfo(aArgs.initialClientInfo().ref()));
}
nsresult rv = NS_ERROR_UNEXPECTED;
if (!mParent->Open(loadState, aArgs.loadFlags(), aArgs.cacheKey(),
MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = NS_ERROR_UNEXPECTED;
if (!mParent->Open(loadState, loadInfo, aArgs.loadFlags(), aArgs.cacheKey(),
aArgs.channelId(), aArgs.asyncOpenTime(),
aArgs.timing().refOr(nullptr), std::move(clientInfo),
aArgs.outerWindowId(), aArgs.hasValidTransientUserAction(),

View File

@ -40,7 +40,6 @@
#include "nsIOService.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/StaticPrefs_security.h"
#include "nsICookieService.h"
#ifdef ANDROID
# include "mozilla/widget/nsWindow.h"
@ -260,6 +259,9 @@ DocumentLoadListener::~DocumentLoadListener() {
already_AddRefed<LoadInfo> DocumentLoadListener::CreateLoadInfo(
CanonicalBrowsingContext* aBrowsingContext, nsDocShellLoadState* aLoadState,
uint64_t aOuterWindowId) {
OriginAttributes attrs;
mLoadContext->GetOriginAttributes(attrs);
// TODO: Block copied from nsDocShell::DoURILoad, refactor out somewhere
bool inheritPrincipal = false;
@ -289,22 +291,22 @@ already_AddRefed<LoadInfo> DocumentLoadListener::CreateLoadInfo(
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
}
if (aBrowsingContext->GetParent()) {
// Build LoadInfo for TYPE_SUBDOCUMENT
RefPtr<LoadInfo> loadInfo =
new LoadInfo(aBrowsingContext, aLoadState->TriggeringPrincipal(),
aOuterWindowId, securityFlags, sandboxFlags);
return loadInfo.forget();
}
// Build LoadInfo for TYPE_DOCUMENT
OriginAttributes attrs;
mLoadContext->GetOriginAttributes(attrs);
RefPtr<LoadInfo> loadInfo =
new LoadInfo(aBrowsingContext, aLoadState->TriggeringPrincipal(), attrs,
aOuterWindowId, securityFlags, sandboxFlags);
return loadInfo.forget();
}
already_AddRefed<WindowGlobalParent> GetParentEmbedderWindowGlobal(
CanonicalBrowsingContext* aBrowsingContext) {
RefPtr<WindowGlobalParent> parent =
aBrowsingContext->GetEmbedderWindowGlobal();
if (parent && parent->BrowsingContext() == aBrowsingContext->GetParent()) {
return parent.forget();
}
return nullptr;
}
// parent-process implementation of
// nsGlobalWindowOuter::GetTopExcludingExtensionAccessibleContentFrames
already_AddRefed<WindowGlobalParent>
@ -312,7 +314,8 @@ GetTopWindowExcludingExtensionAccessibleContentFrames(
CanonicalBrowsingContext* aBrowsingContext, nsIURI* aURIBeingLoaded) {
CanonicalBrowsingContext* bc = aBrowsingContext;
RefPtr<WindowGlobalParent> prev;
while (RefPtr<WindowGlobalParent> parent = bc->GetParentWindowGlobal()) {
while (RefPtr<WindowGlobalParent> parent =
GetParentEmbedderWindowGlobal(bc)) {
CanonicalBrowsingContext* parentBC = parent->BrowsingContext();
nsIPrincipal* parentPrincipal = parent->DocumentPrincipal();
@ -337,10 +340,11 @@ GetTopWindowExcludingExtensionAccessibleContentFrames(
}
bool DocumentLoadListener::Open(
nsDocShellLoadState* aLoadState, nsLoadFlags aLoadFlags, uint32_t aCacheKey,
const uint64_t& aChannelId, const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming, Maybe<ClientInfo>&& aInfo,
uint64_t aOuterWindowId, bool aHasGesture, nsresult* aRv) {
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aCacheKey, const uint64_t& aChannelId,
const TimeStamp& aAsyncOpenTime, nsDOMNavigationTiming* aTiming,
Maybe<ClientInfo>&& aInfo, uint64_t aOuterWindowId, bool aHasGesture,
nsresult* aRv) {
LOG(("DocumentLoadListener Open [this=%p, uri=%s]", this,
aLoadState->URI()->GetSpecOrDefault().get()));
RefPtr<CanonicalBrowsingContext> browsingContext =
@ -349,21 +353,19 @@ bool DocumentLoadListener::Open(
OriginAttributes attrs;
mLoadContext->GetOriginAttributes(attrs);
RefPtr<WindowGlobalParent> embedderWGP =
browsingContext->GetParentWindowGlobal();
if (browsingContext->GetParent() && !embedderWGP) {
// this is a race, bug 1331295
NS_WARNING(
"We don't have an embedder WindowGlobalParent, probably because of a "
"race");
return false;
}
// If this is a top-level load, then rebuild the LoadInfo from scratch,
// since the goal is to be able to initiate loads in the parent, where the
// content process won't have provided us with an existing one.
RefPtr<LoadInfo> loadInfo =
CreateLoadInfo(browsingContext, aLoadState, aOuterWindowId);
// TODO: Handle TYPE_SUBDOCUMENT LoadInfo construction, and stop passing
// aLoadInfo across IPC.
RefPtr<LoadInfo> loadInfo = aLoadInfo;
if (!browsingContext->GetParent()) {
// If we're a top level load, then we should have not got an existing
// LoadInfo, or if we did, it should be TYPE_DOCUMENT.
MOZ_ASSERT(!aLoadInfo || aLoadInfo->InternalContentPolicyType() ==
nsIContentPolicy::TYPE_DOCUMENT);
loadInfo = CreateLoadInfo(browsingContext, aLoadState, aOuterWindowId);
}
if (!nsDocShell::CreateAndConfigureRealChannelForLoadState(
browsingContext, aLoadState, loadInfo, mParentChannelListener,

View File

@ -96,11 +96,11 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
ADocumentChannelBridge* aBridge);
// Creates the channel, and then calls AsyncOpen on it.
bool Open(nsDocShellLoadState* aLoadState, nsLoadFlags aLoadFlags,
uint32_t aCacheKey, const uint64_t& aChannelId,
const TimeStamp& aAsyncOpenTime, nsDOMNavigationTiming* aTiming,
Maybe<dom::ClientInfo>&& aInfo, uint64_t aOuterWindowId,
bool aHasGesture, nsresult* aRv);
bool Open(nsDocShellLoadState* aLoadState, LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aCacheKey,
const uint64_t& aChannelId, const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming, Maybe<dom::ClientInfo>&& aInfo,
uint64_t aOuterWindowId, bool aHasGesture, nsresult* aRv);
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
@ -214,6 +214,8 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
nsTArray<ParentEndpoint>&& aStreamFilterEndpoints);
// Construct a LoadInfo object to use for the internal channel.
// TODO: This currently only supports creating top window TYPE_DOCUMENT
// LoadInfos
already_AddRefed<LoadInfo> CreateLoadInfo(
dom::CanonicalBrowsingContext* aBrowsingContext,
nsDocShellLoadState* aLoadState, uint64_t aOuterWindowId);

View File

@ -425,6 +425,7 @@ struct CookieStruct
struct DocumentChannelCreationArgs {
DocShellLoadStateInit loadState;
LoadInfoArgs loadInfo;
TimeStamp asyncOpenTime;
uint64_t channelId;
uint32_t loadFlags;

View File

@ -420,16 +420,8 @@ NeckoParent::AllocPDocumentChannelParent(
context = aContext.get_canonical();
}
nsCOMPtr<nsIPrincipal> requestingPrincipal;
// We only have the requesting principal in case of TYPE_SUBDOCUMENT.
// If we don't have an embedder window global, then it is probably a race and
// we will deal with that later in the code path.
if (context && !aContext.IsDiscarded() && context->GetParent()) {
if (RefPtr<WindowGlobalParent> embedderWGP =
context->GetParentWindowGlobal()) {
requestingPrincipal = embedderWGP->DocumentPrincipal();
}
}
nsCOMPtr<nsIPrincipal> requestingPrincipal =
GetRequestingPrincipal(Some(args.loadInfo()));
nsCOMPtr<nsILoadContext> loadContext;
const char* error = CreateChannelLoadContext(

View File

@ -151,6 +151,7 @@ skip-if = toolkit == 'android' # bug 1535505
[test_prompt.html]
skip-if = os == "linux" || toolkit == 'android' # Tests desktop prompts
[test_prompt_async.html]
fail-if = fission # bug 1582117
skip-if = toolkit == 'android' || (debug || asan || tsan) # Tests desktop prompts # Bug 1603659
support-files = subtst_prompt_async.html
[test_prompt_http.html]