Loading docshell/base/CanonicalBrowsingContext.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -1858,11 +1858,14 @@ CanonicalBrowsingContext::ChangeRemoteness( BrowsingContextGroup* finalGroup = aOptions.mReplaceBrowsingContext ? change->mSpecificGroup.get() : Group(); bool preferUsed = StaticPrefs::browser_tabs_remote_subframesPreferUsed() && !IsTop(); change->mContentParent = ContentParent::GetNewOrUsedLaunchingBrowserProcess( /* aRemoteType = */ aOptions.mRemoteType, /* aGroup = */ finalGroup, /* aPriority = */ hal::PROCESS_PRIORITY_FOREGROUND, /* aPreferUsed = */ false); /* aPreferUsed = */ preferUsed); if (!change->mContentParent) { change->Cancel(NS_ERROR_FAILURE); return promise.forget(); Loading dom/ipc/ContentParent.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -918,8 +918,9 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess( } if (aPreferUsed && numberOfParents) { // For the preloaded browser we don't want to create a new process but // reuse an existing one. // If we prefer re-using existing content processes, we don't want to create // a new process, and instead re-use an existing one, so pretend the process // limit is at the current number of processes. aMaxContentParents = numberOfParents; } Loading dom/ipc/tests/browser.ini +2 −0 Original line number Diff line number Diff line Loading @@ -40,3 +40,5 @@ skip-if = [browser_very_fission.js] support-files = file_dummy.html run-if = widget == "gtk" [browser_subframesPreferUsed.js] skip-if = !fission # Test doesn't make sense without fission dom/ipc/tests/browser_subframesPreferUsed.js 0 → 100644 +82 −0 Original line number Diff line number Diff line /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ ok( Services.appinfo.fissionAutostart, "this test requires fission to function!" ); function documentURL(origin, html) { let params = new URLSearchParams(); params.append("html", html.trim()); return `${origin}/document-builder.sjs?${params.toString()}`; } async function singleTest(preferUsed) { info(`running test with preferUsed=${preferUsed}`); await SpecialPowers.pushPrefEnv({ set: [ ["dom.ipc.processCount.webIsolated", 4], ["browser.tabs.remote.subframesPreferUsed", preferUsed], ], }); const TEST_URL = documentURL( "https://example.com", `<iframe src=${JSON.stringify( documentURL("https://example.org", `<h1>iframe</h1>`) )}></iframe>` ); await BrowserTestUtils.withNewTab(TEST_URL, async browser1 => { is(browser1.browsingContext.children.length, 1); let topProc1 = browser1.browsingContext.currentWindowGlobal.domProcess; let frameProc1 = browser1.browsingContext.children[0].currentWindowGlobal.domProcess; isnot( topProc1.childID, frameProc1.childID, "the frame should be in a separate process" ); await BrowserTestUtils.withNewTab(TEST_URL, async browser2 => { is(browser2.browsingContext.children.length, 1); let topProc2 = browser2.browsingContext.currentWindowGlobal.domProcess; let frameProc2 = browser2.browsingContext.children[0].currentWindowGlobal.domProcess; isnot( topProc2.childID, frameProc2.childID, "the frame should be in a separate process" ); // Compare processes used for the two tabs. isnot( topProc1.childID, topProc2.childID, "the toplevel windows should be loaded in separate processes" ); if (preferUsed) { is( frameProc1.childID, frameProc2.childID, "the iframes should load in the same process with subframesPreferUsed" ); } else { isnot( frameProc1.childID, frameProc2.childID, "the iframes should load in different processes without subframesPreferUsed" ); } }); }); } add_task(async function test_preferUsed() { await singleTest(true); }); add_task(async function test_noPreferUsed() { await singleTest(false); }); modules/libpref/init/StaticPrefList.yaml +9 −0 Original line number Diff line number Diff line Loading @@ -1350,6 +1350,15 @@ value: false mirror: always # Whether or not process selection for subframes will prefer re-using an # existing content process over creating a new one. Enabling this pref should # reduce the number of processes allocated for non-first-party domains if # dom.ipc.processCount.webIsolated > 1. - name: browser.tabs.remote.subframesPreferUsed type: bool value: true mirror: always # When this pref is enabled, opaque response is only allowed to enter the # content process if it's a response for media (audio, image, video), CSS, or # JavaScript. Loading Loading
docshell/base/CanonicalBrowsingContext.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -1858,11 +1858,14 @@ CanonicalBrowsingContext::ChangeRemoteness( BrowsingContextGroup* finalGroup = aOptions.mReplaceBrowsingContext ? change->mSpecificGroup.get() : Group(); bool preferUsed = StaticPrefs::browser_tabs_remote_subframesPreferUsed() && !IsTop(); change->mContentParent = ContentParent::GetNewOrUsedLaunchingBrowserProcess( /* aRemoteType = */ aOptions.mRemoteType, /* aGroup = */ finalGroup, /* aPriority = */ hal::PROCESS_PRIORITY_FOREGROUND, /* aPreferUsed = */ false); /* aPreferUsed = */ preferUsed); if (!change->mContentParent) { change->Cancel(NS_ERROR_FAILURE); return promise.forget(); Loading
dom/ipc/ContentParent.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -918,8 +918,9 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess( } if (aPreferUsed && numberOfParents) { // For the preloaded browser we don't want to create a new process but // reuse an existing one. // If we prefer re-using existing content processes, we don't want to create // a new process, and instead re-use an existing one, so pretend the process // limit is at the current number of processes. aMaxContentParents = numberOfParents; } Loading
dom/ipc/tests/browser.ini +2 −0 Original line number Diff line number Diff line Loading @@ -40,3 +40,5 @@ skip-if = [browser_very_fission.js] support-files = file_dummy.html run-if = widget == "gtk" [browser_subframesPreferUsed.js] skip-if = !fission # Test doesn't make sense without fission
dom/ipc/tests/browser_subframesPreferUsed.js 0 → 100644 +82 −0 Original line number Diff line number Diff line /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ ok( Services.appinfo.fissionAutostart, "this test requires fission to function!" ); function documentURL(origin, html) { let params = new URLSearchParams(); params.append("html", html.trim()); return `${origin}/document-builder.sjs?${params.toString()}`; } async function singleTest(preferUsed) { info(`running test with preferUsed=${preferUsed}`); await SpecialPowers.pushPrefEnv({ set: [ ["dom.ipc.processCount.webIsolated", 4], ["browser.tabs.remote.subframesPreferUsed", preferUsed], ], }); const TEST_URL = documentURL( "https://example.com", `<iframe src=${JSON.stringify( documentURL("https://example.org", `<h1>iframe</h1>`) )}></iframe>` ); await BrowserTestUtils.withNewTab(TEST_URL, async browser1 => { is(browser1.browsingContext.children.length, 1); let topProc1 = browser1.browsingContext.currentWindowGlobal.domProcess; let frameProc1 = browser1.browsingContext.children[0].currentWindowGlobal.domProcess; isnot( topProc1.childID, frameProc1.childID, "the frame should be in a separate process" ); await BrowserTestUtils.withNewTab(TEST_URL, async browser2 => { is(browser2.browsingContext.children.length, 1); let topProc2 = browser2.browsingContext.currentWindowGlobal.domProcess; let frameProc2 = browser2.browsingContext.children[0].currentWindowGlobal.domProcess; isnot( topProc2.childID, frameProc2.childID, "the frame should be in a separate process" ); // Compare processes used for the two tabs. isnot( topProc1.childID, topProc2.childID, "the toplevel windows should be loaded in separate processes" ); if (preferUsed) { is( frameProc1.childID, frameProc2.childID, "the iframes should load in the same process with subframesPreferUsed" ); } else { isnot( frameProc1.childID, frameProc2.childID, "the iframes should load in different processes without subframesPreferUsed" ); } }); }); } add_task(async function test_preferUsed() { await singleTest(true); }); add_task(async function test_noPreferUsed() { await singleTest(false); });
modules/libpref/init/StaticPrefList.yaml +9 −0 Original line number Diff line number Diff line Loading @@ -1350,6 +1350,15 @@ value: false mirror: always # Whether or not process selection for subframes will prefer re-using an # existing content process over creating a new one. Enabling this pref should # reduce the number of processes allocated for non-first-party domains if # dom.ipc.processCount.webIsolated > 1. - name: browser.tabs.remote.subframesPreferUsed type: bool value: true mirror: always # When this pref is enabled, opaque response is only allowed to enter the # content process if it's a response for media (audio, image, video), CSS, or # JavaScript. Loading