icecat: add release icecat-140.7.0-1gnu1 for ecne
This commit is contained in:
parent
7d0f5dab3b
commit
30225f2e73
156 changed files with 9131 additions and 4525 deletions
|
|
@ -91,7 +91,10 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
);
|
||||
|
||||
ChromeUtils.defineLazyGetter(lazy, "gLocalization", () => {
|
||||
return new Localization(["toolkit/global/browser-utils.ftl"], true);
|
||||
return new Localization(
|
||||
["toolkit/global/browser-utils.ftl", "toolkit/downloads/downloadUtils.ftl"],
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
function stringPrefToSet(prefVal) {
|
||||
|
|
@ -246,8 +249,36 @@ export var BrowserUtils = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a URI in the UI in a user-friendly (but security-sensitive) way.
|
||||
*
|
||||
* @param {nsIURI} uri
|
||||
* @param {object} [options={}]
|
||||
* @param {boolean} [options.showInsecureHTTP=false]
|
||||
* Whether to show "http://" for insecure HTTP URLs.
|
||||
* @param {boolean} [options.showWWW=false]
|
||||
* Whether to show "www." for URLs that have it.
|
||||
* @param {boolean} [options.onlyBaseDomain=false]
|
||||
* Whether to show only the base domain (eTLD+1) for HTTP(S) URLs.
|
||||
* @param {boolean} [options.showFilenameForLocalURIs=false]
|
||||
* If false (default), will show a protocol-specific label for local
|
||||
* URIs (file:, chrome:, resource:, moz-src:, jar:).
|
||||
* Otherwise, will show the filename for such URIs. Only use 'true' if
|
||||
* the context in which the URI is being represented is not security-
|
||||
* critical.
|
||||
*/
|
||||
formatURIForDisplay(uri, options = {}) {
|
||||
let { showInsecureHTTP = false } = options;
|
||||
let {
|
||||
showInsecureHTTP = false,
|
||||
showWWW = false,
|
||||
onlyBaseDomain = false,
|
||||
showFilenameForLocalURIs = false,
|
||||
} = options;
|
||||
// For moz-icon and jar etc. which wrap nsIURLs, if we want to show the
|
||||
// actual filename, unwrap:
|
||||
if (uri && uri instanceof Ci.nsINestedURI && showFilenameForLocalURIs) {
|
||||
return this.formatURIForDisplay(uri.innermostURI, options);
|
||||
}
|
||||
switch (uri.scheme) {
|
||||
case "view-source": {
|
||||
let innerURI = uri.spec.substring("view-source:".length);
|
||||
|
|
@ -257,8 +288,14 @@ export var BrowserUtils = {
|
|||
// Fall through.
|
||||
case "https": {
|
||||
let host = uri.displayHostPort;
|
||||
if (!showInsecureHTTP && host.startsWith("www.")) {
|
||||
let removeSubdomains =
|
||||
!showInsecureHTTP &&
|
||||
(onlyBaseDomain || (!showWWW && host.startsWith("www.")));
|
||||
if (removeSubdomains) {
|
||||
host = Services.eTLD.getSchemelessSite(uri);
|
||||
if (uri.port != -1) {
|
||||
host += ":" + uri.port;
|
||||
}
|
||||
}
|
||||
if (showInsecureHTTP && uri.scheme == "http") {
|
||||
return "http://" + host;
|
||||
|
|
@ -269,7 +306,7 @@ export var BrowserUtils = {
|
|||
return "about:" + uri.filePath;
|
||||
case "blob":
|
||||
try {
|
||||
let url = new URL(uri.specIgnoringRef);
|
||||
let url = URL.fromURI(uri);
|
||||
// _If_ we find a non-null origin, report that.
|
||||
if (url.origin && url.origin != "null") {
|
||||
return this.formatURIStringForDisplay(url.origin, options);
|
||||
|
|
@ -291,8 +328,22 @@ export var BrowserUtils = {
|
|||
}
|
||||
case "chrome":
|
||||
case "resource":
|
||||
case "moz-icon":
|
||||
case "moz-src":
|
||||
case "jar":
|
||||
case "file":
|
||||
if (!showFilenameForLocalURIs) {
|
||||
if (uri.scheme == "file") {
|
||||
return lazy.gLocalization.formatValueSync(
|
||||
"download-utils-done-file-scheme"
|
||||
);
|
||||
}
|
||||
return lazy.gLocalization.formatValueSync(
|
||||
"download-utils-done-scheme",
|
||||
{ scheme: uri.scheme }
|
||||
);
|
||||
}
|
||||
// Otherwise, fall through to show filename...
|
||||
default:
|
||||
try {
|
||||
let url = uri.QueryInterface(Ci.nsIURL);
|
||||
|
|
@ -318,7 +369,7 @@ export var BrowserUtils = {
|
|||
console.error(ex);
|
||||
}
|
||||
}
|
||||
return uri.asciiHost || uri.spec;
|
||||
return uri.spec;
|
||||
},
|
||||
|
||||
// Given a URL returns a (possibly transformed) URL suitable for sharing, or null if
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ export var ClipboardContextMenu = {
|
|||
let menupopup = aChromeDoc.createXULElement("menupopup");
|
||||
menupopup.id = this.MENU_POPUP_ID;
|
||||
menupopup.setAttribute("tabspecific", "true");
|
||||
menupopup.setAttribute("locationspecific", "true");
|
||||
menupopup.appendChild(menuitem);
|
||||
return menupopup;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ let tempFile = new FileUtils.File(PathUtils.tempDir);
|
|||
const TEST_LOCAL_FILE_NAME = "hello.txt";
|
||||
tempFile.append(TEST_LOCAL_FILE_NAME);
|
||||
|
||||
const gL10n = new Localization(["toolkit/global/browser-utils.ftl"], true);
|
||||
const gL10n = new Localization(
|
||||
["toolkit/global/browser-utils.ftl", "toolkit/downloads/downloadUtils.ftl"],
|
||||
true
|
||||
);
|
||||
const DATA_URL_EXPECTED_STRING = gL10n.formatValueSync(
|
||||
"browser-utils-url-data"
|
||||
);
|
||||
|
|
@ -19,6 +22,10 @@ const EXTENSION_URL_EXPECTED_STRING = gL10n.formatValueSync(
|
|||
{ extension: EXTENSION_NAME }
|
||||
);
|
||||
|
||||
const FILE_URL_EXPECTED_STRING = gL10n.formatValueSync(
|
||||
"download-utils-done-file-scheme"
|
||||
);
|
||||
|
||||
const { AddonTestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/AddonTestUtils.sys.mjs"
|
||||
);
|
||||
|
|
@ -88,7 +95,7 @@ const HTTP_TESTS = [
|
|||
output: "www.co.uk",
|
||||
},
|
||||
|
||||
// Other sudomains should be kept:
|
||||
// Other subdomains should be kept:
|
||||
{
|
||||
input: "https://webmail.example.co.uk",
|
||||
output: "webmail.example.co.uk",
|
||||
|
|
@ -158,6 +165,15 @@ const TESTS = [
|
|||
input: "data:text/html,42",
|
||||
output: DATA_URL_EXPECTED_STRING,
|
||||
},
|
||||
|
||||
{
|
||||
input: `moz-icon:${Services.io.newFileURI(tempFile).spec}`,
|
||||
output: tempFile.leafName,
|
||||
},
|
||||
{
|
||||
input: "moz-icon://.extension?size=16",
|
||||
output: "moz-icon://.extension?size=16",
|
||||
},
|
||||
];
|
||||
|
||||
add_setup(async () => {
|
||||
|
|
@ -220,7 +236,9 @@ const { BrowserUtils } = ChromeUtils.importESModule(
|
|||
add_task(async function test_checkStringFormatting() {
|
||||
for (let { input, output } of TESTS) {
|
||||
Assert.equal(
|
||||
BrowserUtils.formatURIStringForDisplay(input),
|
||||
BrowserUtils.formatURIStringForDisplay(input, {
|
||||
showFilenameForLocalURIs: true,
|
||||
}),
|
||||
output,
|
||||
`String ${input} formatted for output should match`
|
||||
);
|
||||
|
|
@ -231,13 +249,56 @@ add_task(async function test_checkURIFormatting() {
|
|||
for (let { input, output } of TESTS) {
|
||||
let uri = Services.io.newURI(input);
|
||||
Assert.equal(
|
||||
BrowserUtils.formatURIForDisplay(uri),
|
||||
BrowserUtils.formatURIForDisplay(uri, {
|
||||
showFilenameForLocalURIs: true,
|
||||
}),
|
||||
output,
|
||||
`URI ${input} formatted for output should match`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_checkOnlyBaseDomain() {
|
||||
for (let { input, output } of [
|
||||
{ input: "https://subdomain.example.com/", output: "example.com" },
|
||||
{
|
||||
input: "http://www.city.mikasa.hokkaido.jp/",
|
||||
output: "city.mikasa.hokkaido.jp",
|
||||
},
|
||||
{ input: "https://www.example.co.uk/", output: "example.co.uk" },
|
||||
{
|
||||
input: "mailto:example@subdomain.example.com",
|
||||
output: "mailto:example@subdomain.example.com",
|
||||
},
|
||||
]) {
|
||||
let uri = Services.io.newURI(input);
|
||||
Assert.equal(
|
||||
BrowserUtils.formatURIForDisplay(uri, { onlyBaseDomain: true }),
|
||||
output,
|
||||
`URI ${input} formatted for output should match`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_checkLocalFileFormatting() {
|
||||
for (let { input } of TESTS) {
|
||||
let uri = Services.io.newURI(input);
|
||||
if (
|
||||
["file", "chrome", "moz-icon", "resource", "jar"].includes(uri.scheme)
|
||||
) {
|
||||
Assert.equal(
|
||||
BrowserUtils.formatURIForDisplay(uri, {
|
||||
showFilenameForLocalURIs: false,
|
||||
}),
|
||||
uri.scheme == "file"
|
||||
? FILE_URL_EXPECTED_STRING
|
||||
: `${uri.scheme} resource`,
|
||||
`URI ${input} formatted for output should match`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_checkViewSourceFormatting() {
|
||||
for (let { input, output } of HTTP_TESTS) {
|
||||
Assert.equal(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue