Backed out 5 changesets (bug 1633820) for bustages complaining about TabContext CLOSED TREE

Backed out changeset 4982d41d5e6b (bug 1633820)
Backed out changeset 9803c41e42f9 (bug 1633820)
Backed out changeset 2475bbab03a8 (bug 1633820)
Backed out changeset 762f0b2c154c (bug 1633820)
Backed out changeset f9ea871a0227 (bug 1633820)
This commit is contained in:
Bogdan Tara 2020-05-06 22:39:46 +03:00
parent 7cd1c17fba
commit 7fce40912d
36 changed files with 429 additions and 170 deletions

View File

@ -508,8 +508,6 @@ void BrowsingContext::Attach(bool aFromIPC, ContentParent* aOriginProcess) {
MOZ_DIAGNOSTIC_ASSERT(mGroup);
MOZ_DIAGNOSTIC_ASSERT(!mIsDiscarded);
AssertCoherentLoadContext();
// Add ourselves either to our parent or BrowsingContextGroup's child list.
if (mParentWindow) {
mParentWindow->AppendChildBrowsingContext(this);
@ -1319,38 +1317,6 @@ nsresult BrowsingContext::SetOriginAttributes(const OriginAttributes& aAttrs) {
return NS_OK;
}
void BrowsingContext::AssertCoherentLoadContext() {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
// LoadContext should generally match our opener or parent.
if (RefPtr<BrowsingContext> opener = GetOpener()) {
MOZ_DIAGNOSTIC_ASSERT(opener->mType == mType);
MOZ_DIAGNOSTIC_ASSERT(opener->mGroup == mGroup);
MOZ_DIAGNOSTIC_ASSERT(opener->mUseRemoteTabs == mUseRemoteTabs);
MOZ_DIAGNOSTIC_ASSERT(opener->mUseRemoteSubframes == mUseRemoteSubframes);
MOZ_DIAGNOSTIC_ASSERT(opener->mPrivateBrowsingId == mPrivateBrowsingId);
MOZ_DIAGNOSTIC_ASSERT(
opener->mOriginAttributes.EqualsIgnoringFPD(mOriginAttributes));
}
if (RefPtr<BrowsingContext> parent = GetParent()) {
MOZ_DIAGNOSTIC_ASSERT(parent->mType == mType);
MOZ_DIAGNOSTIC_ASSERT(parent->mGroup == mGroup);
MOZ_DIAGNOSTIC_ASSERT(parent->mUseRemoteTabs == mUseRemoteTabs);
MOZ_DIAGNOSTIC_ASSERT(parent->mUseRemoteSubframes == mUseRemoteSubframes);
MOZ_DIAGNOSTIC_ASSERT(parent->mPrivateBrowsingId == mPrivateBrowsingId);
MOZ_DIAGNOSTIC_ASSERT(
parent->mOriginAttributes.EqualsIgnoringFPD(mOriginAttributes));
}
// UseRemoteSubframes and UseRemoteTabs must match.
MOZ_DIAGNOSTIC_ASSERT(
!mUseRemoteSubframes || mUseRemoteTabs,
"Cannot set useRemoteSubframes without also setting useRemoteTabs");
// Double-check OriginAttributes/Private Browsing
AssertOriginAttributesMatchPrivateBrowsing();
#endif
}
void BrowsingContext::AssertOriginAttributesMatchPrivateBrowsing() {
// Chrome browsing contexts must not have a private browsing OriginAttribute
// Content browsing contexts must maintain the equality:

View File

@ -616,10 +616,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
void AssertOriginAttributesMatchPrivateBrowsing();
// Assert that the BrowsingContext's LoadContext flags appear coherent
// relative to related BrowsingContexts.
void AssertCoherentLoadContext();
friend class ::nsOuterWindowProxy;
friend class ::nsGlobalWindowOuter;
friend class WindowContext;

View File

@ -403,10 +403,18 @@ 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<nsIPrincipal> principal = embedderBrowser->GetContentPrincipal();
if (principal) {
attrs.SetFirstPartyDomain(
true, principal->OriginAttributesRef().mFirstPartyDomain);
}
nsCOMPtr<nsIPrincipal> initialPrincipal =
NullPrincipal::CreateWithInheritedAttributes(
target->OriginAttributesRef(),
/* isFirstParty */ false);
NullPrincipal::CreateWithInheritedAttributes(attrs,
/* isFirstParty */ false);
WindowGlobalInit windowInit =
WindowGlobalActor::AboutBlankInitializer(target, initialPrincipal);

View File

@ -10,7 +10,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ScriptSettings.h" // for AutoJSAPI
#include "mozilla/dom/BrowsingContext.h"
#include "nsContentUtils.h"
#include "xpcpublic.h"
@ -18,32 +17,6 @@ namespace mozilla {
NS_IMPL_ISUPPORTS(LoadContext, nsILoadContext, nsIInterfaceRequestor)
LoadContext::LoadContext(const IPC::SerializedLoadContext& aToCopy,
dom::Element* aTopFrameElement,
OriginAttributes& aAttrs)
: mTopFrameElement(do_GetWeakReference(aTopFrameElement)),
mIsContent(aToCopy.mIsContent),
mUseRemoteTabs(aToCopy.mUseRemoteTabs),
mUseRemoteSubframes(aToCopy.mUseRemoteSubframes),
mUseTrackingProtection(aToCopy.mUseTrackingProtection),
#ifdef DEBUG
mIsNotNull(aToCopy.mIsNotNull),
#endif
mOriginAttributes(aAttrs) {
}
LoadContext::LoadContext(OriginAttributes& aAttrs)
: mTopFrameElement(nullptr),
mIsContent(false),
mUseRemoteTabs(false),
mUseRemoteSubframes(false),
mUseTrackingProtection(false),
#ifdef DEBUG
mIsNotNull(true),
#endif
mOriginAttributes(aAttrs) {
}
LoadContext::LoadContext(nsIPrincipal* aPrincipal,
nsILoadContext* aOptionalBase)
: mTopFrameElement(nullptr),
@ -67,8 +40,6 @@ LoadContext::LoadContext(nsIPrincipal* aPrincipal,
aOptionalBase->GetUseTrackingProtection(&mUseTrackingProtection));
}
LoadContext::~LoadContext() = default;
//-----------------------------------------------------------------------------
// LoadContext::nsILoadContext
//-----------------------------------------------------------------------------

View File

@ -22,7 +22,7 @@ namespace mozilla {
* from Child via SerializedLoadContext.
*
* Note: this is not the "normal" or "original" nsILoadContext. That is
* typically provided by BrowsingContext. This is only used when the original
* typically provided by nsDocShell. This is only used when the original
* docshell is in a different process and we need to copy certain values from
* it.
*/
@ -34,17 +34,54 @@ class LoadContext final : public nsILoadContext, public nsIInterfaceRequestor {
NS_DECL_NSIINTERFACEREQUESTOR
LoadContext(const IPC::SerializedLoadContext& aToCopy,
dom::Element* aTopFrameElement, OriginAttributes& aAttrs);
dom::Element* aTopFrameElement, OriginAttributes& aAttrs)
: mTopFrameElement(do_GetWeakReference(aTopFrameElement)),
mIsContent(aToCopy.mIsContent),
mUseRemoteTabs(aToCopy.mUseRemoteTabs),
mUseRemoteSubframes(aToCopy.mUseRemoteSubframes),
mUseTrackingProtection(aToCopy.mUseTrackingProtection),
#ifdef DEBUG
mIsNotNull(aToCopy.mIsNotNull),
#endif
mOriginAttributes(aAttrs) {
}
LoadContext(dom::Element* aTopFrameElement, bool aIsContent,
bool aUsePrivateBrowsing, bool aUseRemoteTabs,
bool aUseRemoteSubframes, bool aUseTrackingProtection,
const OriginAttributes& aAttrs)
: mTopFrameElement(do_GetWeakReference(aTopFrameElement)),
mIsContent(aIsContent),
mUseRemoteTabs(aUseRemoteTabs),
mUseRemoteSubframes(aUseRemoteSubframes),
mUseTrackingProtection(aUseTrackingProtection),
#ifdef DEBUG
mIsNotNull(true),
#endif
mOriginAttributes(aAttrs) {
MOZ_DIAGNOSTIC_ASSERT(aUsePrivateBrowsing ==
(aAttrs.mPrivateBrowsingId > 0));
}
// Constructor taking reserved origin attributes.
explicit LoadContext(OriginAttributes& aAttrs);
explicit LoadContext(OriginAttributes& aAttrs)
: mTopFrameElement(nullptr),
mIsContent(false),
mUseRemoteTabs(false),
mUseRemoteSubframes(false),
mUseTrackingProtection(false),
#ifdef DEBUG
mIsNotNull(true),
#endif
mOriginAttributes(aAttrs) {
}
// Constructor for creating a LoadContext with a given browser flag.
explicit LoadContext(nsIPrincipal* aPrincipal,
nsILoadContext* aOptionalBase = nullptr);
private:
~LoadContext();
~LoadContext() {}
nsWeakPtr mTopFrameElement;
bool mIsContent;

View File

@ -234,6 +234,7 @@
#include "nsViewManager.h"
#include "nsViewportInfo.h"
#include "nsWidgetsCID.h"
#include "nsIWindowProvider.h"
#include "nsWrapperCacheInlines.h"
#include "nsXULPopupManager.h"
#include "xpcprivate.h" // nsXPConnect
@ -5353,6 +5354,12 @@ void nsContentUtils::RemoveScriptBlocker() {
sBlockedScriptRunners->RemoveElementsAt(originalFirstBlocker, blockersCount);
}
/* static */
nsIWindowProvider* nsContentUtils::GetWindowProviderForContentProcess() {
MOZ_ASSERT(XRE_IsContentProcess());
return ContentChild::GetSingleton();
}
/* static */
already_AddRefed<nsPIDOMWindowOuter>
nsContentUtils::GetMostRecentNonPBWindow() {

View File

@ -109,6 +109,7 @@ class nsWrapperCache;
class nsAttrValue;
class nsITransferable;
class nsPIWindowRoot;
class nsIWindowProvider;
class nsIReferrerInfo;
struct JSRuntime;
@ -2096,6 +2097,10 @@ class nsContentUtils {
return sScriptBlockerCount == 0;
}
// XXXcatalinb: workaround for weird include error when trying to reference
// ipdl types in WindowWatcher.
static nsIWindowProvider* GetWindowProviderForContentProcess();
// Returns the browser window with the most recent time stamp that is
// not in private browsing mode.
static already_AddRefed<nsPIDOMWindowOuter> GetMostRecentNonPBWindow();

View File

@ -1156,9 +1156,6 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader(
return NS_ERROR_NOT_IMPLEMENTED;
}
RefPtr<BrowsingContext> ourBc = browserParent->GetBrowsingContext();
RefPtr<BrowsingContext> 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
@ -1167,11 +1164,12 @@ 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 = ourBc->OriginAttributesRef();
OriginAttributes ourOriginAttributes = browserParent->OriginAttributesRef();
rv = PopulateOriginContextIdsFromAttributes(ourOriginAttributes);
NS_ENSURE_SUCCESS(rv, rv);
OriginAttributes otherOriginAttributes = otherBc->OriginAttributesRef();
OriginAttributes otherOriginAttributes =
otherBrowserParent->OriginAttributesRef();
rv = aOther->PopulateOriginContextIdsFromAttributes(otherOriginAttributes);
NS_ENSURE_SUCCESS(rv, rv);
@ -3142,7 +3140,13 @@ already_AddRefed<nsIRemoteTab> nsFrameLoader::GetRemoteTab() {
}
already_AddRefed<nsILoadContext> nsFrameLoader::LoadContext() {
return do_AddRef(GetBrowsingContext());
nsCOMPtr<nsILoadContext> loadContext;
if (IsRemoteFrame() && EnsureRemoteBrowser()) {
loadContext = mRemoteBrowser->GetLoadContext();
} else {
loadContext = do_GetInterface(ToSupports(GetDocShell(IgnoreErrors())));
}
return loadContext.forget();
}
BrowsingContext* nsFrameLoader::GetBrowsingContext() {
@ -3277,6 +3281,7 @@ 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;
@ -3297,8 +3302,9 @@ nsresult nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
uint32_t maxTouchPoints = BrowserParent::GetMaxTouchPoints(mOwnerContent);
bool tabContextUpdated = aTabContext->SetTabContext(
chromeOuterWindowID, showFocusRings, presentationURLStr, maxTouchPoints);
bool tabContextUpdated =
aTabContext->SetTabContext(chromeOuterWindowID, showFocusRings, attrs,
presentationURLStr, maxTouchPoints);
NS_ENSURE_STATE(tabContextUpdated);
return NS_OK;

View File

@ -66,10 +66,6 @@ already_AddRefed<BrowserBridgeHost> BrowserBridgeChild::FinishInit(
return MakeAndAddRef<BrowserBridgeHost>(this);
}
nsILoadContext* BrowserBridgeChild::GetLoadContext() {
return mBrowsingContext;
}
void BrowserBridgeChild::NavigateByKey(bool aForward,
bool aForDocumentNavigation) {
Unused << SendNavigateByKey(aForward, aForDocumentNavigation);

View File

@ -45,7 +45,8 @@ class BrowserBridgeChild : public PBrowserBridgeChild {
BrowsingContext* GetBrowsingContext() { return mBrowsingContext; }
nsILoadContext* GetLoadContext();
// XXX(nika): We should have a load context here. (bug 1532664)
nsILoadContext* GetLoadContext() { return nullptr; }
void NavigateByKey(bool aForward, bool aForDocumentNavigation);

View File

@ -37,9 +37,20 @@ nsresult BrowserBridgeParent::InitWithProcess(
RefPtr<CanonicalBrowsingContext> 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<nsIPrincipal> principal = Manager()->GetContentPrincipal();
if (principal) {
attrs.SetFirstPartyDomain(
true, principal->OriginAttributesRef().mFirstPartyDomain);
}
tabContext.SetTabContext(Manager()->ChromeOuterWindowID(),
Manager()->ShowFocusRings(), aPresentationURL,
Manager()->ShowFocusRings(), attrs, aPresentationURL,
Manager()->GetMaxTouchPoints());
// Ensure that our content process is subscribed to our newly created

View File

@ -489,8 +489,8 @@ nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent,
LayoutDeviceIntRect(0, 0, 0, 0),
nullptr); // HandleWidgetEvent
mWebBrowser = nsWebBrowser::Create(this, mPuppetWidget, mBrowsingContext,
aInitialWindowChild);
mWebBrowser = nsWebBrowser::Create(this, mPuppetWidget, OriginAttributesRef(),
mBrowsingContext, aInitialWindowChild);
nsIWebBrowser* webBrowser = mWebBrowser;
mWebNav = do_QueryInterface(webBrowser);
@ -526,6 +526,8 @@ nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent,
#ifdef DEBUG
nsCOMPtr<nsILoadContext> 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() ==

View File

@ -90,6 +90,7 @@
#include "ColorPickerParent.h"
#include "FilePickerParent.h"
#include "BrowserChild.h"
#include "LoadContext.h"
#include "nsNetCID.h"
#include "nsIAuthInformation.h"
#include "nsIAuthPromptCallback.h"
@ -167,7 +168,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowserParent)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventListener)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WEAK(BrowserParent, mFrameLoader, mBrowsingContext)
NS_IMPL_CYCLE_COLLECTION_WEAK(BrowserParent, mLoadContext, mFrameLoader,
mBrowsingContext)
NS_IMPL_CYCLE_COLLECTING_ADDREF(BrowserParent)
NS_IMPL_CYCLE_COLLECTING_RELEASE(BrowserParent)
@ -179,6 +181,7 @@ BrowserParent::BrowserParent(ContentParent* aManager, const TabId& aTabId,
mTabId(aTabId),
mManager(aManager),
mBrowsingContext(aBrowsingContext),
mLoadContext(nullptr),
mFrameElement(nullptr),
mBrowserDOMWindow(nullptr),
mFrameLoader(nullptr),
@ -295,7 +298,27 @@ void BrowserParent::RemoveBrowserParentFromTable(layers::LayersId aLayersId) {
}
already_AddRefed<nsILoadContext> BrowserParent::GetLoadContext() {
return do_AddRef(mBrowsingContext);
nsCOMPtr<nsILoadContext> loadContext;
if (mLoadContext) {
loadContext = mLoadContext;
} else {
bool isPrivate = mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
SetPrivateBrowsingAttributes(isPrivate);
bool useTrackingProtection = false;
if (mFrameElement) {
nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
if (docShell) {
docShell->GetUseTrackingProtection(&useTrackingProtection);
}
}
loadContext = new LoadContext(
GetOwnerElement(), true /* aIsContent */, isPrivate,
mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW,
mChromeFlags & nsIWebBrowserChrome::CHROME_FISSION_WINDOW,
useTrackingProtection, OriginAttributesRef());
mLoadContext = loadContext;
}
return loadContext.forget();
}
/**

View File

@ -611,6 +611,7 @@ ContentChild::~ContentChild() {
NS_INTERFACE_MAP_BEGIN(ContentChild)
NS_INTERFACE_MAP_ENTRY(nsIContentChild)
NS_INTERFACE_MAP_ENTRY(nsIWindowProvider)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentChild)
NS_INTERFACE_MAP_END
@ -779,6 +780,20 @@ void ContentChild::SetProcessName(const nsAString& aName) {
#endif
}
NS_IMETHODIMP
ContentChild::ProvideWindow(nsIOpenWindowInfo* aOpenWindowInfo,
uint32_t aChromeFlags, bool aCalledFromJS,
bool aWidthSpecified, nsIURI* aURI,
const nsAString& aName, const nsACString& aFeatures,
bool aForceNoOpener, bool aForceNoReferrer,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
BrowsingContext** aReturn) {
return ProvideWindowCommon(nullptr, aOpenWindowInfo, aChromeFlags,
aCalledFromJS, aWidthSpecified, aURI, aName,
aFeatures, aForceNoOpener, aForceNoReferrer,
aLoadState, aWindowIsNew, aReturn);
}
static nsresult GetCreateWindowParams(nsIOpenWindowInfo* aOpenWindowInfo,
nsDocShellLoadState* aLoadState,
bool aForceNoReferrer, float* aFullZoom,
@ -849,16 +864,18 @@ nsresult ContentChild::ProvideWindowCommon(
nsIURI* aURI, const nsAString& aName, const nsACString& aFeatures,
bool aForceNoOpener, bool aForceNoReferrer, nsDocShellLoadState* aLoadState,
bool* aWindowIsNew, BrowsingContext** aReturn) {
MOZ_DIAGNOSTIC_ASSERT(aTabOpener, "We must have a tab opener");
*aReturn = nullptr;
UniquePtr<IPCTabContext> ipcContext;
TabId openerTabId = TabId(0);
nsAutoCString features(aFeatures);
nsAutoString name(aName);
nsresult rv;
RefPtr<BrowsingContext> parent = aOpenWindowInfo->GetParent();
MOZ_ASSERT(!parent || aTabOpener,
"If parent is non-null, we should have an aTabOpener");
// Cache the boolean preference for allowing noopener windows to open in a
// separate process.
@ -880,7 +897,7 @@ nsresult ContentChild::ProvideWindowCommon(
// load in the current process.
bool loadInDifferentProcess =
aForceNoOpener && sNoopenerNewProcess && !useRemoteSubframes;
if (!loadInDifferentProcess && aURI) {
if (aTabOpener && !loadInDifferentProcess && aURI) {
// Only special-case cross-process loads if Fission is disabled. With
// Fission enabled, the initial in-process load will automatically be
// retargeted to the correct process.
@ -926,13 +943,26 @@ nsresult ContentChild::ProvideWindowCommon(
return NS_ERROR_ABORT;
}
if (aTabOpener) {
PopupIPCTabContext context;
openerTabId = aTabOpener->GetTabId();
context.opener() = openerTabId;
ipcContext = MakeUnique<IPCTabContext>(context);
} else {
// It's possible to not have a BrowserChild opener in the case
// of ServiceWorker::OpenWindow.
UnsafeIPCTabContext unsafeTabContext;
ipcContext = MakeUnique<IPCTabContext>(unsafeTabContext);
}
MOZ_ASSERT(ipcContext);
TabId tabId(nsContentUtils::GenerateTabId());
// We need to assign a TabGroup to the PBrowser actor before we send it to the
// parent. Otherwise, the parent could send messages to us before we have a
// proper TabGroup for that actor.
RefPtr<BrowsingContext> openerBC;
if (!aForceNoOpener) {
if (aTabOpener && !aForceNoOpener) {
openerBC = parent;
}
@ -952,9 +982,19 @@ nsresult ContentChild::ProvideWindowCommon(
// Awkwardly manually construct the new TabContext in order to ensure our
// OriginAttributes perfectly matches it.
MutableTabContext newTabContext;
newTabContext.SetTabContext(
aTabOpener->ChromeOuterWindowID(), aTabOpener->ShowFocusRings(),
aTabOpener->PresentationURL(), aTabOpener->MaxTouchPoints());
if (aTabOpener) {
newTabContext.SetTabContext(
aTabOpener->ChromeOuterWindowID(), aTabOpener->ShowFocusRings(),
browsingContext->OriginAttributesRef(), aTabOpener->PresentationURL(),
aTabOpener->MaxTouchPoints());
} else {
newTabContext.SetTabContext(
/* chromeOuterWindowID */ 0,
/* showFocusRings */ UIStateChangeType_NoChange,
browsingContext->OriginAttributesRef(),
/* presentationURL */ EmptyString(),
/* maxTouchPoints */ 0);
}
// The initial about:blank document we generate within the nsDocShell will
// almost certainly be replaced at some point. Unfortunately, getting the
@ -975,6 +1015,11 @@ nsresult ContentChild::ProvideWindowCommon(
browsingContext, aChromeFlags,
/* aIsTopLevel */ true);
if (aTabOpener) {
MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext);
ipcContext->get_PopupIPCTabContext().opener() = aTabOpener;
}
if (IsShuttingDown()) {
return NS_ERROR_ABORT;
}
@ -993,10 +1038,8 @@ nsresult ContentChild::ProvideWindowCommon(
}
// Tell the parent process to set up its PBrowserParent.
PopupIPCTabContext ipcContext;
ipcContext.openerChild() = aTabOpener;
if (NS_WARN_IF(!SendConstructPopupBrowser(
std::move(parentEp), std::move(windowParentEp), tabId, ipcContext,
std::move(parentEp), std::move(windowParentEp), tabId, *ipcContext,
windowInit, aChromeFlags))) {
return NS_ERROR_ABORT;
}
@ -1048,10 +1091,13 @@ nsresult ContentChild::ProvideWindowCommon(
return;
}
ParentShowInfo showInfo(
EmptyString(), false, true, false, aTabOpener->WebWidget()->GetDPI(),
aTabOpener->WebWidget()->RoundsWidgetCoordinatesTo(),
aTabOpener->WebWidget()->GetDefaultScale().scale);
ParentShowInfo showInfo(EmptyString(), false, true, false, 0, 0, 0);
if (aTabOpener) {
showInfo = ParentShowInfo(
EmptyString(), false, true, false, aTabOpener->WebWidget()->GetDPI(),
aTabOpener->WebWidget()->RoundsWidgetCoordinatesTo(),
aTabOpener->WebWidget()->GetDefaultScale().scale);
}
newChild->SetMaxTouchPoints(maxTouchPoints);
newChild->SetHasSiblings(hasSiblings);
@ -2871,6 +2917,13 @@ void ContentChild::ShutdownInternal() {
: NS_LITERAL_CSTRING("SendFinishShutdown (failed)"));
}
PBrowserOrId ContentChild::GetBrowserOrId(BrowserChild* aBrowserChild) {
if (!aBrowserChild || this == aBrowserChild->Manager()) {
return PBrowserOrId(aBrowserChild);
}
return PBrowserOrId(aBrowserChild->GetTabId());
}
mozilla::ipc::IPCResult ContentChild::RecvUpdateWindow(
const uintptr_t& aChildId) {
#if defined(XP_WIN)

View File

@ -14,6 +14,7 @@
#include "mozilla/dom/BrowserBridgeChild.h"
#include "mozilla/dom/ProcessActor.h"
#include "mozilla/dom/JSProcessActorChild.h"
#include "mozilla/dom/PBrowserOrId.h"
#include "mozilla/dom/PContentChild.h"
#include "mozilla/dom/RemoteBrowser.h"
#include "mozilla/StaticPtr.h"
@ -27,6 +28,8 @@
#include "nsTArrayForwardDeclare.h"
#include "nsRefPtrHashtable.h"
#include "nsIWindowProvider.h"
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
# include "nsIFile.h"
#endif
@ -73,11 +76,13 @@ class GetFilesHelperChild;
class TabContext;
enum class MediaControlKeysEvent : uint32_t;
class ContentChild final : public PContentChild,
public nsIContentChild,
public mozilla::ipc::IShmemAllocator,
public mozilla::ipc::ChildToParentStreamActorManager,
public ProcessActor {
class ContentChild final
: public PContentChild,
public nsIContentChild,
public nsIWindowProvider,
public mozilla::ipc::IShmemAllocator,
public mozilla::ipc::ChildToParentStreamActorManager,
public ProcessActor {
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
typedef mozilla::ipc::FileDescriptor FileDescriptor;
typedef mozilla::ipc::PFileDescriptorSetChild PFileDescriptorSetChild;
@ -86,6 +91,7 @@ class ContentChild final : public PContentChild,
public:
NS_DECL_NSICONTENTCHILD
NS_DECL_NSIWINDOWPROVIDER
ContentChild();
virtual ~ContentChild();
@ -501,6 +507,8 @@ class ContentChild final : public PContentChild,
void GetAvailableDictionaries(nsTArray<nsString>& aDictionaries);
PBrowserOrId GetBrowserOrId(BrowserChild* aBrowserChild);
PWebrtcGlobalChild* AllocPWebrtcGlobalChild();
bool DeallocPWebrtcGlobalChild(PWebrtcGlobalChild* aActor);

View File

@ -1283,7 +1283,7 @@ already_AddRefed<RemoteBrowser> ContentParent::CreateBrowser(
cpm->RegisterRemoteFrame(browserParent);
nsCOMPtr<nsIPrincipal> initialPrincipal =
NullPrincipal::Create(aBrowsingContext->OriginAttributesRef());
NullPrincipal::Create(aContext.OriginAttributesRef());
WindowGlobalInit windowInit = WindowGlobalActor::AboutBlankInitializer(
aBrowsingContext, initialPrincipal);
@ -3160,7 +3160,8 @@ bool ContentParent::CanOpenBrowser(const IPCTabContext& aContext) {
// the app it's trying to open.)
// On e10s we also allow UnsafeTabContext to allow service workers to open
// windows. This is enforced in MaybeInvalidTabContext.
if (aContext.type() != IPCTabContext::TPopupIPCTabContext) {
if (aContext.type() != IPCTabContext::TPopupIPCTabContext &&
aContext.type() != IPCTabContext::TUnsafeIPCTabContext) {
ASSERT_UNLESS_FUZZING(
"Unexpected IPCTabContext type. Aborting AllocPBrowserParent.");
return false;
@ -3168,8 +3169,14 @@ bool ContentParent::CanOpenBrowser(const IPCTabContext& aContext) {
if (aContext.type() == IPCTabContext::TPopupIPCTabContext) {
const PopupIPCTabContext& popupContext = aContext.get_PopupIPCTabContext();
if (popupContext.opener().type() != PBrowserOrId::TPBrowserParent) {
ASSERT_UNLESS_FUZZING(
"Unexpected PopupIPCTabContext type. Aborting AllocPBrowserParent.");
return false;
}
auto opener = BrowserParent::GetFrom(popupContext.openerParent());
auto opener =
BrowserParent::GetFrom(popupContext.opener().get_PBrowserParent());
if (!opener) {
ASSERT_UNLESS_FUZZING(
"Got null opener from child; aborting AllocPBrowserParent.");
@ -3215,7 +3222,8 @@ mozilla::ipc::IPCResult ContentParent::RecvConstructPopupBrowser(
// type PopupIPCTabContext, and that the opener BrowserParent is
// reachable.
const PopupIPCTabContext& popupContext = aContext.get_PopupIPCTabContext();
auto opener = BrowserParent::GetFrom(popupContext.openerParent());
auto opener =
BrowserParent::GetFrom(popupContext.opener().get_PBrowserParent());
openerTabId = opener->GetTabId();
openerCpId = opener->Manager()->ChildID();
@ -3259,9 +3267,10 @@ mozilla::ipc::IPCResult ContentParent::RecvConstructPopupBrowser(
// XXX: Why are we checking these requirements? It seems we should register
// the created frame unconditionally?
if (openerTabId > 0) {
if (openerTabId > 0 ||
aContext.type() == IPCTabContext::TUnsafeIPCTabContext) {
// The creation of PBrowser was triggered from content process through
// window.open().
// either window.open() or service worker's openWindow().
// We need to register remote frame with the child generated tab id.
auto* cpm = ContentProcessManager::GetSingleton();
if (!cpm->RegisterRemoteFrame(parent)) {

View File

@ -0,0 +1,21 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=c: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBrowser;
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
namespace mozilla {
namespace dom {
union PBrowserOrId
{
nullable PBrowser;
TabId;
};
} // namespace dom
} // namespace mozilla

View File

@ -7,6 +7,7 @@
include "mozilla/dom/TabMessageUtils.h";
include protocol PBrowser;
include PBrowserOrId;
using UIStateChangeType from "nsPIDOMWindow.h";
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
@ -18,13 +19,16 @@ namespace dom {
// receives window.open().
struct PopupIPCTabContext
{
PBrowser opener;
PBrowserOrId opener;
uint64_t chromeOuterWindowID;
};
// 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.
@ -44,6 +48,13 @@ struct JSPluginFrameIPCTabContext
uint32_t jsPluginId;
};
// XXXcatalinb: This is only used by ServiceWorkerClients::OpenWindow.
// Because service workers don't have an associated BrowserChild
// we can't satisfy the security constraints on b2g. As such, the parent
// process will accept this tab context only on desktop.
struct UnsafeIPCTabContext
{ };
// IPCTabContext is an analog to mozilla::dom::TabContext. Both specify an
// iframe/PBrowser's own and containing app-ids and tell you whether the
// iframe/PBrowser is a browser frame. But only IPCTabContext is allowed to
@ -56,6 +67,7 @@ union IPCTabContext
PopupIPCTabContext;
FrameIPCTabContext;
JSPluginFrameIPCTabContext;
UnsafeIPCTabContext;
};
}

View File

@ -41,17 +41,33 @@ 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;
}
@ -60,12 +76,14 @@ 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;
@ -85,15 +103,16 @@ IPCTabContext TabContext::AsIPCTabContext() const {
return IPCTabContext(JSPluginFrameIPCTabContext(mJSPluginID));
}
return IPCTabContext(FrameIPCTabContext(mChromeOuterWindowID,
mPresentationURL, mShowFocusRings,
mMaxTouchPoints));
return IPCTabContext(
FrameIPCTabContext(mOriginAttributes, 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;
@ -103,17 +122,33 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
const PopupIPCTabContext& ipcContext = aParams.get_PopupIPCTabContext();
TabContext* context;
if (ipcContext.openerParent()) {
context = BrowserParent::GetFrom(ipcContext.openerParent());
} else if (ipcContext.openerChild()) {
context = static_cast<BrowserChild*>(ipcContext.openerChild());
if (ipcContext.opener().type() == PBrowserOrId::TPBrowserParent) {
context =
BrowserParent::GetFrom(ipcContext.opener().get_PBrowserParent());
if (!context) {
mInvalidReason =
"Child is-browser process tried to "
"open a null tab.";
return;
}
} else if (ipcContext.opener().type() == PBrowserOrId::TPBrowserChild) {
context =
static_cast<BrowserChild*>(ipcContext.opener().get_PBrowserChild());
} else if (ipcContext.opener().type() == PBrowserOrId::TTabId) {
// We should never get here because this PopupIPCTabContext is only
// used for allocating a new tab id, not for allocating a PBrowser.
mInvalidReason =
"Child process tried to open an tab without the opener "
"information.";
return;
} else {
// This should be unreachable because PopupIPCTabContext::opener is not
// a nullable field.
mInvalidReason = "PopupIPCTabContext::opener was null.";
mInvalidReason = "PopupIPCTabContext::opener was null (?!).";
return;
}
originAttributes = context->mOriginAttributes;
chromeOuterWindowID = ipcContext.chromeOuterWindowID();
break;
}
@ -130,9 +165,22 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
chromeOuterWindowID = ipcContext.chromeOuterWindowID();
presentationURL = ipcContext.presentationURL();
showFocusRings = ipcContext.showFocusRings();
originAttributes = ipcContext.originAttributes();
maxTouchPoints = ipcContext.maxTouchPoints();
break;
}
case IPCTabContext::TUnsafeIPCTabContext: {
// XXXcatalinb: This used *only* by ServiceWorkerClients::OpenWindow.
// It is meant as a temporary solution until service workers can
// provide a BrowserChild equivalent. Don't allow this on b2g since
// it might be used to escalate privileges.
if (!StaticPrefs::dom_serviceWorkers_enabled()) {
mInvalidReason = "ServiceWorkers should be enabled.";
return;
}
break;
}
default: {
MOZ_CRASH();
}
@ -143,7 +191,8 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
rv = mTabContext.SetTabContextForJSPluginFrame(jsPluginId);
} else {
rv = mTabContext.SetTabContext(chromeOuterWindowID, showFocusRings,
presentationURL, maxTouchPoints);
originAttributes, presentationURL,
maxTouchPoints);
}
if (!rv) {
mInvalidReason = "Couldn't initialize TabContext.";

View File

@ -44,6 +44,13 @@ 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
@ -71,8 +78,19 @@ 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);
@ -114,6 +132,11 @@ class TabContext {
int32_t mJSPluginID;
/**
* OriginAttributes of the top level tab docShell
*/
OriginAttributes mOriginAttributes;
/**
* The requested presentation URL.
*/
@ -143,15 +166,21 @@ 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,
aPresentationURL, aMaxTouchPoints);
aOriginAttributes, aPresentationURL,
aMaxTouchPoints);
}
bool SetTabContextForJSPluginFrame(uint32_t aJSPluginID) {
return TabContext::SetTabContextForJSPluginFrame(aJSPluginID);
}
void SetFirstPartyDomainAttributes(const nsAString& aFirstPartyDomain) {
TabContext::SetFirstPartyDomainAttributes(aFirstPartyDomain);
}
};
/**

View File

@ -160,6 +160,7 @@ PREPROCESSED_IPDL_SOURCES += [
IPDL_SOURCES += [
'DOMTypes.ipdlh',
'MemoryReportTypes.ipdlh',
'PBrowserOrId.ipdlh',
'PColorPicker.ipdl',
'PContentPermission.ipdlh',
'PContentPermissionRequest.ipdl',

View File

@ -127,8 +127,15 @@ bool NeckoChild::DeallocPAltDataOutputStreamChild(
return true;
}
already_AddRefed<PDocumentChannelChild> NeckoChild::AllocPDocumentChannelChild(
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
const DocumentChannelCreationArgs& args) {
MOZ_ASSERT_UNREACHABLE("AllocPDocumentChannelChild should not be called");
return nullptr;
}
PFTPChannelChild* NeckoChild::AllocPFTPChannelChild(
PBrowserChild* aBrowser, const SerializedLoadContext& aSerialized,
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
const FTPChannelCreationArgs& aOpenArgs) {
// We don't allocate here: see FTPChannelChild::AsyncOpen()
MOZ_CRASH("AllocPFTPChannelChild should not be called");
@ -159,7 +166,7 @@ bool NeckoChild::DeallocPCookieServiceChild(PCookieServiceChild* cs) {
}
PWebSocketChild* NeckoChild::AllocPWebSocketChild(
PBrowserChild* browser, const SerializedLoadContext& aSerialized,
const PBrowserOrId& browser, const SerializedLoadContext& aSerialized,
const uint32_t& aSerial) {
MOZ_ASSERT_UNREACHABLE("AllocPWebSocketChild should not be called");
return nullptr;

View File

@ -36,13 +36,17 @@ class NeckoChild : public PNeckoChild {
PHttpChannelChild* channel);
bool DeallocPAltDataOutputStreamChild(PAltDataOutputStreamChild* aActor);
already_AddRefed<PDocumentChannelChild> AllocPDocumentChannelChild(
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
const DocumentChannelCreationArgs& args);
PCookieServiceChild* AllocPCookieServiceChild();
bool DeallocPCookieServiceChild(PCookieServiceChild*);
PFTPChannelChild* AllocPFTPChannelChild(
PBrowserChild* aBrowser, const SerializedLoadContext& aSerialized,
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
const FTPChannelCreationArgs& aOpenArgs);
bool DeallocPFTPChannelChild(PFTPChannelChild*);
PWebSocketChild* AllocPWebSocketChild(PBrowserChild*,
PWebSocketChild* AllocPWebSocketChild(const PBrowserOrId&,
const SerializedLoadContext&,
const uint32_t&);
bool DeallocPWebSocketChild(PWebSocketChild*);

View File

@ -147,7 +147,7 @@ const char* NeckoParent::GetValidatedOriginAttributes(
}
const char* NeckoParent::CreateChannelLoadContext(
PBrowserParent* aBrowser, PContentParent* aContent,
const PBrowserOrId& aBrowser, PContentParent* aContent,
const SerializedLoadContext& aSerialized,
nsIPrincipal* aRequestingPrincipal, nsCOMPtr<nsILoadContext>& aResult) {
OriginAttributes attrs;
@ -162,13 +162,24 @@ const char* NeckoParent::CreateChannelLoadContext(
if (aSerialized.IsNotNull()) {
attrs.SyncAttributesWithPrivateBrowsing(
aSerialized.mOriginAttributes.mPrivateBrowsingId > 0);
RefPtr<BrowserParent> browserParent = BrowserParent::GetFrom(aBrowser);
dom::Element* topFrameElement = nullptr;
if (browserParent) {
topFrameElement = browserParent->GetOwnerElement();
switch (aBrowser.type()) {
case PBrowserOrId::TPBrowserParent: {
RefPtr<BrowserParent> browserParent =
BrowserParent::GetFrom(aBrowser.get_PBrowserParent());
dom::Element* topFrameElement = nullptr;
if (browserParent) {
topFrameElement = browserParent->GetOwnerElement();
}
aResult = new LoadContext(aSerialized, topFrameElement, attrs);
break;
}
case PBrowserOrId::TTabId: {
aResult = new LoadContext(aSerialized, nullptr, attrs);
break;
}
default:
MOZ_CRASH();
}
aResult = new LoadContext(aSerialized, topFrameElement, attrs);
}
return nullptr;
@ -180,7 +191,7 @@ void NeckoParent::ActorDestroy(ActorDestroyReason aWhy) {
}
already_AddRefed<PHttpChannelParent> NeckoParent::AllocPHttpChannelParent(
PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized,
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
const HttpChannelCreationArgs& aOpenArgs) {
nsCOMPtr<nsIPrincipal> requestingPrincipal =
GetRequestingPrincipal(aOpenArgs);
@ -197,13 +208,13 @@ already_AddRefed<PHttpChannelParent> NeckoParent::AllocPHttpChannelParent(
}
PBOverrideStatus overrideStatus =
PBOverrideStatusFromLoadContext(aSerialized);
RefPtr<HttpChannelParent> p = new HttpChannelParent(
BrowserParent::GetFrom(aBrowser), loadContext, overrideStatus);
RefPtr<HttpChannelParent> p =
new HttpChannelParent(aBrowser, loadContext, overrideStatus);
return p.forget();
}
mozilla::ipc::IPCResult NeckoParent::RecvPHttpChannelConstructor(
PHttpChannelParent* aActor, PBrowserParent* aBrowser,
PHttpChannelParent* aActor, const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const HttpChannelCreationArgs& aOpenArgs) {
HttpChannelParent* p = static_cast<HttpChannelParent*>(aActor);
@ -276,7 +287,7 @@ bool NeckoParent::DeallocPAltDataOutputStreamParent(
}
PFTPChannelParent* NeckoParent::AllocPFTPChannelParent(
PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized,
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
const FTPChannelCreationArgs& aOpenArgs) {
nsCOMPtr<nsIPrincipal> requestingPrincipal =
GetRequestingPrincipal(aOpenArgs);
@ -293,8 +304,8 @@ PFTPChannelParent* NeckoParent::AllocPFTPChannelParent(
}
PBOverrideStatus overrideStatus =
PBOverrideStatusFromLoadContext(aSerialized);
FTPChannelParent* p = new FTPChannelParent(BrowserParent::GetFrom(aBrowser),
loadContext, overrideStatus);
FTPChannelParent* p =
new FTPChannelParent(aBrowser, loadContext, overrideStatus);
p->AddRef();
return p;
}
@ -306,7 +317,7 @@ bool NeckoParent::DeallocPFTPChannelParent(PFTPChannelParent* channel) {
}
mozilla::ipc::IPCResult NeckoParent::RecvPFTPChannelConstructor(
PFTPChannelParent* aActor, PBrowserParent* aBrowser,
PFTPChannelParent* aActor, const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const FTPChannelCreationArgs& aOpenArgs) {
FTPChannelParent* p = static_cast<FTPChannelParent*>(aActor);
@ -351,7 +362,7 @@ bool NeckoParent::DeallocPCookieServiceParent(PCookieServiceParent* cs) {
}
PWebSocketParent* NeckoParent::AllocPWebSocketParent(
PBrowserParent* browser, const SerializedLoadContext& serialized,
const PBrowserOrId& browser, const SerializedLoadContext& serialized,
const uint32_t& aSerial) {
nsCOMPtr<nsILoadContext> loadContext;
const char* error = CreateChannelLoadContext(browser, Manager(), serialized,
@ -364,7 +375,8 @@ PWebSocketParent* NeckoParent::AllocPWebSocketParent(
return nullptr;
}
RefPtr<BrowserParent> browserParent = BrowserParent::GetFrom(browser);
RefPtr<BrowserParent> browserParent =
BrowserParent::GetFrom(browser.get_PBrowserParent());
PBOverrideStatus overrideStatus = PBOverrideStatusFromLoadContext(serialized);
WebSocketChannelParent* p = new WebSocketChannelParent(
browserParent, loadContext, overrideStatus, aSerial);

View File

@ -45,7 +45,7 @@ class NeckoParent : public PNeckoParent {
* Returns null if successful, or an error string if failed.
*/
[[nodiscard]] static const char* CreateChannelLoadContext(
PBrowserParent* aBrowser, PContentParent* aContent,
const PBrowserOrId& aBrowser, PContentParent* aContent,
const SerializedLoadContext& aSerialized,
nsIPrincipal* aRequestingPrincipal, nsCOMPtr<nsILoadContext>& aResult);
@ -90,10 +90,10 @@ class NeckoParent : public PNeckoParent {
bool mSocketProcessBridgeInited;
already_AddRefed<PHttpChannelParent> AllocPHttpChannelParent(
PBrowserParent*, const SerializedLoadContext&,
const PBrowserOrId&, const SerializedLoadContext&,
const HttpChannelCreationArgs& aOpenArgs);
virtual mozilla::ipc::IPCResult RecvPHttpChannelConstructor(
PHttpChannelParent* aActor, PBrowserParent* aBrowser,
PHttpChannelParent* aActor, const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const HttpChannelCreationArgs& aOpenArgs) override;
@ -111,15 +111,15 @@ class NeckoParent : public PNeckoParent {
bool DeallocPCookieServiceParent(PCookieServiceParent*);
PFTPChannelParent* AllocPFTPChannelParent(
PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized,
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
const FTPChannelCreationArgs& aOpenArgs);
virtual mozilla::ipc::IPCResult RecvPFTPChannelConstructor(
PFTPChannelParent* aActor, PBrowserParent* aBrowser,
PFTPChannelParent* aActor, const PBrowserOrId& aBrowser,
const SerializedLoadContext& aSerialized,
const FTPChannelCreationArgs& aOpenArgs) override;
bool DeallocPFTPChannelParent(PFTPChannelParent*);
PWebSocketParent* AllocPWebSocketParent(
PBrowserParent* browser, const SerializedLoadContext& aSerialized,
const PBrowserOrId& browser, const SerializedLoadContext& aSerialized,
const uint32_t& aSerial);
bool DeallocPWebSocketParent(PWebSocketParent*);
PTCPSocketParent* AllocPTCPSocketParent(const nsString& host,

View File

@ -32,6 +32,7 @@ include protocol PDocumentChannel;
include IPCStream;
include NeckoChannelParams;
include PBrowserOrId;
include protocol PAltDataOutputStream;
using mozilla::dom::MaybeDiscardedBrowsingContext from "mozilla/dom/BrowsingContext.h";
@ -73,13 +74,13 @@ parent:
async __delete__();
nested(inside_cpow) async PCookieService();
async PHttpChannel(nullable PBrowser browser,
async PHttpChannel(PBrowserOrId browser,
SerializedLoadContext loadContext,
HttpChannelCreationArgs args);
async PFTPChannel(nullable PBrowser browser, SerializedLoadContext loadContext,
async PFTPChannel(PBrowserOrId browser, SerializedLoadContext loadContext,
FTPChannelCreationArgs args);
async PWebSocket(nullable PBrowser browser, SerializedLoadContext loadContext,
async PWebSocket(PBrowserOrId browser, SerializedLoadContext loadContext,
uint32_t aSerialID);
async PTCPServerSocket(uint16_t localPort, uint16_t backlog, bool useArrayBuffers);
async PUDPSocket(nsIPrincipal principal, nsCString filter);

View File

@ -19,11 +19,11 @@ include protocol PAltSvcTransaction;
include MemoryReportTypes;
include NeckoChannelParams;
include PBrowserOrId;
include PrefsTypes;
include PSMIPCTypes;
using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::Telemetry::HistogramAccumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedHistogramAccumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::ScalarAction from "mozilla/TelemetryComms.h";

View File

@ -36,7 +36,7 @@ using namespace mozilla::ipc;
namespace mozilla {
namespace net {
FTPChannelParent::FTPChannelParent(dom::BrowserParent* aIframeEmbedding,
FTPChannelParent::FTPChannelParent(const PBrowserOrId& aIframeEmbedding,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus)
: mIPCClosed(false),
@ -46,12 +46,16 @@ FTPChannelParent::FTPChannelParent(dom::BrowserParent* aIframeEmbedding,
mDivertingFromChild(false),
mDivertedOnStartRequest(false),
mSuspendedForDiversion(false),
mBrowserParent(aIframeEmbedding),
mUseUTF8(false) {
nsIProtocolHandler* handler;
CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ftp", &handler);
MOZ_ASSERT(handler, "no ftp handler");
if (aIframeEmbedding.type() == PBrowserOrId::TPBrowserParent) {
mBrowserParent =
static_cast<dom::BrowserParent*>(aIframeEmbedding.get_PBrowserParent());
}
mEventQ = new ChannelEventQueue(static_cast<nsIParentChannel*>(this));
}

View File

@ -22,6 +22,7 @@ namespace mozilla {
namespace dom {
class BrowserParent;
class PBrowserOrId;
} // namespace dom
namespace net {
@ -41,7 +42,7 @@ class FTPChannelParent final : public PFTPChannelParent,
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSICHANNELEVENTSINK
FTPChannelParent(dom::BrowserParent* aIframeEmbedding,
FTPChannelParent(const dom::PBrowserOrId& aIframeEmbedding,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus);

View File

@ -2054,8 +2054,10 @@ HttpChannelChild::ConnectParent(uint32_t registrarId) {
SetEventTarget();
HttpChannelConnectArgs connectArgs(registrarId, mShouldParentIntercept);
PBrowserOrId browser = static_cast<ContentChild*>(gNeckoChild->Manager())
->GetBrowserOrId(browserChild);
if (!gNeckoChild->SendPHttpChannelConstructor(
this, browserChild, IPC::SerializedLoadContext(this), connectArgs)) {
this, browser, IPC::SerializedLoadContext(this), connectArgs)) {
return NS_ERROR_FAILURE;
}
@ -2796,8 +2798,9 @@ nsresult HttpChannelChild::ContinueAsyncOpen() {
// target.
SetEventTarget();
PBrowserOrId browser = cc->GetBrowserOrId(browserChild);
if (!gNeckoChild->SendPHttpChannelConstructor(
this, browserChild, IPC::SerializedLoadContext(this), openArgs)) {
this, browser, IPC::SerializedLoadContext(this), openArgs)) {
return NS_ERROR_FAILURE;
}

View File

@ -63,10 +63,11 @@ using namespace mozilla::ipc;
namespace mozilla {
namespace net {
HttpChannelParent::HttpChannelParent(dom::BrowserParent* iframeEmbedding,
HttpChannelParent::HttpChannelParent(const PBrowserOrId& iframeEmbedding,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus)
: mLoadContext(aLoadContext),
mNestedFrameId(0),
mIPCClosed(false),
mPBOverride(aOverrideStatus),
mStatus(NS_OK),
@ -93,7 +94,12 @@ HttpChannelParent::HttpChannelParent(dom::BrowserParent* iframeEmbedding,
MOZ_ASSERT(gHttpHandler);
mHttpHandler = gHttpHandler;
mBrowserParent = iframeEmbedding;
if (iframeEmbedding.type() == PBrowserOrId::TPBrowserParent) {
mBrowserParent =
static_cast<dom::BrowserParent*>(iframeEmbedding.get_PBrowserParent());
} else {
mNestedFrameId = iframeEmbedding.get_TabId();
}
mSendWindowSize = gHttpHandler->SendWindowSize();
@ -2444,7 +2450,7 @@ NS_IMETHODIMP
HttpChannelParent::GetAuthPrompt(uint32_t aPromptReason, const nsIID& iid,
void** aResult) {
nsCOMPtr<nsIAuthPrompt2> prompt =
new NeckoParent::NestedFrameAuthPrompt(Manager(), TabId(0));
new NeckoParent::NestedFrameAuthPrompt(Manager(), mNestedFrameId);
prompt.forget(aResult);
return NS_OK;
}

View File

@ -37,6 +37,7 @@ namespace mozilla {
namespace dom {
class BrowserParent;
class PBrowserOrId;
} // namespace dom
namespace net {
@ -80,7 +81,7 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
NS_DECLARE_STATIC_IID_ACCESSOR(HTTP_CHANNEL_PARENT_IID)
HttpChannelParent(dom::BrowserParent* iframeEmbedding,
HttpChannelParent(const dom::PBrowserOrId& iframeEmbedding,
nsILoadContext* aLoadContext, PBOverrideStatus aStatus);
[[nodiscard]] bool Init(const HttpChannelCreationArgs& aOpenArgs);
@ -301,6 +302,8 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
MozPromiseHolder<GenericNonExclusivePromise> mPromise;
MozPromiseRequestHolder<GenericNonExclusivePromise> mRequest;
dom::TabId mNestedFrameId;
// To calculate the delay caused by the e10s back-pressure suspension
TimeStamp mResumedTimestamp;

View File

@ -97,6 +97,7 @@ nsIWidget* nsWebBrowser::EnsureWidget() {
/* static */
already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget,
const OriginAttributes& aOriginAttributes,
dom::BrowsingContext* aBrowsingContext,
dom::WindowGlobalChild* aInitialWindowChild,
bool aDisableHistory /* = false */) {
@ -123,6 +124,7 @@ already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
if (NS_WARN_IF(!docShell)) {
return nullptr;
}
MOZ_ASSERT(aBrowsingContext->OriginAttributesRef() == aOriginAttributes);
browser->SetDocShell(docShell);
// get the system default window background colour

View File

@ -108,6 +108,7 @@ class nsWebBrowser final : public nsIWebBrowser,
static already_AddRefed<nsWebBrowser> Create(
nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget,
const mozilla::OriginAttributes& aOriginAttributes,
mozilla::dom::BrowsingContext* aBrowsingContext,
mozilla::dom::WindowGlobalChild* aInitialWindowChild,
bool aDisableHistory = false);

View File

@ -831,6 +831,10 @@ nsresult nsWindowWatcher::OpenWindowInternal(
nsCOMPtr<nsIWindowProvider> provider;
if (parentTreeOwner) {
provider = do_GetInterface(parentTreeOwner);
} else if (XRE_IsContentProcess()) {
// we're in a content process but we don't have a tabchild we can
// use.
provider = nsContentUtils::GetWindowProviderForContentProcess();
}
if (provider) {

View File

@ -457,8 +457,8 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome,
* an associated doc shell, which is what we're interested in.
*/
nsCOMPtr<nsIWebBrowser> browser = nsWebBrowser::Create(
stub, widget, browsingContext, nullptr /* initialWindowChild */,
true /* disable history */);
stub, widget, OriginAttributes(), browsingContext,
nullptr /* initialWindowChild */, true /* disable history */);
if (NS_WARN_IF(!browser)) {
NS_ERROR("Couldn't create instance of nsWebBrowser!");