Bug 1633710 - Move js uri.host to principal r=ckerschb,preferences-reviewers,ntim

Differential Revision: https://phabricator.services.mozilla.com/D73242
This commit is contained in:
Sebastian Streich
2020-07-13 18:35:01 +00:00
parent c19ac56e47
commit 9a30e9e484
11 changed files with 25 additions and 30 deletions

View File

@@ -845,7 +845,7 @@ var ThirdPartyCookies = {
for (let perm of Services.perms.all) {
if (
perm.type == "cookie" &&
Services.eTLD.hasRootDomain(host, perm.principal.URI.host)
Services.eTLD.hasRootDomain(host, perm.principal.host)
) {
Services.perms.removePermission(perm);
}

View File

@@ -7617,7 +7617,7 @@ var CanvasPermissionPromptHelper = {
let options = {
checkbox,
name: principal.URI.host,
name: principal.host,
learnMoreURL:
Services.urlFormatter.formatURLPref("app.support.baseURL") +
"fingerprint-permission",

View File

@@ -51,7 +51,7 @@ add_task(async function test_toplevel_frame_permission() {
browser
);
is(
notification.options.principal.URI.host,
notification.options.principal.host,
"example.com",
"Should use top host for permission prompt!"
);

View File

@@ -48,7 +48,7 @@ function waitForUnregister(host) {
return new Promise(resolve => {
let listener = {
onUnregister: registration => {
if (registration.principal.URI.host != host) {
if (registration.principal.host != host) {
return;
}
swm.removeListener(listener);
@@ -72,7 +72,7 @@ async function createData(host) {
function moveOriginInTime(principals, endDate, host) {
for (let i = 0; i < principals.length; ++i) {
let principal = principals.queryElementAt(i, Ci.nsIPrincipal);
if (principal.URI.host == host) {
if (principal.host == host) {
sas.moveOriginInTime(principal, endDate - fiveHours);
return true;
}
@@ -116,10 +116,7 @@ add_task(async function testWithRange() {
let found = 0;
for (let i = 0; i < principals.length; ++i) {
let principal = principals.queryElementAt(i, Ci.nsIPrincipal);
if (
principal.URI.host == "example.org" ||
principal.URI.host == "example.com"
) {
if (principal.host == "example.org" || principal.host == "example.com") {
found++;
}
}

View File

@@ -104,7 +104,7 @@ add_task(async function testServiceWorkers() {
let host = serviceWorkers.queryElementAt(
0,
Ci.nsIServiceWorkerRegistrationInfo
).principal.URI.host;
).principal.host;
is(host, "mochi.test", "ServiceWorkers for example.com have been removed.");
extension.sendMessage({});

View File

@@ -232,7 +232,7 @@ async function addTestData(data) {
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
site.origin
);
hosts.push(principal.URI.host);
hosts.push(principal.host);
}
return hosts;

View File

@@ -485,7 +485,7 @@ var SiteDataManager = {
if (perm.principal.schemeIs("file")) {
Services.perms.removePermission(perm);
}
} else if (Services.eTLD.hasRootDomain(perm.principal.URI.host, host)) {
} else if (Services.eTLD.hasRootDomain(perm.principal.host, host)) {
Services.perms.removePermission(perm);
}
}

View File

@@ -434,14 +434,14 @@ const QuotaCleaner = {
Services.obs.notifyObservers(
null,
"extension:purge-localStorage",
aPrincipal.URI.host
aPrincipal.host
);
// Clear sessionStorage
Services.obs.notifyObservers(
null,
"browser:purge-sessionStorage",
aPrincipal.URI.host
aPrincipal.host
);
// ServiceWorkers: they must be removed before cleaning QuotaManager.
@@ -504,7 +504,7 @@ const QuotaCleaner = {
);
let host;
try {
host = principal.URI.host;
host = principal.host;
} catch (e) {
// There is no host for the given principal.
continue;
@@ -701,7 +701,7 @@ const StorageAccessCleaner = {
let toBeRemoved = false;
try {
toBeRemoved = Services.eTLD.hasRootDomain(
perm.principal.URI.host,
perm.principal.host,
aHost
);
} catch (ex) {
@@ -819,10 +819,7 @@ const PermissionsCleaner = {
for (let perm of Services.perms.all) {
let toBeRemoved;
try {
toBeRemoved = Services.eTLD.hasRootDomain(
perm.principal.URI.host,
aHost
);
toBeRemoved = Services.eTLD.hasRootDomain(perm.principal.host, aHost);
} catch (ex) {
continue;
}
@@ -1204,7 +1201,7 @@ ClearDataService.prototype = Object.freeze({
// is to delete by host.
if (aCleaner.deleteByHost) {
return aCleaner.deleteByHost(
aPrincipal.URI.host,
aPrincipal.host,
aPrincipal.originAttributes
);
}

View File

@@ -50,7 +50,7 @@ this.ServiceWorkerCleanUp = {
i,
Ci.nsIServiceWorkerRegistrationInfo
);
if (sw.principal.URI.host == aHost) {
if (sw.principal.host == aHost) {
promises.push(unregisterServiceWorker(sw));
}
}

View File

@@ -91,7 +91,7 @@ var SiteDataTestUtils = {
origin
);
Services.cookies.add(
principal.URI.host,
principal.host,
principal.URI.pathQueryRef,
name,
value,
@@ -190,7 +190,7 @@ var SiteDataTestUtils = {
principal.originAttributes,
cookie.originAttributes
) &&
cookie.host.includes(principal.URI.host)
cookie.host.includes(principal.host)
) {
return true;
}
@@ -295,7 +295,7 @@ var SiteDataTestUtils = {
return new Promise(resolve => {
let listener = {
onRegister: registration => {
if (registration.principal.URI.host != url.host) {
if (registration.principal.host != url.host) {
return;
}
swm.removeListener(listener);
@@ -322,7 +322,7 @@ var SiteDataTestUtils = {
return new Promise(resolve => {
let listener = {
onUnregister: registration => {
if (registration.principal.URI.host != url.host) {
if (registration.principal.host != url.host) {
return;
}
swm.removeListener(listener);

View File

@@ -41,12 +41,13 @@ amContentHandler.prototype = {
let sourceHost;
let sourceURL;
try {
sourceURL = triggeringPrincipal.URI.spec;
sourceHost = triggeringPrincipal.URI.host;
} catch (err) {
// Ignore errors when retrieving the host for the principal (e.g. null principals raise
// an NS_ERROR_FAILURE when principal.URI.host is accessed).
sourceHost = triggeringPrincipal.host;
} catch (error) {
// Ignore errors when retrieving the host for the principal (e.g. data URIs return
// an NS_ERROR_FAILURE when principal.host is accessed).
}
let install = {