diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 17badf3847da..4dfd4b9a4234 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3241,7 +3241,6 @@ async function BrowserViewSourceOfDocument(args) { skipAnimation: inNewWindow, preferredRemoteType, initialBrowsingContextGroupId, - sameProcessAsFrameLoader: args.browser ? args.browser.frameLoader : null, triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), }); args.viewSourceBrowser = tabBrowser.getBrowserForTab(tab); @@ -3630,7 +3629,6 @@ var PrintPreviewListener = { inBackground: true, preferredRemoteType, initialBrowsingContextGroupId, - sameProcessAsFrameLoader: browser.frameLoader, triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), }); }, @@ -3660,7 +3658,6 @@ var PrintPreviewListener = { inBackground: true, preferredRemoteType, initialBrowsingContextGroupId, - sameProcessAsFrameLoader: browser.frameLoader, triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), }); return this.getSimplifiedSourceBrowser(); diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index f142e9e0ca66..ae2a69db970d 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -317,20 +317,20 @@ let tabArgument = gBrowserInit.getTabToAdopt(); - // We only need sameProcessAsFrameLoader in the case where we're passed a tab - let initialBrowsingContextGroupId; - let sameProcessAsFrameLoader; // If we have a tab argument with browser, we use its remoteType. Otherwise, // if e10s is disabled or there's a parent process opener (e.g. parent // process about: page) for the content tab, we use a parent // process remoteType. Otherwise, we check the URI to determine // what to do - if there isn't one, we default to the default remote type. + // + // When adopting a tab, we'll also use that tab's browsingContextGroupId, + // if available, to ensure we don't spawn a new process. let remoteType; + let initialBrowsingContextGroupId; if (tabArgument && tabArgument.linkedBrowser) { remoteType = tabArgument.linkedBrowser.remoteType; initialBrowsingContextGroupId = tabArgument.linkedBrowser.browsingContext?.group.id; - sameProcessAsFrameLoader = tabArgument.linkedBrowser.frameLoader; } else if (openWindowInfo) { userContextId = openWindowInfo.originAttributes.userContextId; if (openWindowInfo.isRemote) { @@ -366,7 +366,6 @@ let createOptions = { uriIsAboutBlank: false, userContextId, - sameProcessAsFrameLoader, initialBrowsingContextGroupId, remoteType, openWindowInfo, @@ -1583,7 +1582,6 @@ aForceNotRemote = params.forceNotRemote; aPreferredRemoteType = params.preferredRemoteType; aUserContextId = params.userContextId; - aSameProcessAsFrameLoader = params.sameProcessAsFrameLoader; aInitialBrowsingContextGroupId = params.initialBrowsingContextGroupId; aOriginPrincipal = params.originPrincipal; aOriginStoragePrincipal = params.originStoragePrincipal; @@ -1627,7 +1625,6 @@ userContextId: aUserContextId, originPrincipal: aOriginPrincipal, originStoragePrincipal: aOriginStoragePrincipal, - sameProcessAsFrameLoader: aSameProcessAsFrameLoader, initialBrowsingContextGroupId: aInitialBrowsingContextGroupId, openWindowInfo: aOpenWindowInfo, openerBrowser: aOpenerBrowser, @@ -1821,7 +1818,6 @@ listener.destroy(); let oldDroppedLinkHandler = aBrowser.droppedLinkHandler; - let oldSameProcessAsFrameLoader = aBrowser.sameProcessAsFrameLoader; let oldUserTypedValue = aBrowser.userTypedValue; let hadStartedLoad = aBrowser.didStartLoadSinceLastUserTyping(); @@ -1830,14 +1826,6 @@ // Make sure the browser is destroyed so it unregisters from observer notifications aBrowser.destroy(); - // NB: This works with the hack in the browser constructor that - // turns this normal property into a field. - if (!shouldBeRemote || oldRemoteType == remoteType) { - // Only copy existing sameProcessAsFrameLoader when not switching - // remote type otherwise it would stop the switch. - aBrowser.sameProcessAsFrameLoader = oldSameProcessAsFrameLoader; - } - if (shouldBeRemote) { aBrowser.setAttribute("remote", "true"); aBrowser.setAttribute("remoteType", remoteType); @@ -1971,7 +1959,6 @@ name, openWindowInfo, remoteType, - sameProcessAsFrameLoader, initialBrowsingContextGroupId, uriIsAboutBlank, userContextId, @@ -2033,10 +2020,6 @@ b.setAttribute("preloadedState", "preloaded"); } - if (sameProcessAsFrameLoader) { - b.sameProcessAsFrameLoader = sameProcessAsFrameLoader; - } - // Ensure that the browser will be created in a specific initial // BrowsingContextGroup. This may change the process selection behaviour // of the newly created browser, and is often used in combination with @@ -2458,7 +2441,6 @@ preferredRemoteType, referrerInfo, relatedToCurrent, - sameProcessAsFrameLoader, initialBrowsingContextGroupId, skipAnimation, skipBackgroundNotify, @@ -2633,10 +2615,6 @@ gFissionBrowser, preferredRemoteType ); - if (sameProcessAsFrameLoader) { - remoteType = - sameProcessAsFrameLoader.browsingContext.currentRemoteType; - } // If we open a new tab with the newtab URL in the default // userContext, check if there is a preloaded browser ready. @@ -2653,7 +2631,6 @@ remoteType, uriIsAboutBlank, userContextId, - sameProcessAsFrameLoader, initialBrowsingContextGroupId, openWindowInfo, name, @@ -4439,7 +4416,6 @@ let params = { eventDetail: { adoptedTab: aTab }, preferredRemoteType: linkedBrowser.remoteType, - sameProcessAsFrameLoader: linkedBrowser.frameLoader, initialBrowsingContextGroupId: linkedBrowser.browsingContext?.group.id, skipAnimation: true, index: aIndex, diff --git a/browser/base/content/webext-panels.js b/browser/base/content/webext-panels.js index c3cfee371061..b09747bf92f1 100644 --- a/browser/base/content/webext-panels.js +++ b/browser/base/content/webext-panels.js @@ -50,7 +50,6 @@ function getBrowser(panel) { "initialBrowsingContextGroupId", panel.extension.policy.browsingContextGroupId ); - browser.sameProcessAsFrameLoader = panel.extension.groupFrameLoader; let readyPromise; if (panel.extension.remote) { diff --git a/browser/components/extensions/ExtensionPopups.jsm b/browser/components/extensions/ExtensionPopups.jsm index 8e6ccc312a21..eddb3969a349 100644 --- a/browser/components/extensions/ExtensionPopups.jsm +++ b/browser/components/extensions/ExtensionPopups.jsm @@ -290,7 +290,6 @@ class BasePopup { "initialBrowsingContextGroupId", this.extension.policy.browsingContextGroupId ); - browser.sameProcessAsFrameLoader = this.extension.groupFrameLoader; if (this.extension.remote) { browser.setAttribute("remote", "true"); diff --git a/browser/components/sessionstore/test/browser_crashedTabs.js b/browser/components/sessionstore/test/browser_crashedTabs.js index c31445ea0af1..1ddb45fac46a 100644 --- a/browser/components/sessionstore/test/browser_crashedTabs.js +++ b/browser/components/sessionstore/test/browser_crashedTabs.js @@ -235,7 +235,6 @@ add_task(async function test_revive_tab_from_session_store() { await promiseBrowserLoaded(browser); let newTab2 = BrowserTestUtils.addTab(gBrowser, "about:blank", { - sameProcessAsFrameLoader: browser.frameLoader, remoteType: browser.remoteType, initialBrowsingContextGroupId: browser.browsingContext.group.id, }); @@ -300,7 +299,6 @@ add_task(async function test_revive_all_tabs_from_session_store() { // about:tabcrashed. let win2 = await BrowserTestUtils.openNewBrowserWindow(); let newTab2 = BrowserTestUtils.addTab(win2.gBrowser, PAGE_1, { - sameProcessAsFrameLoader: browser.frameLoader, remoteType: browser.remoteType, initialBrowsingContextGroupId: browser.browsingContext.group.id, }); @@ -431,7 +429,6 @@ add_task(async function test_hide_restore_all_button() { // about:tabcrashed let win2 = await BrowserTestUtils.openNewBrowserWindow(); let newTab3 = BrowserTestUtils.addTab(win2.gBrowser, PAGE_2, { - sameProcessAsFrameLoader: browser.frameLoader, remoteType: browser.remoteType, initialBrowsingContextGroupId: browser.browsingContext.group.id, }); diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 90fed5881b2c..058f0a355398 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -351,49 +351,6 @@ static bool InitialLoadIsRemote(Element* aOwner) { nsGkAtoms::_true, eCaseMatters); } -static void GetInitialRemoteTypeAndProcess(Element* aOwner, - nsACString& aRemoteType, - uint64_t* aChildID) { - MOZ_ASSERT(XRE_IsParentProcess()); - *aChildID = 0; - - // Check if there is an explicit `remoteType` attribute which we should use. - nsAutoString remoteType; - bool hasRemoteType = - aOwner->GetAttr(kNameSpaceID_None, nsGkAtoms::RemoteType, remoteType); - if (!hasRemoteType || remoteType.IsEmpty()) { - hasRemoteType = false; - aRemoteType = DEFAULT_REMOTE_TYPE; - } else { - aRemoteType = NS_ConvertUTF16toUTF8(remoteType); - } - - // Check if `sameProcessAsFrameLoader` was used to override the process. - nsCOMPtr browser = aOwner->AsBrowser(); - if (!browser) { - return; - } - RefPtr otherLoader; - browser->GetSameProcessAsFrameLoader(getter_AddRefs(otherLoader)); - if (!otherLoader) { - return; - } - BrowserParent* browserParent = BrowserParent::GetFrom(otherLoader); - if (!browserParent) { - return; - } - RefPtr contentParent = browserParent->Manager(); - - // NOTE: This assertion is known to fail in the wild. It is being kept around - // only to ensure that we don't land and test new code which breaks this - // desired invariant. (bug 1646328) - MOZ_ASSERT(!hasRemoteType || contentParent->GetRemoteType() == aRemoteType, - "If specified, remoteType attribute should match " - "sameProcessAsFrameLoader"); - aRemoteType = contentParent->GetRemoteType(); - *aChildID = contentParent->ChildID(); -} - static already_AddRefed InitialBrowsingContextGroup( Element* aOwner) { nsAutoString attrString; @@ -454,8 +411,20 @@ already_AddRefed nsFrameLoader::Create( RefPtr fl = new nsFrameLoader(aOwner, context, isRemoteFrame, aNetworkCreated); fl->mOpenWindowInfo = aOpenWindowInfo; + + // If this is a toplevel initial remote frame, we're looking at a browser + // loaded in the parent process. Pull the remote type attribute off of the + // element to determine which remote type it should be loaded in, or + // use `DEFAULT_REMOTE_TYPE` if we can't tell. if (isRemoteFrame) { - GetInitialRemoteTypeAndProcess(aOwner, fl->mRemoteType, &fl->mChildID); + MOZ_ASSERT(XRE_IsParentProcess()); + nsAutoString remoteType; + if (aOwner->GetAttr(kNameSpaceID_None, nsGkAtoms::RemoteType, remoteType) && + !remoteType.IsEmpty()) { + CopyUTF16toUTF8(remoteType, fl->mRemoteType); + } else { + fl->mRemoteType = DEFAULT_REMOTE_TYPE; + } } return fl.forget(); } diff --git a/dom/interfaces/base/nsIBrowser.idl b/dom/interfaces/base/nsIBrowser.idl index b6402ffc687a..d6df6411e97a 100644 --- a/dom/interfaces/base/nsIBrowser.idl +++ b/dom/interfaces/base/nsIBrowser.idl @@ -11,20 +11,9 @@ interface nsIWebProgress; interface nsIReferrerInfo; interface nsIOpenWindowInfo; -webidl FrameLoader; - [scriptable, uuid(14e5a0cb-e223-4202-95e8-fe53275193ea)] interface nsIBrowser : nsISupports { - /** - * Gets an optional frame loader that is "related" to this browser. - * If this exists, then we should attempt to use the same content parent as - * this frame loader for any new remote tabs. For example, view source - * browsers set this to the frame loader for the original content to ensure - * they are loaded in the same process as the content. - */ - readonly attribute FrameLoader sameProcessAsFrameLoader; - /* * Called by the child to inform the parent that links are dropped into * content area. diff --git a/toolkit/components/extensions/ExtensionParent.jsm b/toolkit/components/extensions/ExtensionParent.jsm index 839715a8ad50..fc21d41aa259 100644 --- a/toolkit/components/extensions/ExtensionParent.jsm +++ b/toolkit/components/extensions/ExtensionParent.jsm @@ -1158,14 +1158,11 @@ class HiddenXULWindow { * @param {Object} xulAttributes * An object that contains the xul attributes to set of the newly * created browser XUL element. - * @param {FrameLoader} [groupFrameLoader] - * The frame loader to load this browser into the same process - * and tab group as. * * @returns {Promise} * A Promise which resolves to the newly created browser XUL element. */ - async createBrowserElement(xulAttributes, groupFrameLoader = null) { + async createBrowserElement(xulAttributes) { if (!xulAttributes || Object.keys(xulAttributes).length === 0) { throw new Error("missing mandatory xulAttributes parameter"); } @@ -1178,10 +1175,6 @@ class HiddenXULWindow { browser.setAttribute("type", "content"); browser.setAttribute("disableglobalhistory", "true"); - // NOTE: This can be removed once all callers pass - // `initialBrowsingContextGroupId`. - browser.sameProcessAsFrameLoader = groupFrameLoader; - for (const [name, value] of Object.entries(xulAttributes)) { if (value != null) { browser.setAttribute(name, value); @@ -1299,15 +1292,12 @@ class HiddenExtensionPage { let window = SharedWindow.acquire(); try { - this.browser = await window.createBrowserElement( - { - "webextension-view-type": this.viewType, - remote: this.extension.remote ? "true" : null, - remoteType: this.extension.remoteType, - initialBrowsingContextGroupId: this.extension.browsingContextGroupId, - }, - this.extension.groupFrameLoader - ); + this.browser = await window.createBrowserElement({ + "webextension-view-type": this.viewType, + remote: this.extension.remote ? "true" : null, + remoteType: this.extension.remoteType, + initialBrowsingContextGroupId: this.extension.browsingContextGroupId, + }); } catch (e) { SharedWindow.release(); throw e; @@ -1399,15 +1389,12 @@ const DebugUtils = { this.watchExtensionUpdated(); } - return this.hiddenXULWindow.createBrowserElement( - { - "webextension-addon-debug-target": extensionId, - remote: extension.remote ? "true" : null, - remoteType: extension.remoteType, - initialBrowsingContextGroupId: extension.browsingContextGroupId, - }, - extension.groupFrameLoader - ); + return this.hiddenXULWindow.createBrowserElement({ + "webextension-addon-debug-target": extensionId, + remote: extension.remote ? "true" : null, + remoteType: extension.remoteType, + initialBrowsingContextGroupId: extension.browsingContextGroupId, + }); }; let browserPromise = this.debugBrowserPromises.get(extensionId); diff --git a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm index c51892a86faa..e14244d9c4fc 100644 --- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm +++ b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm @@ -258,7 +258,6 @@ class ContentPage { if (this.extension?.remote) { browser.setAttribute("remote", "true"); browser.setAttribute("remoteType", "extension"); - browser.sameProcessAsFrameLoader = this.extension.groupFrameLoader; } // Ensure that the extension is loaded into the correct diff --git a/toolkit/components/pictureinpicture/content/player.js b/toolkit/components/pictureinpicture/content/player.js index a6f793629471..f356a3af6996 100644 --- a/toolkit/components/pictureinpicture/content/player.js +++ b/toolkit/components/pictureinpicture/content/player.js @@ -122,7 +122,6 @@ let Player = { "initialBrowsingContextGroupId", originatingBrowser.browsingContext.group.id ); - browser.sameProcessAsFrameLoader = originatingBrowser.frameLoader; holder.appendChild(browser); this.actor = browser.browsingContext.currentWindowGlobal.getActor( diff --git a/toolkit/components/printing/content/printUtils.js b/toolkit/components/printing/content/printUtils.js index 6c9acc45aa94..71ec356114b0 100644 --- a/toolkit/components/printing/content/printUtils.js +++ b/toolkit/components/printing/content/printUtils.js @@ -160,7 +160,6 @@ var PrintUtils = { let sourceBrowser = aBrowsingContext.embedderElement; let printPreviewBrowser = gBrowser.createBrowser({ remoteType: sourceBrowser.remoteType, - sameProcessAsFrameLoader: sourceBrowser.frameLoader, initialBrowsingContextGroupId: aBrowsingContext.group.id, skipLoad: false, }); diff --git a/toolkit/components/viewsource/content/viewSourceUtils.js b/toolkit/components/viewsource/content/viewSourceUtils.js index 6521f3238adc..0c1efd4d09e5 100644 --- a/toolkit/components/viewsource/content/viewSourceUtils.js +++ b/toolkit/components/viewsource/content/viewSourceUtils.js @@ -118,15 +118,6 @@ var gViewSourceUtils = { } if (browser) { - // XXX(nika): I am pretty sure this does absolutely nothing. I don't think - // that this will correctly ensure that the browser is loaded in the same - // process as the URL it's viewing the source of. - // - // The callers of this function should probably be updated to make sure to - // create the browser with the correct settings so it's already in the - // correct process. - viewSourceBrowser.sameProcessAsFrameLoader = browser.frameLoader; - // If we're dealing with a remote browser, then the browser // for view source needs to be remote as well. if (viewSourceBrowser.remoteType != browser.remoteType) { diff --git a/toolkit/content/widgets/browser-custom-element.js b/toolkit/content/widgets/browser-custom-element.js index 96079c2a0c3c..cbfebf97cf22 100644 --- a/toolkit/content/widgets/browser-custom-element.js +++ b/toolkit/content/widgets/browser-custom-element.js @@ -207,19 +207,6 @@ this._documentContentType = null; - /** - * Weak reference to an optional frame loader that can be used to influence - * process selection for this browser. - * See nsIBrowser.sameProcessAsFrameLoader. - * - * tabbrowser sets "sameProcessAsFrameLoader" on some browsers before - * they are connected. This avoids clearing that out while we're doing - * the initial construct(), which is what would read it. - */ - if (this.mInitialized) { - this._sameProcessAsFrameLoader = null; - } - this._loadContext = null; this._webBrowserFind = null; @@ -357,16 +344,6 @@ } } - set sameProcessAsFrameLoader(val) { - this._sameProcessAsFrameLoader = Cu.getWeakReference(val); - } - - get sameProcessAsFrameLoader() { - return ( - this._sameProcessAsFrameLoader && this._sameProcessAsFrameLoader.get() - ); - } - get loadContext() { if (this._loadContext) { return this._loadContext; diff --git a/toolkit/mozapps/extensions/content/aboutaddons.js b/toolkit/mozapps/extensions/content/aboutaddons.js index 07c8c772f72e..168bb68dd0e0 100644 --- a/toolkit/mozapps/extensions/content/aboutaddons.js +++ b/toolkit/mozapps/extensions/content/aboutaddons.js @@ -2297,7 +2297,6 @@ class InlineOptionsBrowser extends HTMLElement { let { optionsURL, optionsBrowserStyle } = addon; if (addon.isWebExtension) { let policy = ExtensionParent.WebExtensionPolicy.getByID(addon.id); - browser.sameProcessAsFrameLoader = policy.extension.groupFrameLoader; browser.setAttribute( "initialBrowsingContextGroupId", policy.browsingContextGroupId