Skip to content

Commit

Permalink
Bug 1839845 - Add about:settings as alias of about:preferences. r=Gij…
Browse files Browse the repository at this point in the history
…s,settings-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D202594
  • Loading branch information
bojidar-bg committed Feb 29, 2024
1 parent 790c008 commit c7286a7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions browser/components/about/AboutRedirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ static const RedirEntry kRedirMap[] = {
nsIAboutModule::URI_MUST_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::URI_CAN_LOAD_IN_PRIVILEGEDABOUT_PROCESS |
nsIAboutModule::HIDE_FROM_ABOUTABOUT},
{"settings", "chrome://browser/content/preferences/preferences.xhtml",
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::IS_SECURE_CHROME_UI |
nsIAboutModule::HIDE_FROM_ABOUTABOUT},
{"preferences", "chrome://browser/content/preferences/preferences.xhtml",
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::IS_SECURE_CHROME_UI},
{"downloads",
Expand Down
1 change: 1 addition & 0 deletions browser/components/about/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pages = [
'rights',
'robots',
'sessionrestore',
'settings',
'shoppingsidebar',
'tabcrashed',
'unloads',
Expand Down
13 changes: 8 additions & 5 deletions browser/components/preferences/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,15 @@ var gHomePane = {
},

/**
* _isTabAboutPreferences: Is a given tab set to about:preferences?
* _isTabAboutPreferencesOrSettings: Is a given tab set to about:preferences or about:settings?
* @param {Element} aTab A tab element
* @returns {bool} Is the linkedBrowser of aElement set to about:preferences?
* @returns {bool} Is the linkedBrowser of aElement set to about:preferences or about:settings?
*/
_isTabAboutPreferences(aTab) {
return aTab.linkedBrowser.currentURI.spec.startsWith("about:preferences");
_isTabAboutPreferencesOrSettings(aTab) {
return (
aTab.linkedBrowser.currentURI.spec.startsWith("about:preferences") ||
aTab.linkedBrowser.currentURI.spec.startsWith("about:settings")
);
},

/**
Expand All @@ -367,7 +370,7 @@ var gHomePane = {
"navigator:browser"
) {
tabs = win.gBrowser.visibleTabs.slice(win.gBrowser._numPinnedTabs);
tabs = tabs.filter(tab => !this._isTabAboutPreferences(tab));
tabs = tabs.filter(tab => !this._isTabAboutPreferencesOrSettings(tab));
// XXX: Bug 1441637 - Fix tabbrowser to report tab.closing before it blurs it
tabs = tabs.filter(tab => !tab.closing);
}
Expand Down
5 changes: 4 additions & 1 deletion browser/components/preferences/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ var gMainPane = {
let uri = win.gBrowser.currentURI.spec;

if (
(uri == "about:preferences" || uri == "about:preferences#general") &&
(uri == "about:preferences" ||
uri == "about:preferences#general" ||
uri == "about:settings" ||
uri == "about:settings#general") &&
document.visibilityState == "visible"
) {
this.updateSetDefaultBrowser();
Expand Down
5 changes: 4 additions & 1 deletion dom/security/nsContentSecurityUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ void nsContentSecurityUtils::AssertAboutPageHasCSP(Document* aDocument) {
// preferences and downloads allow legacy inline scripts through hash src.
MOZ_ASSERT(!foundScriptSrc ||
StringBeginsWith(aboutSpec, "about:preferences"_ns) ||
StringBeginsWith(aboutSpec, "about:settings"_ns) ||
StringBeginsWith(aboutSpec, "about:downloads"_ns) ||
StringBeginsWith(aboutSpec, "about:asrouter"_ns) ||
StringBeginsWith(aboutSpec, "about:newtab"_ns) ||
Expand All @@ -1383,6 +1384,7 @@ void nsContentSecurityUtils::AssertAboutPageHasCSP(Document* aDocument) {
// remote web resources
MOZ_ASSERT(!foundWebScheme ||
StringBeginsWith(aboutSpec, "about:preferences"_ns) ||
StringBeginsWith(aboutSpec, "about:settings"_ns) ||
StringBeginsWith(aboutSpec, "about:addons"_ns) ||
StringBeginsWith(aboutSpec, "about:newtab"_ns) ||
StringBeginsWith(aboutSpec, "about:debugging"_ns) ||
Expand Down Expand Up @@ -1411,6 +1413,7 @@ void nsContentSecurityUtils::AssertAboutPageHasCSP(Document* aDocument) {
// Bug 1579160: Remove 'unsafe-inline' from style-src within
// about:preferences
"about:preferences"_ns,
"about:settings"_ns,
// Bug 1571346: Remove 'unsafe-inline' from style-src within about:addons
"about:addons"_ns,
// Bug 1584485: Remove 'unsafe-inline' from style-src within:
Expand Down Expand Up @@ -1553,7 +1556,7 @@ bool nsContentSecurityUtils::ValidateScriptFilename(JSContext* cx,
// and this is the most reasonable. See 1727770
u"about:downloads"_ns,
// We think this is the same problem as about:downloads
u"about:preferences"_ns,
u"about:preferences"_ns, u"about:settings"_ns,
// Browser console will give a filename of 'debugger' See 1763943
// Sometimes it's 'debugger eager eval code', other times just 'debugger
// eval code'
Expand Down
1 change: 1 addition & 0 deletions toolkit/modules/BrowserUtils.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export var BrowserUtils = {
canFindInPage(location) {
return (
!location.startsWith("about:preferences") &&
!location.startsWith("about:settings") &&
!location.startsWith("about:logins") &&
!(location.startsWith("about:firefoxview") && lazy.FXVIEW_SEARCH_ENABLED)
);
Expand Down

0 comments on commit c7286a7

Please sign in to comment.