зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1578710 Bug - 1578710 Don't show persistent storage permission on moz-extension pages. r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D67780 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
069ef2ef55
Коммит
1c29492230
|
@ -167,6 +167,7 @@ skip-if = (verify && debug && (os == 'mac'))
|
|||
[browser_ext_pageAction_simple.js]
|
||||
[browser_ext_pageAction_telemetry.js]
|
||||
[browser_ext_pageAction_title.js]
|
||||
[browser_ext_persistent_storage_permission_indication.js]
|
||||
[browser_ext_popup_api_injection.js]
|
||||
[browser_ext_popup_background.js]
|
||||
[browser_ext_popup_corners.js]
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/* -- Mode: indent-tabs-mode: nil; js-indent-level: 2 -- */
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
const { PermissionTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/PermissionTestUtils.jsm"
|
||||
);
|
||||
|
||||
function openIdentityPopup() {
|
||||
let promise = BrowserTestUtils.waitForEvent(
|
||||
gIdentityHandler._identityPopup,
|
||||
"popupshown"
|
||||
);
|
||||
gIdentityHandler._identityBox.click();
|
||||
return promise;
|
||||
}
|
||||
|
||||
function closeIdentityPopup() {
|
||||
let promise = BrowserTestUtils.waitForEvent(
|
||||
gIdentityHandler._identityPopup,
|
||||
"popuphidden"
|
||||
);
|
||||
gIdentityHandler._identityPopup.hidePopup();
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function testIdentityPopup({ expectPermissionHidden }) {
|
||||
await openIdentityPopup();
|
||||
|
||||
let permissionsGrantedIcon = document.getElementById(
|
||||
"permissions-granted-icon"
|
||||
);
|
||||
|
||||
let permissionsList = document.getElementById(
|
||||
"identity-popup-permission-list"
|
||||
);
|
||||
|
||||
if (expectPermissionHidden) {
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(permissionsGrantedIcon),
|
||||
"Permission Granted Icon is hidden"
|
||||
);
|
||||
|
||||
is(
|
||||
permissionsList.querySelectorAll(
|
||||
".identity-popup-permission-label-persistent-storage"
|
||||
).length,
|
||||
0,
|
||||
"Persistent storage Permission should be hidden"
|
||||
);
|
||||
} else {
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(permissionsGrantedIcon),
|
||||
"Permission Granted Icon is visible"
|
||||
);
|
||||
}
|
||||
|
||||
await closeIdentityPopup();
|
||||
}
|
||||
|
||||
add_task(async function testPersistentStoragePermissionHidden() {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
background() {
|
||||
browser.test.sendMessage("url", browser.extension.getURL("icon.png"));
|
||||
},
|
||||
manifest: {
|
||||
name: "Test Extension",
|
||||
permissions: ["unlimitedStorage"],
|
||||
},
|
||||
files: {
|
||||
"icon.png": "",
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
|
||||
let url = await extension.awaitMessage("url");
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function() {
|
||||
await testIdentityPopup({ expectPermissionHidden: true });
|
||||
});
|
||||
|
||||
await extension.unload();
|
||||
});
|
||||
|
||||
add_task(async function testPersistentStoragePermissionVisible() {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
background() {
|
||||
browser.test.sendMessage("url", browser.extension.getURL("icon.png"));
|
||||
},
|
||||
manifest: {
|
||||
name: "Test Extension",
|
||||
},
|
||||
files: {
|
||||
"icon.png": "",
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
|
||||
let url = await extension.awaitMessage("url");
|
||||
|
||||
let policy = WebExtensionPolicy.getByID(extension.id);
|
||||
let principal = policy.extension.principal;
|
||||
PermissionTestUtils.add(
|
||||
principal,
|
||||
"persistent-storage",
|
||||
Services.perms.ALLOW_ACTION
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function() {
|
||||
await testIdentityPopup({ expectPermissionHidden: false });
|
||||
});
|
||||
|
||||
await extension.unload();
|
||||
});
|
|
@ -302,6 +302,18 @@ var SitePermissions = {
|
|||
if (permission.type == "canvas" && !this.resistFingerprinting) {
|
||||
continue;
|
||||
}
|
||||
/* Hide persistent storage permission when extension principal
|
||||
* have WebExtensions-unlimitedStorage permission. */
|
||||
|
||||
if (
|
||||
permission.type == "persistent-storage" &&
|
||||
SitePermissions.getForPrincipal(
|
||||
principal,
|
||||
"WebExtensions-unlimitedStorage"
|
||||
).state == SitePermissions.ALLOW
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let scope = this.SCOPE_PERSISTENT;
|
||||
if (permission.expireType == Services.perms.EXPIRE_SESSION) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче