Bug 2011307 - Remove test-only support for marking chrome:// URI as needing to be loaded remotely, r=smaug,tabbrowser-reviewers,nsharpley

This feature is only used by its feature test. This patch removes the logic
completely alongside the test, which should slightly simplify process selection
logic.

Differential Revision: https://phabricator.services.mozilla.com/D282081
This commit is contained in:
Nika Layzell
2026-05-21 19:23:48 +00:00
committed by nlayzell@mozilla.com
parent 1dc15d1e7b
commit c7c574c601
12 changed files with 2 additions and 305 deletions
@@ -4,7 +4,6 @@ support-files = [
"audio.ogg",
"dummy_page.html",
"file_mediaPlayback.html",
"test_process_flags_chrome.html",
"helper_origin_attrs_testing.js",
"file_about_srcdoc.html",
"file_reader_mode_article.html",
@@ -97,11 +96,6 @@ tags = "vertical-tabs"
["browser_e10s_about_process.js"]
["browser_e10s_chrome_process.js"]
skip-if = [
"debug", # Bug 1444565, Bug 1457887
]
["browser_e10s_javascript.js"]
["browser_e10s_mozillaweb_process.js"]
@@ -1,136 +0,0 @@
// Returns a function suitable for add_task which loads startURL, runs
// transitionTask and waits for endURL to load, checking that the URLs were
// loaded in the correct process.
function makeTest(
name,
startURL,
startProcessIsRemote,
endURL,
endProcessIsRemote,
transitionTask
) {
return async function () {
info("Running test " + name + ", " + transitionTask.name);
let browser = gBrowser.selectedBrowser;
// In non-e10s nothing should be remote
if (!gMultiProcessBrowser) {
startProcessIsRemote = false;
endProcessIsRemote = false;
}
// Load the initial URL and make sure we are in the right initial process
info("Loading initial URL");
BrowserTestUtils.startLoadingURIString(browser, startURL);
await BrowserTestUtils.browserLoaded(browser, false, startURL);
is(browser.currentURI.spec, startURL, "Shouldn't have been redirected");
is(
browser.isRemoteBrowser,
startProcessIsRemote,
"Should be displayed in the right process"
);
let docLoadedPromise = BrowserTestUtils.browserLoaded(
browser,
false,
endURL
);
await transitionTask(browser, endURL);
await docLoadedPromise;
is(browser.currentURI.spec, endURL, "Should have made it to the final URL");
is(
browser.isRemoteBrowser,
endProcessIsRemote,
"Should be displayed in the right process"
);
};
}
const PATH = (
getRootDirectory(gTestPath) + "test_process_flags_chrome.html"
).replace("chrome://mochitests", "");
const CHROME = "chrome://mochitests" + PATH;
const CANREMOTE = "chrome://mochitests-any" + PATH;
const MUSTREMOTE = "chrome://mochitests-content" + PATH;
add_setup(async function () {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {
forceNotRemote: true,
});
});
registerCleanupFunction(() => {
gBrowser.removeCurrentTab();
});
add_task(async function test_chrome() {
test_url_for_process_types({
url: CHROME,
chromeResult: true,
webContentResult: false,
privilegedAboutContentResult: false,
privilegedMozillaContentResult: false,
extensionProcessResult: false,
});
});
add_task(async function test_any() {
test_url_for_process_types({
url: CANREMOTE,
chromeResult: true,
webContentResult: true,
privilegedAboutContentResult: false,
privilegedMozillaContentResult: false,
extensionProcessResult: false,
});
});
add_task(async function test_remote() {
test_url_for_process_types({
url: MUSTREMOTE,
chromeResult: false,
webContentResult: true,
privilegedAboutContentResult: false,
privilegedMozillaContentResult: false,
extensionProcessResult: false,
});
});
// The set of page transitions
var TESTS = [
["chrome -> chrome", CHROME, false, CHROME, false],
["chrome -> canremote", CHROME, false, CANREMOTE, false],
["chrome -> mustremote", CHROME, false, MUSTREMOTE, true],
["remote -> chrome", MUSTREMOTE, true, CHROME, false],
["remote -> canremote", MUSTREMOTE, true, CANREMOTE, true],
["remote -> mustremote", MUSTREMOTE, true, MUSTREMOTE, true],
];
// The different ways to transition from one page to another
var TRANSITIONS = [
// Loads the new page by calling browser.loadURI directly
async function loadURI(browser, uri) {
info("Calling browser.loadURI");
BrowserTestUtils.startLoadingURIString(browser, uri);
},
// Loads the new page by finding a link with the right href in the document and
// clicking it
function clickLink(browser, uri) {
info("Clicking link");
SpecialPowers.spawn(browser, [uri], function frame_script(frameUri) {
let link = content.document.querySelector("a[href='" + frameUri + "']");
link.click();
});
},
];
// Creates a set of test tasks, one for each combination of TESTS and TRANSITIONS.
for (let test of TESTS) {
for (let transition of TRANSITIONS) {
add_task(makeTest(...test, transition));
}
}
@@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<p>chrome: test page</p>
<p><a href="chrome://mochitests/content/browser/browser/components/tabbrowser/test/browser/tabs/test_process_flags_chrome.html">chrome</a></p>
<p><a href="chrome://mochitests-any/content/browser/browser/components/tabbrowser/test/browser/tabs/test_process_flags_chrome.html">canremote</a></p>
<p><a href="chrome://mochitests-content/content/browser/browser/components/tabbrowser/test/browser/tabs/test_process_flags_chrome.html">mustremote</a></p>
</body>
</html>
-24
View File
@@ -390,30 +390,6 @@ main process.
component {09543782-22b1-4a0b-ba07-9134365776ee} maincomponent.js process=main
component {98309951-ac89-4642-afea-7b2b6216bcef} contentcomponent.js process=content
remoteenabled
~~~~~~~~~~~~~
In `multiprocess Firefox`, the
default is that a given chrome: URI will always be loaded into the
chrome process. If you set the "remoteenabled" flag, then the page will
be loaded in the same process as the ``browser`` that loaded it:
::
content packagename chrome/path/ remoteenabled=yes
remoterequired
~~~~~~~~~~~~~~
In `multiprocess Firefox`, the
default is that a given chrome: URI will always be loaded into the
chrome process. If you set the "remoterequired" flag, then the page will
always be loaded into a child process:
::
content packagename chrome/path/ remoterequired=yes
Example chrome manifest
-----------------------
-56
View File
@@ -327,62 +327,6 @@ nsChromeRegistry::AllowContentToAccess(nsIURI* aURI, bool* aResult) {
return NS_OK;
}
NS_IMETHODIMP
nsChromeRegistry::CanLoadURLRemotely(nsIURI* aURI, bool* aResult) {
nsresult rv;
*aResult = false;
NS_ASSERTION(aURI->SchemeIs("chrome"),
"Non-chrome URI passed to CanLoadURLRemotely!");
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
if (!url) {
NS_ERROR("Chrome URL doesn't implement nsIURL.");
return NS_ERROR_UNEXPECTED;
}
nsAutoCString package;
rv = url->GetHostPort(package);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t flags;
rv = GetFlagsFromPackage(package, &flags);
if (NS_SUCCEEDED(rv)) {
*aResult = !!(flags & REMOTE_ALLOWED);
}
return NS_OK;
}
NS_IMETHODIMP
nsChromeRegistry::MustLoadURLRemotely(nsIURI* aURI, bool* aResult) {
nsresult rv;
*aResult = false;
NS_ASSERTION(aURI->SchemeIs("chrome"),
"Non-chrome URI passed to MustLoadURLRemotely!");
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
if (!url) {
NS_ERROR("Chrome URL doesn't implement nsIURL.");
return NS_ERROR_UNEXPECTED;
}
nsAutoCString package;
rv = url->GetHostPort(package);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t flags;
rv = GetFlagsFromPackage(package, &flags);
if (NS_SUCCEEDED(rv)) {
*aResult = !!(flags & REMOTE_REQUIRED);
}
return NS_OK;
}
already_AddRefed<nsChromeRegistry> nsChromeRegistry::GetSingleton() {
if (gChromeRegistry) {
RefPtr<nsChromeRegistry> registry = gChromeRegistry;
-8
View File
@@ -40,8 +40,6 @@ class nsChromeRegistry : public nsIToolkitChromeRegistry,
// nsIXULChromeRegistry methods:
NS_IMETHOD AllowScriptsForPackage(nsIURI* url, bool* _retval) override;
NS_IMETHOD AllowContentToAccess(nsIURI* url, bool* _retval) override;
NS_IMETHOD CanLoadURLRemotely(nsIURI* url, bool* _retval) override;
NS_IMETHOD MustLoadURLRemotely(nsIURI* url, bool* _retval) override;
NS_IMETHOD ConvertChromeURL(nsIURI* aChromeURI, nsIURI** aResult) override;
@@ -118,12 +116,6 @@ class nsChromeRegistry : public nsIToolkitChromeRegistry,
// Content script may access files in this package
CONTENT_ACCESSIBLE = 1 << 2,
// Package may be loaded remotely
REMOTE_ALLOWED = 1 << 3,
// Package must be loaded remotely
REMOTE_REQUIRED = 1 << 4,
};
bool mInitialized;
-14
View File
@@ -59,20 +59,6 @@ interface nsIXULChromeRegistry : nsIChromeRegistry
* Do not pass non-chrome URIs to this method.
*/
boolean allowContentToAccess(in nsIURI url);
/**
* Returns true if the passed chrome URL is allowed to be loaded in a remote
* process. This reflects the remoteenabled flag on packages.
* Do not pass non-chrome URIs to this method.
*/
boolean canLoadURLRemotely(in nsIURI url);
/**
* Returns true if the passed chrome URL must be loaded in a remote process.
* This reflects the remoterequired flag on packages.
* Do not pass non-chrome URIs to this method.
*/
boolean mustLoadURLRemotely(in nsIURI url);
};
%{ C++
+1 -17
View File
@@ -259,23 +259,7 @@ static IsolationBehavior IsolationBehaviorForURI(nsIURI* aURI, bool aIsSubframe,
MOZ_ALWAYS_SUCCEEDS(aURI->GetScheme(scheme));
if (scheme == "chrome"_ns) {
// `chrome://` URIs are always loaded in the parent process, unless they
// have opted in to loading in a content process. This is currently only
// done in tests.
//
// FIXME: These flags should be removed from `chrome` URIs at some point.
nsCOMPtr<nsIXULChromeRegistry> chromeReg =
do_GetService("@mozilla.org/chrome/chrome-registry;1");
bool mustLoadRemotely = false;
if (NS_SUCCEEDED(chromeReg->MustLoadURLRemotely(aURI, &mustLoadRemotely)) &&
mustLoadRemotely) {
return IsolationBehavior::ForceWebRemoteType;
}
bool canLoadRemotely = false;
if (NS_SUCCEEDED(chromeReg->CanLoadURLRemotely(aURI, &canLoadRemotely)) &&
canLoadRemotely) {
return IsolationBehavior::Anywhere;
}
// `chrome://` URIs are always loaded in the parent process.
return IsolationBehavior::Parent;
}
-6
View File
@@ -1696,12 +1696,6 @@ class MochitestDesktop:
manifestFile.write(
f"content mochitests {chrometestDir} contentaccessible=yes\n"
)
manifestFile.write(
f"content mochitests-any {chrometestDir} contentaccessible=yes remoteenabled=yes\n"
)
manifestFile.write(
f"content mochitests-content {chrometestDir} contentaccessible=yes remoterequired=yes\n"
)
if options.testingModulesDir is not None:
manifestFile.write(
+1 -16
View File
@@ -548,23 +548,8 @@ export var E10SUtils = {
return NOT_REMOTE;
}
case "chrome": {
let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
Ci.nsIXULChromeRegistry
);
if (chromeReg.mustLoadURLRemotely(aURI)) {
return DEFAULT_REMOTE_TYPE;
}
if (
chromeReg.canLoadURLRemotely(aURI) &&
preferredRemoteType != NOT_REMOTE
) {
return DEFAULT_REMOTE_TYPE;
}
case "chrome":
return NOT_REMOTE;
}
case "moz-extension":
// Extension iframes should load in the same process
-2
View File
@@ -1333,8 +1333,6 @@ interface nsIXULChromeRegistry extends nsIChromeRegistry {
isLocaleRTL(package: string): boolean;
allowScriptsForPackage(url: nsIURI): boolean;
allowContentToAccess(url: nsIURI): boolean;
canLoadURLRemotely(url: nsIURI): boolean;
mustLoadURLRemotely(url: nsIURI): boolean;
}
// https://searchfox.org/firefox-main/source/chrome/nsIToolkitChromeRegistry.idl
-10
View File
@@ -379,8 +379,6 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
nsresult rv;
constexpr auto kContentAccessible = u"contentaccessible"_ns;
constexpr auto kRemoteEnabled = u"remoteenabled"_ns;
constexpr auto kRemoteRequired = u"remoterequired"_ns;
constexpr auto kApplication = u"application"_ns;
constexpr auto kAppVersion = u"appversion"_ns;
constexpr auto kGeckoVersion = u"platformversion"_ns;
@@ -605,14 +603,6 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
if (flag) flags |= nsChromeRegistry::CONTENT_ACCESSIBLE;
continue;
}
if (CheckFlag(kRemoteEnabled, wtoken, flag)) {
if (flag) flags |= nsChromeRegistry::REMOTE_ALLOWED;
continue;
}
if (CheckFlag(kRemoteRequired, wtoken, flag)) {
if (flag) flags |= nsChromeRegistry::REMOTE_REQUIRED;
continue;
}
}
bool xpcNativeWrappers = true; // Dummy for CheckFlag.