diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index c371de0d4ccc..713dcbb0986c 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -403,18 +403,10 @@ void CanonicalBrowsingContext::PendingRemotenessChange::Complete( callback, callback); } - // FIXME: We should get the correct principal for the to-be-created window so - // we can avoid creating unnecessary extra windows in the new process. - OriginAttributes attrs = embedderBrowser->OriginAttributesRef(); - RefPtr principal = embedderBrowser->GetContentPrincipal(); - if (principal) { - attrs.SetFirstPartyDomain( - true, principal->OriginAttributesRef().mFirstPartyDomain); - } - nsCOMPtr initialPrincipal = - NullPrincipal::CreateWithInheritedAttributes(attrs, - /* isFirstParty */ false); + NullPrincipal::CreateWithInheritedAttributes( + target->OriginAttributesRef(), + /* isFirstParty */ false); WindowGlobalInit windowInit = WindowGlobalActor::AboutBlankInitializer(target, initialPrincipal); diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 7d11b91a68b7..80d0e1f53e2b 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -1156,6 +1156,9 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( return NS_ERROR_NOT_IMPLEMENTED; } + RefPtr ourBc = browserParent->GetBrowsingContext(); + RefPtr otherBc = otherBrowserParent->GetBrowsingContext(); + // When we swap docShells, maybe we have to deal with a new page created just // for this operation. In this case, the browser code should already have set // the correct userContextId attribute value in the owning element, but our @@ -1164,12 +1167,11 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( // This is the reason why now we must retrieve the correct value from the // usercontextid attribute before comparing our originAttributes with the // other one. - OriginAttributes ourOriginAttributes = browserParent->OriginAttributesRef(); + OriginAttributes ourOriginAttributes = ourBc->OriginAttributesRef(); rv = PopulateOriginContextIdsFromAttributes(ourOriginAttributes); NS_ENSURE_SUCCESS(rv, rv); - OriginAttributes otherOriginAttributes = - otherBrowserParent->OriginAttributesRef(); + OriginAttributes otherOriginAttributes = otherBc->OriginAttributesRef(); rv = aOther->PopulateOriginContextIdsFromAttributes(otherOriginAttributes); NS_ENSURE_SUCCESS(rv, rv); @@ -3275,7 +3277,6 @@ nsresult nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext, NS_ENSURE_STATE(parentContext); MOZ_ASSERT(mPendingBrowsingContext->EverAttached()); - OriginAttributes attrs = mPendingBrowsingContext->OriginAttributesRef(); UIStateChangeType showFocusRings = UIStateChangeType_NoChange; uint64_t chromeOuterWindowID = 0; @@ -3296,9 +3297,8 @@ nsresult nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext, uint32_t maxTouchPoints = BrowserParent::GetMaxTouchPoints(mOwnerContent); - bool tabContextUpdated = - aTabContext->SetTabContext(chromeOuterWindowID, showFocusRings, attrs, - presentationURLStr, maxTouchPoints); + bool tabContextUpdated = aTabContext->SetTabContext( + chromeOuterWindowID, showFocusRings, presentationURLStr, maxTouchPoints); NS_ENSURE_STATE(tabContextUpdated); return NS_OK; diff --git a/dom/ipc/BrowserBridgeParent.cpp b/dom/ipc/BrowserBridgeParent.cpp index 398d756e06c2..41114dc93bc6 100644 --- a/dom/ipc/BrowserBridgeParent.cpp +++ b/dom/ipc/BrowserBridgeParent.cpp @@ -37,20 +37,9 @@ nsresult BrowserBridgeParent::InitWithProcess( RefPtr browsingContext = aWindowInit.browsingContext().get_canonical(); - // We can inherit most TabContext fields for the new BrowserParent actor from - // our Manager BrowserParent. We also need to sync the first party domain if - // the content principal exists. MutableTabContext tabContext; - OriginAttributes attrs; - attrs = Manager()->OriginAttributesRef(); - RefPtr principal = Manager()->GetContentPrincipal(); - if (principal) { - attrs.SetFirstPartyDomain( - true, principal->OriginAttributesRef().mFirstPartyDomain); - } - tabContext.SetTabContext(Manager()->ChromeOuterWindowID(), - Manager()->ShowFocusRings(), attrs, aPresentationURL, + Manager()->ShowFocusRings(), aPresentationURL, Manager()->GetMaxTouchPoints()); // Ensure that our content process is subscribed to our newly created diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index b0d1f4742e54..9260c1eac816 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -489,8 +489,8 @@ nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent, LayoutDeviceIntRect(0, 0, 0, 0), nullptr); // HandleWidgetEvent - mWebBrowser = nsWebBrowser::Create(this, mPuppetWidget, OriginAttributesRef(), - mBrowsingContext, aInitialWindowChild); + mWebBrowser = nsWebBrowser::Create(this, mPuppetWidget, mBrowsingContext, + aInitialWindowChild); nsIWebBrowser* webBrowser = mWebBrowser; mWebNav = do_QueryInterface(webBrowser); @@ -526,8 +526,6 @@ nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent, #ifdef DEBUG nsCOMPtr loadContext = do_GetInterface(WebNavigation()); MOZ_ASSERT(loadContext); - MOZ_ASSERT(loadContext->UsePrivateBrowsing() == - (OriginAttributesRef().mPrivateBrowsingId > 0)); MOZ_ASSERT(loadContext->UseRemoteTabs() == !!(mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW)); MOZ_ASSERT(loadContext->UseRemoteSubframes() == diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 0c0be3a1f209..c65d53f26665 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -983,13 +983,11 @@ nsresult ContentChild::ProvideWindowCommon( if (aTabOpener) { newTabContext.SetTabContext( aTabOpener->ChromeOuterWindowID(), aTabOpener->ShowFocusRings(), - browsingContext->OriginAttributesRef(), aTabOpener->PresentationURL(), - aTabOpener->MaxTouchPoints()); + aTabOpener->PresentationURL(), aTabOpener->MaxTouchPoints()); } else { newTabContext.SetTabContext( /* chromeOuterWindowID */ 0, /* showFocusRings */ UIStateChangeType_NoChange, - browsingContext->OriginAttributesRef(), /* presentationURL */ EmptyString(), /* maxTouchPoints */ 0); } diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index f98178a64c2a..98b3dd216b48 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1283,7 +1283,7 @@ already_AddRefed ContentParent::CreateBrowser( cpm->RegisterRemoteFrame(browserParent); nsCOMPtr initialPrincipal = - NullPrincipal::Create(aContext.OriginAttributesRef()); + NullPrincipal::Create(aBrowsingContext->OriginAttributesRef()); WindowGlobalInit windowInit = WindowGlobalActor::AboutBlankInitializer( aBrowsingContext, initialPrincipal); diff --git a/dom/ipc/PTabContext.ipdlh b/dom/ipc/PTabContext.ipdlh index 445bf7520455..8681a342875d 100644 --- a/dom/ipc/PTabContext.ipdlh +++ b/dom/ipc/PTabContext.ipdlh @@ -25,9 +25,6 @@ struct PopupIPCTabContext // An IPCTabContext which corresponds to an app, browser, or normal frame. struct FrameIPCTabContext { - // The originAttributes dictionary. - OriginAttributes originAttributes; - uint64_t chromeOuterWindowID; // The requested presentation URL. diff --git a/dom/ipc/TabContext.cpp b/dom/ipc/TabContext.cpp index 01fd1552b44d..f895810dc897 100644 --- a/dom/ipc/TabContext.cpp +++ b/dom/ipc/TabContext.cpp @@ -41,33 +41,17 @@ bool TabContext::SetTabContext(const TabContext& aContext) { return true; } -void TabContext::SetPrivateBrowsingAttributes(bool aIsPrivateBrowsing) { - mOriginAttributes.SyncAttributesWithPrivateBrowsing(aIsPrivateBrowsing); -} - -void TabContext::SetFirstPartyDomainAttributes( - const nsAString& aFirstPartyDomain) { - mOriginAttributes.SetFirstPartyDomain(true, aFirstPartyDomain); -} - bool TabContext::UpdateTabContextAfterSwap(const TabContext& aContext) { // This is only used after already initialized. MOZ_ASSERT(mInitialized); // The only permissable changes are to mChromeOuterWindowID. All other fields // must match for the change to be accepted. - if (aContext.mOriginAttributes != mOriginAttributes) { - return false; - } mChromeOuterWindowID = aContext.mChromeOuterWindowID; return true; } -const OriginAttributes& TabContext::OriginAttributesRef() const { - return mOriginAttributes; -} - const nsAString& TabContext::PresentationURL() const { return mPresentationURL; } @@ -76,14 +60,12 @@ UIStateChangeType TabContext::ShowFocusRings() const { return mShowFocusRings; } bool TabContext::SetTabContext(uint64_t aChromeOuterWindowID, UIStateChangeType aShowFocusRings, - const OriginAttributes& aOriginAttributes, const nsAString& aPresentationURL, uint32_t aMaxTouchPoints) { NS_ENSURE_FALSE(mInitialized, false); mInitialized = true; mChromeOuterWindowID = aChromeOuterWindowID; - mOriginAttributes = aOriginAttributes; mPresentationURL = aPresentationURL; mShowFocusRings = aShowFocusRings; mMaxTouchPoints = aMaxTouchPoints; @@ -103,16 +85,15 @@ IPCTabContext TabContext::AsIPCTabContext() const { return IPCTabContext(JSPluginFrameIPCTabContext(mJSPluginID)); } - return IPCTabContext( - FrameIPCTabContext(mOriginAttributes, mChromeOuterWindowID, - mPresentationURL, mShowFocusRings, mMaxTouchPoints)); + return IPCTabContext(FrameIPCTabContext(mChromeOuterWindowID, + mPresentationURL, mShowFocusRings, + mMaxTouchPoints)); } MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams) : mInvalidReason(nullptr) { uint64_t chromeOuterWindowID = 0; int32_t jsPluginId = -1; - OriginAttributes originAttributes; nsAutoString presentationURL; UIStateChangeType showFocusRings = UIStateChangeType_NoChange; uint32_t maxTouchPoints = 0; @@ -133,7 +114,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams) return; } - originAttributes = context->mOriginAttributes; chromeOuterWindowID = ipcContext.chromeOuterWindowID(); break; } @@ -150,7 +130,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams) chromeOuterWindowID = ipcContext.chromeOuterWindowID(); presentationURL = ipcContext.presentationURL(); showFocusRings = ipcContext.showFocusRings(); - originAttributes = ipcContext.originAttributes(); maxTouchPoints = ipcContext.maxTouchPoints(); break; } @@ -176,8 +155,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams) rv = mTabContext.SetTabContextForJSPluginFrame(jsPluginId); } else { rv = mTabContext.SetTabContext(chromeOuterWindowID, showFocusRings, - originAttributes, presentationURL, - maxTouchPoints); + presentationURL, maxTouchPoints); } if (!rv) { mInvalidReason = "Couldn't initialize TabContext."; diff --git a/dom/ipc/TabContext.h b/dom/ipc/TabContext.h index 16e469d9de16..a7ec44732150 100644 --- a/dom/ipc/TabContext.h +++ b/dom/ipc/TabContext.h @@ -44,13 +44,6 @@ class TabContext { uint64_t ChromeOuterWindowID() const; - /** - * OriginAttributesRef() returns the OriginAttributes of this frame to - * the caller. This is used to store any attribute associated with the frame's - * docshell. - */ - const OriginAttributes& OriginAttributesRef() const; - /** * Returns the presentation URL associated with the tab if this tab is * created for presented content @@ -78,19 +71,8 @@ class TabContext { */ bool SetTabContext(const TabContext& aContext); - /** - * Set the tab context's origin attributes to a private browsing value. - */ - void SetPrivateBrowsingAttributes(bool aIsPrivateBrowsing); - - /** - * Set the first party domain of the tab context's origin attributes. - */ - void SetFirstPartyDomainAttributes(const nsAString& aFirstPartyDomain); - bool SetTabContext(uint64_t aChromeOuterWindowID, UIStateChangeType aShowFocusRings, - const OriginAttributes& aOriginAttributes, const nsAString& aPresentationURL, uint32_t aMaxTouchPoints); @@ -132,11 +114,6 @@ class TabContext { int32_t mJSPluginID; - /** - * OriginAttributes of the top level tab docShell - */ - OriginAttributes mOriginAttributes; - /** * The requested presentation URL. */ @@ -166,21 +143,15 @@ class MutableTabContext : public TabContext { bool SetTabContext(uint64_t aChromeOuterWindowID, UIStateChangeType aShowFocusRings, - const OriginAttributes& aOriginAttributes, const nsAString& aPresentationURL, uint32_t aMaxTouchPoints) { return TabContext::SetTabContext(aChromeOuterWindowID, aShowFocusRings, - aOriginAttributes, aPresentationURL, - aMaxTouchPoints); + aPresentationURL, aMaxTouchPoints); } bool SetTabContextForJSPluginFrame(uint32_t aJSPluginID) { return TabContext::SetTabContextForJSPluginFrame(aJSPluginID); } - - void SetFirstPartyDomainAttributes(const nsAString& aFirstPartyDomain) { - TabContext::SetFirstPartyDomainAttributes(aFirstPartyDomain); - } }; /** diff --git a/toolkit/components/browser/nsWebBrowser.cpp b/toolkit/components/browser/nsWebBrowser.cpp index 76d7da82e2ad..58dec07a2e41 100644 --- a/toolkit/components/browser/nsWebBrowser.cpp +++ b/toolkit/components/browser/nsWebBrowser.cpp @@ -97,7 +97,6 @@ nsIWidget* nsWebBrowser::EnsureWidget() { /* static */ already_AddRefed nsWebBrowser::Create( nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget, - const OriginAttributes& aOriginAttributes, dom::BrowsingContext* aBrowsingContext, dom::WindowGlobalChild* aInitialWindowChild, bool aDisableHistory /* = false */) { @@ -124,7 +123,6 @@ already_AddRefed nsWebBrowser::Create( if (NS_WARN_IF(!docShell)) { return nullptr; } - MOZ_ASSERT(aBrowsingContext->OriginAttributesRef() == aOriginAttributes); browser->SetDocShell(docShell); // get the system default window background colour diff --git a/toolkit/components/browser/nsWebBrowser.h b/toolkit/components/browser/nsWebBrowser.h index ecc77ac10623..c41383028436 100644 --- a/toolkit/components/browser/nsWebBrowser.h +++ b/toolkit/components/browser/nsWebBrowser.h @@ -108,7 +108,6 @@ class nsWebBrowser final : public nsIWebBrowser, static already_AddRefed Create( nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget, - const mozilla::OriginAttributes& aOriginAttributes, mozilla::dom::BrowsingContext* aBrowsingContext, mozilla::dom::WindowGlobalChild* aInitialWindowChild, bool aDisableHistory = false); diff --git a/xpfe/appshell/nsAppShellService.cpp b/xpfe/appshell/nsAppShellService.cpp index 1082df199033..b4e2a48a2177 100644 --- a/xpfe/appshell/nsAppShellService.cpp +++ b/xpfe/appshell/nsAppShellService.cpp @@ -457,8 +457,8 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome, * an associated doc shell, which is what we're interested in. */ nsCOMPtr browser = nsWebBrowser::Create( - stub, widget, OriginAttributes(), browsingContext, - nullptr /* initialWindowChild */, true /* disable history */); + stub, widget, browsingContext, nullptr /* initialWindowChild */, + true /* disable history */); if (NS_WARN_IF(!browser)) { NS_ERROR("Couldn't create instance of nsWebBrowser!");