зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1733073 - Updated requestStorageAccess permission doorhanger tests. r=johannh
- Updated PermissionUI prompt test to also test permission states for prompts which do not use the permission manager - Also do permission panel checks in storageAccessDoorhanger for block state Differential Revision: https://phabricator.services.mozilla.com/D127962
This commit is contained in:
Родитель
01c38b4d38
Коммит
d3c5057f4f
|
@ -15,9 +15,6 @@ const { PermissionUI } = ChromeUtils.import(
|
||||||
const { SitePermissions } = ChromeUtils.import(
|
const { SitePermissions } = ChromeUtils.import(
|
||||||
"resource:///modules/SitePermissions.jsm"
|
"resource:///modules/SitePermissions.jsm"
|
||||||
);
|
);
|
||||||
const { PermissionTestUtils } = ChromeUtils.import(
|
|
||||||
"resource://testing-common/PermissionTestUtils.jsm"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Tests that GeolocationPermissionPrompt works as expected
|
// Tests that GeolocationPermissionPrompt works as expected
|
||||||
add_task(async function test_geo_permission_prompt() {
|
add_task(async function test_geo_permission_prompt() {
|
||||||
|
@ -73,12 +70,15 @@ async function testPrompt(Prompt) {
|
||||||
let mockRequest = makeMockPermissionRequest(browser);
|
let mockRequest = makeMockPermissionRequest(browser);
|
||||||
let principal = mockRequest.principal;
|
let principal = mockRequest.principal;
|
||||||
let TestPrompt = new Prompt(mockRequest);
|
let TestPrompt = new Prompt(mockRequest);
|
||||||
let permissionKey =
|
let { usePermissionManager, permissionKey } = TestPrompt;
|
||||||
TestPrompt.usePermissionManager && TestPrompt.permissionKey;
|
|
||||||
|
|
||||||
registerCleanupFunction(function() {
|
registerCleanupFunction(function() {
|
||||||
if (permissionKey) {
|
if (permissionKey) {
|
||||||
PermissionTestUtils.remove(principal.URI, permissionKey);
|
SitePermissions.removeFromPrincipal(
|
||||||
|
principal,
|
||||||
|
permissionKey,
|
||||||
|
browser
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -183,16 +183,26 @@ async function testPrompt(Prompt) {
|
||||||
);
|
);
|
||||||
await clickSecondaryAction(secondaryActionToClickIndex);
|
await clickSecondaryAction(secondaryActionToClickIndex);
|
||||||
if (permissionKey) {
|
if (permissionKey) {
|
||||||
curPerm = PermissionTestUtils.getPermissionObject(
|
curPerm = SitePermissions.getForPrincipal(
|
||||||
principal.URI,
|
principal,
|
||||||
permissionKey
|
permissionKey,
|
||||||
|
browser
|
||||||
);
|
);
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
curPerm.capability,
|
curPerm.state,
|
||||||
Services.perms.DENY_ACTION,
|
SitePermissions.BLOCK,
|
||||||
"Should have denied the action"
|
"Should have denied the action"
|
||||||
);
|
);
|
||||||
Assert.equal(curPerm.expireTime, 0, "Deny should be permanent");
|
|
||||||
|
let expectedScope = usePermissionManager
|
||||||
|
? SitePermissions.SCOPE_PERSISTENT
|
||||||
|
: SitePermissions.SCOPE_TEMPORARY;
|
||||||
|
Assert.equal(
|
||||||
|
curPerm.scope,
|
||||||
|
expectedScope,
|
||||||
|
`Deny should be ${usePermissionManager ? "persistent" : "temporary"}`
|
||||||
|
);
|
||||||
|
|
||||||
Assert.ok(
|
Assert.ok(
|
||||||
mockRequest._cancelled,
|
mockRequest._cancelled,
|
||||||
"The request should have been cancelled"
|
"The request should have been cancelled"
|
||||||
|
@ -203,11 +213,7 @@ async function testPrompt(Prompt) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SitePermissions.removeFromPrincipal(
|
SitePermissions.removeFromPrincipal(principal, permissionKey, browser);
|
||||||
principal,
|
|
||||||
TestPrompt.permissionKey,
|
|
||||||
browser
|
|
||||||
);
|
|
||||||
mockRequest._cancelled = false;
|
mockRequest._cancelled = false;
|
||||||
|
|
||||||
// Bring the PopupNotification back up now...
|
// Bring the PopupNotification back up now...
|
||||||
|
@ -223,17 +229,24 @@ async function testPrompt(Prompt) {
|
||||||
popupNotification.checkbox.checked = true;
|
popupNotification.checkbox.checked = true;
|
||||||
|
|
||||||
await clickMainAction();
|
await clickMainAction();
|
||||||
if (permissionKey) {
|
// If the prompt does not use the permission manager, it can not set a
|
||||||
curPerm = PermissionTestUtils.getPermissionObject(
|
// persistent allow. Temporary allow is not supported.
|
||||||
principal.URI,
|
if (usePermissionManager && permissionKey) {
|
||||||
permissionKey
|
curPerm = SitePermissions.getForPrincipal(
|
||||||
|
principal,
|
||||||
|
permissionKey,
|
||||||
|
browser
|
||||||
);
|
);
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
curPerm.capability,
|
curPerm.state,
|
||||||
Services.perms.ALLOW_ACTION,
|
SitePermissions.ALLOW,
|
||||||
"Should have allowed the action"
|
"Should have allowed the action"
|
||||||
);
|
);
|
||||||
Assert.equal(curPerm.expireTime, 0, "Allow should be permanent");
|
Assert.equal(
|
||||||
|
curPerm.scope,
|
||||||
|
SitePermissions.SCOPE_PERSISTENT,
|
||||||
|
"Allow should be permanent"
|
||||||
|
);
|
||||||
Assert.ok(
|
Assert.ok(
|
||||||
!mockRequest._cancelled,
|
!mockRequest._cancelled,
|
||||||
"The request should not have been cancelled"
|
"The request should not have been cancelled"
|
||||||
|
|
|
@ -225,7 +225,7 @@ async function testDoorHanger(
|
||||||
} else {
|
} else {
|
||||||
await Promise.all([ct, permChanged]);
|
await Promise.all([ct, permChanged]);
|
||||||
}
|
}
|
||||||
if (choice != BLOCK) {
|
|
||||||
let permissionPopupPromise = BrowserTestUtils.waitForEvent(
|
let permissionPopupPromise = BrowserTestUtils.waitForEvent(
|
||||||
window,
|
window,
|
||||||
"popupshown",
|
"popupshown",
|
||||||
|
@ -256,7 +256,6 @@ async function testDoorHanger(
|
||||||
);
|
);
|
||||||
gPermissionPanel._permissionPopup.hidePopup();
|
gPermissionPanel._permissionPopup.hidePopup();
|
||||||
await permissionPopupPromise;
|
await permissionPopupPromise;
|
||||||
}
|
|
||||||
|
|
||||||
BrowserTestUtils.removeTab(tab);
|
BrowserTestUtils.removeTab(tab);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче