зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1622730 - Support `file://` principals for the site permission setting.r=pbz
Differential Revision: https://phabricator.services.mozilla.com/D68970 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4f2c05e8cd
Коммит
2e7e4c38ec
|
@ -382,8 +382,7 @@ var SitePermissions = {
|
|||
|
||||
/**
|
||||
* Checks whether a UI for managing permissions should be exposed for a given
|
||||
* principal. This excludes file URIs, for instance, as they don't have a host,
|
||||
* even though nsIPermissionManager can still handle them.
|
||||
* principal.
|
||||
*
|
||||
* @param {nsIPrincipal} principal
|
||||
* The principal to check.
|
||||
|
@ -399,7 +398,7 @@ var SitePermissions = {
|
|||
"Argument passed as principal is not an instance of Ci.nsIPrincipal"
|
||||
);
|
||||
}
|
||||
return ["http", "https", "moz-extension"].some(scheme =>
|
||||
return ["http", "https", "moz-extension", "file"].some(scheme =>
|
||||
principal.schemeIs(scheme)
|
||||
);
|
||||
},
|
||||
|
|
|
@ -49,9 +49,9 @@ add_task(async function testPermissionsListing() {
|
|||
|
||||
add_task(async function testGetAllByPrincipal() {
|
||||
// check that it returns an empty array on an invalid principal
|
||||
// like a principal with a file URI, which doesn't support site permissions
|
||||
// like a principal with an about URI, which doesn't support site permissions
|
||||
let wrongPrincipal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
|
||||
"file:///example.js"
|
||||
"about:config"
|
||||
);
|
||||
Assert.deepEqual(SitePermissions.getAllByPrincipal(wrongPrincipal), []);
|
||||
|
||||
|
@ -353,3 +353,21 @@ add_task(async function testCanvasPermission() {
|
|||
resistFingerprinting
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function testFilePermissions() {
|
||||
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
|
||||
"file:///example.js"
|
||||
);
|
||||
Assert.deepEqual(SitePermissions.getAllByPrincipal(principal), []);
|
||||
|
||||
SitePermissions.setForPrincipal(principal, "camera", SitePermissions.ALLOW);
|
||||
Assert.deepEqual(SitePermissions.getAllByPrincipal(principal), [
|
||||
{
|
||||
id: "camera",
|
||||
state: SitePermissions.ALLOW,
|
||||
scope: SitePermissions.SCOPE_PERSISTENT,
|
||||
},
|
||||
]);
|
||||
SitePermissions.removeFromPrincipal(principal, "camera");
|
||||
Assert.deepEqual(SitePermissions.getAllByPrincipal(principal), []);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче