Bug 1633710 - Move js uri.hostPort to principal r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D73240
This commit is contained in:
Sebastian Streich 2020-05-18 13:50:14 +00:00
parent ab82161bc2
commit b70610980a
4 changed files with 12 additions and 16 deletions

View File

@ -108,7 +108,7 @@ const clearIndexedDB = async function(options) {
principal.schemeIs("https") ||
principal.schemeIs("file")
) {
let host = principal.URI.hostPort;
let host = principal.hostPort;
if (!options.hostnames || options.hostnames.includes(host)) {
promises.push(
new Promise((resolve, reject) => {
@ -187,7 +187,7 @@ const clearLocalStorage = async function(options) {
principal.schemeIs("https") ||
principal.schemeIs("file")
) {
let host = principal.URI.hostPort;
let host = principal.hostPort;
if (!options.hostnames || options.hostnames.includes(host)) {
promises.push(
new Promise((resolve, reject) => {

View File

@ -253,7 +253,7 @@ var PermissionPromptPrototype = {
return principal.addonPolicy.name;
}
return principal.URI.hostPort;
return principal.hostPort;
},
/**
@ -1259,15 +1259,11 @@ StorageAccessPermissionPrompt.prototype = {
return "storage-access-" + this.principal.origin;
},
prettifyHostPort(uri) {
try {
uri = Services.io.createExposableURI(uri);
} catch (e) {
// ignore, since we can't do anything better
}
let host = IDNService.convertToDisplayIDN(uri.host, {});
if (uri.port != -1) {
host += `:${uri.port}`;
prettifyHostPort(hostport) {
let [host, port] = hostport.split(":");
host = IDNService.convertToDisplayIDN(host, {});
if (port) {
return `${host}:${port}`;
}
return host;
},
@ -1279,8 +1275,8 @@ StorageAccessPermissionPrompt.prototype = {
return {
learnMoreURL,
displayURI: false,
name: this.prettifyHostPort(this.principal.URI),
secondName: this.prettifyHostPort(this.topLevelPrincipal.URI),
name: this.prettifyHostPort(this.principal.hostPort),
secondName: this.prettifyHostPort(this.topLevelPrincipal.hostPort),
escAction: "buttoncommand",
};
},

View File

@ -243,7 +243,7 @@ interface nsIPrincipal : nsISerializable
* Returns the "host:port" portion of the
* Principals URI, if any.
*/
[noscript] readonly attribute ACString hostPort;
readonly attribute ACString hostPort;
/**
* Returns the "host:port" portion of the

View File

@ -88,7 +88,7 @@ async function testNodePrincipal() {
"chrome://alerts/locale/alert.properties"
);
var localizedSource = stringBundle.formatStringFromName(
"source.label", [principal.URI.hostPort]);
"source.label", [principal.hostPort]);
is(source, localizedSource, "Should include source for node principal");
}