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-01 12:21:22 +00:00
Родитель ed781fc43a
Коммит 51a16a3ad7
12 изменённых файлов: 24 добавлений и 45 удалений

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

@ -813,7 +813,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);
}

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

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

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

@ -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!"
);

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

@ -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++;
}
}

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

@ -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;

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

@ -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);
}
}

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

@ -431,14 +431,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.
@ -501,7 +501,7 @@ const QuotaCleaner = {
);
let host;
try {
host = principal.URI.host;
host = principal.host;
} catch (e) {
// There is no host for the given principal.
continue;
@ -698,7 +698,7 @@ const StorageAccessCleaner = {
let toBeRemoved = false;
try {
toBeRemoved = Services.eTLD.hasRootDomain(
perm.principal.URI.host,
perm.principal.host,
aHost
);
} catch (ex) {
@ -816,10 +816,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;
}
@ -1146,7 +1143,7 @@ ClearDataService.prototype = Object.freeze({
// is to delete by host.
if (aCleaner.deleteByHost) {
return aCleaner.deleteByHost(
aPrincipal.URI.host,
aPrincipal.host,
aPrincipal.originAttributes
);
}

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

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

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

@ -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);

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

@ -39,15 +39,8 @@ amContentHandler.prototype = {
const { triggeringPrincipal } = loadInfo;
let browsingContext = loadInfo.targetBrowsingContext;
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).
}
let sourceHost = triggeringPrincipal.host;
let sourceURL = triggeringPrincipal.URI?.spec;
let install = {
uri: uri.spec,

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

@ -151,16 +151,8 @@ InstallTrigger.prototype = {
}
}
let sourceHost;
let sourceURL;
try {
sourceHost = this._principal.URI.host;
sourceURL = this._principal.URI.spec;
} 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).
}
let sourceHost = this._principal.host;
let sourceURL = this._principal.URI?.spec;
let installData = {
uri: url.spec,

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

@ -256,7 +256,7 @@ class WebAPI extends APIObject {
// Provide the host from which the amWebAPI is being called
// (so that we can detect if the API is being used from the disco pane,
// AMO, testpilot or another unknown webpage).
sourceHost: triggeringPrincipal.URI && triggeringPrincipal.URI.host,
sourceHost: triggeringPrincipal.host,
sourceURL: triggeringPrincipal.URI && triggeringPrincipal.URI.spec,
};
return this._apiTask("createInstall", [installOptions], installInfo => {