Backed out changeset e99b30fd0931 (bug 1067293) for causing bc failures in browser_preferences_usage.js CLOSED TREE

This commit is contained in:
Cristian Tuns 2023-08-08 20:40:06 -04:00
Родитель ff69e79f19
Коммит 4d0c75f5cd
7 изменённых файлов: 61 добавлений и 108 удалений

Просмотреть файл

@ -516,8 +516,6 @@ pref("browser.urlbar.maxCharsForSearchSuggestions", 100);
pref("browser.urlbar.trimURLs", true);
pref("browser.urlbar.trimHttps", false);
// If changed to true, copying the entire URL from the location bar will put the
// human readable (percent-decoded) URL on the clipboard.
pref("browser.urlbar.decodeURLsOnCopy", false);

Просмотреть файл

@ -3348,16 +3348,7 @@ export class UrlbarInput {
if (fixedURI) {
try {
let expectedURI = Services.io.newURI(this._untrimmedValue);
if (
lazy.UrlbarPrefs.get("trimHttps") &&
this._untrimmedValue.startsWith("https://")
) {
untrim =
fixedURI.displaySpec.replace("http://", "https://") !=
expectedURI.displaySpec; // FIXME bug 1847723: Figure out a way to do this without manually messing with the fixed up URI.
} else {
untrim = fixedURI.displaySpec != expectedURI.displaySpec;
}
untrim = fixedURI.displaySpec != expectedURI.displaySpec;
} catch (ex) {
untrim = true;
}

Просмотреть файл

@ -405,9 +405,6 @@ const PREF_URLBAR_DEFAULTS = new Map([
// Remove redundant portions from URLs.
["trimURLs", true],
// Remove 'https://' from url when urlbar is focused.
["trimHttps", true],
// If true, top sites may include sponsored ones.
["sponsoredTopSites", false],

Просмотреть файл

@ -269,12 +269,8 @@ export class UrlbarValueFormatter {
let { domain, origin, preDomain, schemeWSlashes, trimmedLength, url } =
urlMetaData;
// When the scheme has been stripped, don't show the box for it.
if (
!lazy.UrlbarPrefs.get("trimURLs") ||
schemeWSlashes != lazy.BrowserUIUtils.trimURLProtocol
) {
// We strip http, so we should not show the scheme box for it.
if (!lazy.UrlbarPrefs.get("trimURLs") || schemeWSlashes != "http://") {
this.scheme.value = schemeWSlashes;
this.inputField.style.setProperty(
"--urlbar-scheme-size",

Просмотреть файл

@ -40,17 +40,13 @@ async function testVal(urlFormatString, clobberedURLString = null) {
}
add_task(async function () {
const PREF_FORMATTING = "browser.urlbar.formatting.enabled";
const PREF_TRIM_HTTPS = "browser.urlbar.trimHttps";
const prefname = "browser.urlbar.formatting.enabled";
registerCleanupFunction(function () {
Services.prefs.clearUserPref(PREF_FORMATTING);
Services.prefs.clearUserPref(PREF_TRIM_HTTPS);
Services.prefs.clearUserPref(prefname);
gURLBar.setURI();
});
Services.prefs.setBoolPref(PREF_TRIM_HTTPS, false);
gBrowser.selectedBrowser.focus();
await testVal("<https://>mozilla.org");
@ -156,7 +152,7 @@ add_task(async function () {
await testVal("foo-://mozilla.org/");
// Disable formatting.
Services.prefs.setBoolPref(PREF_FORMATTING, false);
Services.prefs.setBoolPref(prefname, false);
await testVal("https://mozilla.org");
});

Просмотреть файл

@ -1,38 +1,53 @@
function testValues(trimmedProtocol, notTrimmedProtocol) {
testVal(trimmedProtocol + "mozilla.org/", "mozilla.org");
testVal(
notTrimmedProtocol + "mozilla.org/",
notTrimmedProtocol + "mozilla.org"
);
testVal(trimmedProtocol + "mözilla.org/", "mözilla.org");
add_task(async function () {
const PREF_TRIMURLS = "browser.urlbar.trimURLs";
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
registerCleanupFunction(async function () {
BrowserTestUtils.removeTab(tab);
Services.prefs.clearUserPref(PREF_TRIMURLS);
gURLBar.setURI();
});
// Avoid search service sync init warnings due to URIFixup, when running the
// test alone.
await Services.search.init();
Services.prefs.setBoolPref(PREF_TRIMURLS, true);
testVal("http://mozilla.org/", "mozilla.org");
testVal("https://mozilla.org/", "https://mozilla.org");
testVal("http://mözilla.org/", "mözilla.org");
// This isn't a valid public suffix, thus we should untrim it or it would
// end up doing a search.
testVal(trimmedProtocol + "mozilla.imaginatory/");
testVal(trimmedProtocol + "www.mozilla.org/", "www.mozilla.org");
testVal(trimmedProtocol + "sub.mozilla.org/", "sub.mozilla.org");
testVal(
trimmedProtocol + "sub1.sub2.sub3.mozilla.org/",
"sub1.sub2.sub3.mozilla.org"
);
testVal(trimmedProtocol + "mozilla.org/file.ext", "mozilla.org/file.ext");
testVal(trimmedProtocol + "mozilla.org/sub/", "mozilla.org/sub/");
testVal("http://mozilla.imaginatory/");
testVal("http://www.mozilla.org/", "www.mozilla.org");
testVal("http://sub.mozilla.org/", "sub.mozilla.org");
testVal("http://sub1.sub2.sub3.mozilla.org/", "sub1.sub2.sub3.mozilla.org");
testVal("http://mozilla.org/file.ext", "mozilla.org/file.ext");
testVal("http://mozilla.org/sub/", "mozilla.org/sub/");
testVal(trimmedProtocol + "ftp.mozilla.org/", "ftp.mozilla.org");
testVal(trimmedProtocol + "ftp1.mozilla.org/", "ftp1.mozilla.org");
testVal(trimmedProtocol + "ftp42.mozilla.org/", "ftp42.mozilla.org");
testVal(trimmedProtocol + "ftpx.mozilla.org/", "ftpx.mozilla.org");
testVal("http://ftp.mozilla.org/", "ftp.mozilla.org");
testVal("http://ftp1.mozilla.org/", "ftp1.mozilla.org");
testVal("http://ftp42.mozilla.org/", "ftp42.mozilla.org");
testVal("http://ftpx.mozilla.org/", "ftpx.mozilla.org");
testVal("ftp://ftp.mozilla.org/", "ftp://ftp.mozilla.org");
testVal("ftp://ftp1.mozilla.org/", "ftp://ftp1.mozilla.org");
testVal("ftp://ftp42.mozilla.org/", "ftp://ftp42.mozilla.org");
testVal("ftp://ftpx.mozilla.org/", "ftp://ftpx.mozilla.org");
testVal("https://user:pass@mozilla.org/", "https://user:pass@mozilla.org");
testVal("https://user@mozilla.org/", "https://user@mozilla.org");
testVal("http://user:pass@mozilla.org/", "user:pass@mozilla.org");
testVal("http://user@mozilla.org/", "user@mozilla.org");
testVal("http://sub.mozilla.org:666/", "sub.mozilla.org:666");
testVal("https://[fe80::222:19ff:fe11:8c76]/file.ext");
testVal("http://[fe80::222:19ff:fe11:8c76]/", "[fe80::222:19ff:fe11:8c76]");
testVal("https://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext");
testVal(
notTrimmedProtocol + "user:pass@mozilla.org/",
notTrimmedProtocol + "user:pass@mozilla.org"
);
testVal(
notTrimmedProtocol + "user@mozilla.org/",
notTrimmedProtocol + "user@mozilla.org"
"http://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext",
"user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext"
);
testVal("mailto:admin@mozilla.org");
@ -40,33 +55,6 @@ function testValues(trimmedProtocol, notTrimmedProtocol) {
testVal("about:config");
testVal("jar:http://mozilla.org/example.jar!/");
testVal("view-source:http://mozilla.org/");
}
add_task(async function () {
const PREF_TRIM_URLS = "browser.urlbar.trimURLs";
const PREF_TRIM_HTTPS = "browser.urlbar.trimHttps";
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
registerCleanupFunction(async function () {
BrowserTestUtils.removeTab(tab);
Services.prefs.clearUserPref(PREF_TRIM_URLS);
Services.prefs.clearUserPref(PREF_TRIM_HTTPS);
gURLBar.setURI();
});
Services.prefs.setBoolPref(PREF_TRIM_HTTPS, false);
// Avoid search service sync init warnings due to URIFixup, when running the
// test alone.
await Services.search.init();
Services.prefs.setBoolPref(PREF_TRIM_URLS, true);
testValues("http://", "https://");
Services.prefs.setBoolPref(PREF_TRIM_HTTPS, true);
testValues("https://", "http://");
Services.prefs.setBoolPref(PREF_TRIM_HTTPS, false);
// Behaviour for hosts with no dots depends on the whitelist:
let fixupWhitelistPref = "browser.fixup.domainwhitelist.localhost";
@ -83,28 +71,17 @@ add_task(async function () {
// This host is whitelisted, it can be trimmed.
testVal("http://localhost/ foo bar baz", "localhost/ foo bar baz");
testVal("http://user:pass@mozilla.org/", "user:pass@mozilla.org");
testVal("http://user@mozilla.org/", "user@mozilla.org");
testVal("http://sub.mozilla.org:666/", "sub.mozilla.org:666");
testVal("https://[fe80::222:19ff:fe11:8c76]/file.ext");
testVal("http://[fe80::222:19ff:fe11:8c76]/", "[fe80::222:19ff:fe11:8c76]");
testVal("https://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext");
testVal(
"http://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext",
"user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext"
);
// This is not trimmed because it's not in the domain whitelist.
testVal(
"http://localhost.localdomain/ foo bar baz",
"http://localhost.localdomain/ foo bar baz"
);
Services.prefs.setBoolPref(PREF_TRIM_URLS, false);
Services.prefs.setBoolPref(PREF_TRIMURLS, false);
testVal("http://mozilla.org/");
Services.prefs.setBoolPref(PREF_TRIM_URLS, true);
Services.prefs.setBoolPref(PREF_TRIMURLS, true);
let promiseLoaded = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,

Просмотреть файл

@ -141,26 +141,24 @@ export var BrowserUIUtils = {
return aURL.replace(/^((?:http|https|ftp):\/\/[^/]+)\/$/, "$1");
},
get trimURLProtocol() {
return Services.prefs.getBoolPref("browser.urlbar.trimHttps")
? "https://"
: "http://";
},
/**
* Returns a URL which has been trimmed by removing 'http://' or 'https://',
* when the pref 'trimHttps' is set to true, and any trailing slash
* (in http/https/ftp urls). Note that a trimmed url may not load the same
* page as the original url, so before loading it, it must be passed through
* URIFixup, to check trimming doesn't change its destination. We don't run
* the URIFixup check here, because trimURL is in the page load path
* (see onLocationChange), so it must be fast and simple.
* Returns a URL which has been trimmed by removing 'http://' and any
* trailing slash (in http/https/ftp urls).
* Note that a trimmed url may not load the same page as the original url, so
* before loading it, it must be passed through URIFixup, to check trimming
* doesn't change its destination. We don't run the URIFixup check here,
* because trimURL is in the page load path (see onLocationChange), so it
* must be fast and simple.
*
* @param {string} aURL The URL to trim.
* @returns {string} The trimmed string.
*/
get trimURLProtocol() {
return "http://";
},
trimURL(aURL) {
let url = this.removeSingleTrailingSlashFromURL(aURL);
// Remove "http://" prefix.
return url.startsWith(this.trimURLProtocol)
? url.substring(this.trimURLProtocol.length)
: url;