From 2310b3bd3977eb7e4fa070acccfd2286ed18e16d Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Mon, 29 May 2017 12:38:46 +0200 Subject: [PATCH] Bug 558184 - Part 8 - Load js plugins in a separate process. r=billm. Every JS plugin is assigned a unique ID. When an instance of a JS plugin is created the frame loader that we use to load the plugin's handler URI will create a special TabContext. This TabContext causes the ContentParent to use the process for this specific JS plugin (creating one if it hasn't already) when it creates the PBrowser actors. This causes the iframes for all the instances of a specific JS plugin to be grouped in the same process. --HG-- extra : rebase_source : c39560bdf66cda1a005c7b823b3a46e4734878a4 extra : source : 9cba1db527c7eed4371c9f4caf96fd942608cab6 --- dom/base/nsFrameLoader.cpp | 33 +++++- dom/base/nsFrameLoader.h | 14 ++- dom/base/nsObjectLoadingContent.cpp | 83 +++++++------- dom/base/nsObjectLoadingContent.h | 4 +- dom/events/EventStateManager.cpp | 23 +--- dom/ipc/ContentBridgeParent.cpp | 1 + dom/ipc/ContentBridgeParent.h | 10 ++ dom/ipc/ContentParent.cpp | 163 +++++++++++++++++++++------- dom/ipc/ContentParent.h | 36 +++++- dom/ipc/PContent.ipdl | 2 +- dom/ipc/PTabContext.ipdlh | 6 + dom/ipc/TabContext.cpp | 52 +++++++-- dom/ipc/TabContext.h | 19 ++++ dom/ipc/nsIContentParent.h | 1 + dom/plugins/base/nsIPluginTag.idl | 5 + dom/plugins/base/nsPluginTags.cpp | 8 ++ dom/plugins/base/nsPluginTags.h | 3 + layout/ipc/RenderFrameParent.cpp | 3 +- 18 files changed, 351 insertions(+), 115 deletions(-) diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index fe1fbcbab757..dfe77e75c83f 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -156,12 +156,14 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameLoader) NS_INTERFACE_MAP_ENTRY(nsIWebBrowserPersistable) NS_INTERFACE_MAP_END -nsFrameLoader::nsFrameLoader(Element* aOwner, nsPIDOMWindowOuter* aOpener, bool aNetworkCreated) +nsFrameLoader::nsFrameLoader(Element* aOwner, nsPIDOMWindowOuter* aOpener, + bool aNetworkCreated, int32_t aJSPluginID) : mOwnerContent(aOwner) , mDetachedSubdocFrame(nullptr) , mOpener(aOpener) , mRemoteBrowser(nullptr) , mChildID(0) + , mJSPluginID(aJSPluginID) , mEventMode(EVENT_MODE_NORMAL_DISPATCH) , mBrowserChangingProcessBlockers(nullptr) , mIsPrerendered(false) @@ -193,7 +195,8 @@ nsFrameLoader::~nsFrameLoader() } nsFrameLoader* -nsFrameLoader::Create(Element* aOwner, nsPIDOMWindowOuter* aOpener, bool aNetworkCreated) +nsFrameLoader::Create(Element* aOwner, nsPIDOMWindowOuter* aOpener, bool aNetworkCreated, + int32_t aJSPluginId) { NS_ENSURE_TRUE(aOwner, nullptr); nsIDocument* doc = aOwner->OwnerDoc(); @@ -223,7 +226,7 @@ nsFrameLoader::Create(Element* aOwner, nsPIDOMWindowOuter* aOpener, bool aNetwor doc->IsStaticDocument()), nullptr); - return new nsFrameLoader(aOwner, aOpener, aNetworkCreated); + return new nsFrameLoader(aOwner, aOpener, aNetworkCreated, aJSPluginId); } NS_IMETHODIMP @@ -314,8 +317,15 @@ nsFrameLoader::LoadURI(nsIURI* aURI) nsCOMPtr doc = mOwnerContent->OwnerDoc(); - nsresult rv = CheckURILoad(aURI); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv; + // If IsForJSPlugin() returns true then we want to allow the load. We're just + // loading the source for the implementation of the JS plugin from a URI + // that's under our control. We will already have done the security checks for + // loading the plugin content itself in the object/embed loading code. + if (!IsForJSPlugin()) { + rv = CheckURILoad(aURI); + NS_ENSURE_SUCCESS(rv, rv); + } mURIToLoad = aURI; rv = doc->InitializeFrameLoader(this); @@ -2246,6 +2256,10 @@ nsFrameLoader::OwnerIsIsolatedMozBrowserFrame() bool nsFrameLoader::ShouldUseRemoteProcess() { + if (IsForJSPlugin()) { + return true; + } + if (PR_GetEnv("MOZ_DISABLE_OOP_TABS") || Preferences::GetBool("dom.ipc.tabs.disabled", false)) { return false; @@ -2910,7 +2924,9 @@ nsFrameLoader::TryRemoteBrowser() } //