Bug 1596897 - Updated tests for decoupled permissions panel. r=johannh,remote-protocol-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D99893
This commit is contained in:
Paul Zuehlcke 2021-02-05 13:40:42 +00:00
parent 66fe5653ff
commit cbda00d7e1
31 changed files with 359 additions and 327 deletions

View File

@ -145,7 +145,7 @@ add_task(async () => {
is(rootChildCount(), 5, "Root has 5 children");
// Open site identity popup
document.getElementById("identity-box").click();
document.getElementById("identity-icon-box").click();
const identityPopup = document.getElementById("identity-popup");
await BrowserTestUtils.waitForPopupEvent(identityPopup, "shown");

View File

@ -21,7 +21,9 @@ add_task(async function test_identityPopupCausesFSExit() {
BrowserTestUtils.loadURI(browser, url);
await loaded;
let identityBox = document.getElementById("identity-box");
let identityPermissionBox = document.getElementById(
"identity-permission-box"
);
info("Entering DOM fullscreen");
await changeFullscreen(browser, true);
@ -30,16 +32,16 @@ add_task(async function test_identityPopupCausesFSExit() {
window,
"popupshown",
true,
event => event.target == document.getElementById("identity-popup")
event => event.target == document.getElementById("permission-popup")
);
let fsExit = waitForFullScreenState(browser, false);
identityBox.click();
identityPermissionBox.click();
info("Waiting for fullscreen exit and identity popup to show");
info("Waiting for fullscreen exit and permission popup to show");
await Promise.all([fsExit, popupShown]);
let identityPopup = document.getElementById("identity-popup");
let identityPopup = document.getElementById("permission-popup");
ok(
identityPopup.hasAttribute("panelopen"),
"Identity popup should be open"

View File

@ -20,7 +20,7 @@ add_task(async function() {
true,
event => event.target == gIdentityHandler._identityPopup
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
await promisePanelOpen;
let promiseViewShown = BrowserTestUtils.waitForEvent(

View File

@ -24,7 +24,7 @@ async function test() {
gURLBar.setPageProxyState("valid");
let result = await EventUtils.synthesizePlainDragAndCancel(
{
srcElement: document.getElementById("identity-box"),
srcElement: document.getElementById("identity-icon-box"),
},
expected
);

View File

@ -353,18 +353,25 @@ add_task(async function testPanelCloseRestoresFocus() {
// Test that the arrow key works in the group of the
// 'tracking-protection-icon-container' and the 'identity-box'.
add_task(async function testArrowKeyForTPIconContainerandIdentityBox() {
await BrowserTestUtils.withNewTab("https://example.com", async function() {
await BrowserTestUtils.withNewTab("https://example.com", async function(
browser
) {
// Simulate geo sharing so the permission box shows
gBrowser.updateBrowserSharing(browser, { geo: true });
await waitUntilReloadEnabled();
startFromUrlBar();
await expectFocusAfterKey(
"Shift+Tab",
"tracking-protection-icon-container"
);
await expectFocusAfterKey("ArrowRight", "identity-box");
await expectFocusAfterKey("ArrowRight", "identity-icon-box");
await expectFocusAfterKey("ArrowRight", "identity-permission-box");
await expectFocusAfterKey("ArrowLeft", "identity-icon-box");
await expectFocusAfterKey(
"ArrowLeft",
"tracking-protection-icon-container"
);
gBrowser.updateBrowserSharing(browser, { geo: false });
});
});

View File

@ -29,23 +29,23 @@ const EMPTY_PAGE =
const AUTOPLAY_PREF = "media.autoplay.default";
const AUTOPLAY_PERM = "autoplay-media";
function openIdentityPopup() {
function openPermissionPopup() {
let promise = BrowserTestUtils.waitForEvent(
gBrowser.ownerGlobal,
"popupshown",
true,
event => event.target == gIdentityHandler._identityPopup
event => event.target == gPermissionPanel._permissionPopup
);
gIdentityHandler._identityBox.click();
gPermissionPanel._identityPermissionBox.click();
return promise;
}
function closeIdentityPopup() {
function closePermissionPopup() {
let promise = BrowserTestUtils.waitForEvent(
gIdentityHandler._identityPopup,
gPermissionPanel._permissionPopup,
"popuphidden"
);
gIdentityHandler._identityPopup.hidePopup();
gPermissionPanel._permissionPopup.hidePopup();
return promise;
}
@ -58,7 +58,7 @@ function autoplayBlockedIcon() {
function permissionListBlockedIcons() {
return document.querySelectorAll(
"image.identity-popup-permission-icon.blocked-permission-icon"
"image.permission-popup-permission-icon.blocked-permission-icon"
);
}
@ -79,6 +79,20 @@ async function blockedIconHidden() {
}, "Blocked icon is hidden");
}
function testPermListHasEntries(expectEntries) {
let permissionsList = document.getElementById(
"permission-popup-permission-list"
);
let listEntryCount = permissionsList.querySelectorAll(
".permission-popup-permission-item"
).length;
if (expectEntries) {
ok(listEntryCount, "List of permissions is not empty");
return;
}
ok(!listEntryCount, "List of permissions is empty");
}
add_task(async function setup() {
registerCleanupFunction(() => {
Services.perms.removeAll();
@ -90,44 +104,36 @@ add_task(async function testMainViewVisible() {
Services.prefs.setIntPref(AUTOPLAY_PREF, Ci.nsIAutoplay.ALLOWED);
await BrowserTestUtils.withNewTab(AUTOPLAY_PAGE, async function() {
let permissionsList = document.getElementById(
"identity-popup-permission-list"
);
let emptyLabel = permissionsList.nextElementSibling.nextElementSibling;
ok(
BrowserTestUtils.is_hidden(autoplayBlockedIcon()),
"Blocked icon not shown"
);
await openIdentityPopup();
ok(!BrowserTestUtils.is_hidden(emptyLabel), "List of permissions is empty");
await closeIdentityPopup();
await openPermissionPopup();
testPermListHasEntries(false);
await closePermissionPopup();
});
Services.prefs.setIntPref(AUTOPLAY_PREF, Ci.nsIAutoplay.BLOCKED);
await BrowserTestUtils.withNewTab(AUTOPLAY_PAGE, async function(browser) {
let permissionsList = document.getElementById(
"identity-popup-permission-list"
"permission-popup-permission-list"
);
let emptyLabel = permissionsList.nextElementSibling.nextElementSibling;
await blockedIconShown();
await openIdentityPopup();
ok(
BrowserTestUtils.is_hidden(emptyLabel),
"List of permissions is not empty"
);
await openPermissionPopup();
testPermListHasEntries(true);
let labelText = SitePermissions.getPermissionLabel(AUTOPLAY_PERM);
let labels = permissionsList.querySelectorAll(
".identity-popup-permission-label"
".permission-popup-permission-label"
);
is(labels.length, 1, "One permission visible in main view");
is(labels[0].textContent, labelText, "Correct value");
let menulist = document.getElementById("identity-popup-popup-menulist");
let menulist = document.getElementById("permission-popup-menulist");
Assert.equal(menulist.label, "Block Audio");
await EventUtils.synthesizeMouseAtCenter(menulist, { type: "mousedown" });
@ -143,7 +149,7 @@ add_task(async function testMainViewVisible() {
menuitem.click();
menulist.menupopup.hidePopup();
await closeIdentityPopup();
await closePermissionPopup();
let uri = Services.io.newURI(AUTOPLAY_PAGE);
let state = PermissionTestUtils.getPermissionObject(uri, AUTOPLAY_PERM)
@ -311,7 +317,7 @@ add_task(async function testBlockedAll() {
BrowserTestUtils.loadURI(browser, MUTED_AUTOPLAY_PAGE);
await blockedIconShown();
await openIdentityPopup();
await openPermissionPopup();
Assert.equal(
permissionListBlockedIcons().length,
@ -319,7 +325,7 @@ add_task(async function testBlockedAll() {
"Blocked icon is shown"
);
let menulist = document.getElementById("identity-popup-popup-menulist");
let menulist = document.getElementById("permission-popup-menulist");
await EventUtils.synthesizeMouseAtCenter(menulist, { type: "mousedown" });
await TestUtils.waitForCondition(() => {
return (
@ -330,7 +336,7 @@ add_task(async function testBlockedAll() {
let menuitem = menulist.getElementsByTagName("menuitem")[0];
menuitem.click();
menulist.menupopup.hidePopup();
await closeIdentityPopup();
await closePermissionPopup();
gBrowser.reload();
await blockedIconHidden();
});

View File

@ -11,37 +11,50 @@ const kStrictKeyPressEvents = SpecialPowers.getBoolPref(
"dom.keyboardevent.keypress.dispatch_non_printable_keys_only_system_group_in_content"
);
function openIdentityPopup() {
function openPermissionPopup() {
let promise = BrowserTestUtils.waitForEvent(
window,
"popupshown",
true,
event => event.target == gIdentityHandler._identityPopup
event => event.target == gPermissionPanel._permissionPopup
);
gIdentityHandler._identityBox.click();
gPermissionPanel._identityPermissionBox.click();
return promise;
}
function closeIdentityPopup() {
function closePermissionPopup() {
let promise = BrowserTestUtils.waitForEvent(
gIdentityHandler._identityPopup,
gPermissionPanel._permissionPopup,
"popuphidden"
);
gIdentityHandler._identityPopup.hidePopup();
gPermissionPanel._permissionPopup.hidePopup();
return promise;
}
function testPermListHasEntries(expectEntries) {
let permissionsList = document.getElementById(
"permission-popup-permission-list"
);
let listEntryCount = permissionsList.querySelectorAll(
".permission-popup-permission-item"
).length;
if (expectEntries) {
ok(listEntryCount, "List of permissions is not empty");
return;
}
ok(!listEntryCount, "List of permissions is empty");
}
add_task(async function testMainViewVisible() {
await BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, async function() {
await openIdentityPopup();
await openPermissionPopup();
let permissionsList = document.getElementById(
"identity-popup-permission-list"
"permission-popup-permission-list"
);
let emptyLabel = permissionsList.nextElementSibling.nextElementSibling;
ok(!BrowserTestUtils.is_hidden(emptyLabel), "List of permissions is empty");
testPermListHasEntries(false);
await closeIdentityPopup();
await closePermissionPopup();
PermissionTestUtils.add(
gBrowser.currentURI,
@ -49,35 +62,32 @@ add_task(async function testMainViewVisible() {
Services.perms.ALLOW_ACTION
);
await openIdentityPopup();
await openPermissionPopup();
ok(
BrowserTestUtils.is_hidden(emptyLabel),
"List of permissions is not empty"
);
testPermListHasEntries(true);
let labelText = SitePermissions.getPermissionLabel("camera");
let labels = permissionsList.querySelectorAll(
".identity-popup-permission-label"
".permission-popup-permission-label"
);
is(labels.length, 1, "One permission visible in main view");
is(labels[0].textContent, labelText, "Correct value");
let img = permissionsList.querySelector(
"image.identity-popup-permission-icon"
"image.permission-popup-permission-icon"
);
ok(img, "There is an image for the permissions");
ok(img.classList.contains("camera-icon"), "proper class is in image class");
await closeIdentityPopup();
await closePermissionPopup();
PermissionTestUtils.remove(gBrowser.currentURI, "camera");
await openIdentityPopup();
await openPermissionPopup();
ok(!BrowserTestUtils.is_hidden(emptyLabel), "List of permissions is empty");
testPermListHasEntries(false);
await closeIdentityPopup();
await closePermissionPopup();
});
});
@ -90,14 +100,18 @@ add_task(async function testIdentityIcon() {
);
ok(
gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
gPermissionPanel._identityPermissionBox.hasAttribute(
"hasGrantedPermissions"
),
"identity-box signals granted permissions"
);
PermissionTestUtils.remove(gBrowser.currentURI, "geo");
ok(
!gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
!gPermissionPanel._identityPermissionBox.hasAttribute(
"hasGrantedPermissions"
),
"identity-box doesn't signal granted permissions"
);
@ -108,7 +122,9 @@ add_task(async function testIdentityIcon() {
);
ok(
!gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
!gPermissionPanel._identityPermissionBox.hasAttribute(
"hasGrantedPermissions"
),
"identity-box doesn't signal granted permissions"
);
@ -119,7 +135,9 @@ add_task(async function testIdentityIcon() {
);
ok(
gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
gPermissionPanel._identityPermissionBox.hasAttribute(
"hasGrantedPermissions"
),
"identity-box signals granted permissions"
);
@ -132,9 +150,8 @@ add_task(async function testIdentityIcon() {
add_task(async function testCancelPermission() {
await BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, async function() {
let permissionsList = document.getElementById(
"identity-popup-permission-list"
"permission-popup-permission-list"
);
let emptyLabel = permissionsList.nextElementSibling.nextElementSibling;
PermissionTestUtils.add(
gBrowser.currentURI,
@ -147,57 +164,50 @@ add_task(async function testCancelPermission() {
Services.perms.DENY_ACTION
);
await openIdentityPopup();
await openPermissionPopup();
ok(
BrowserTestUtils.is_hidden(emptyLabel),
"List of permissions is not empty"
);
testPermListHasEntries(true);
permissionsList
.querySelector(".identity-popup-permission-remove-button")
.querySelector(".permission-popup-permission-remove-button")
.click();
is(
permissionsList.querySelectorAll(".identity-popup-permission-label")
permissionsList.querySelectorAll(".permission-popup-permission-label")
.length,
1,
"First permission should be removed"
);
permissionsList
.querySelector(".identity-popup-permission-remove-button")
.querySelector(".permission-popup-permission-remove-button")
.click();
is(
permissionsList.querySelectorAll(".identity-popup-permission-label")
permissionsList.querySelectorAll(".permission-popup-permission-label")
.length,
0,
"Second permission should be removed"
);
await closeIdentityPopup();
await closePermissionPopup();
});
});
add_task(async function testPermissionHints() {
await BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, async function(browser) {
let permissionsList = document.getElementById(
"identity-popup-permission-list"
);
let emptyHint = document.getElementById(
"identity-popup-permission-empty-hint"
"permission-popup-permission-list"
);
let reloadHint = document.getElementById(
"identity-popup-permission-reload-hint"
"permission-popup-permission-reload-hint"
);
await openIdentityPopup();
await openPermissionPopup();
ok(!BrowserTestUtils.is_hidden(emptyHint), "Empty hint is visible");
ok(BrowserTestUtils.is_hidden(reloadHint), "Reload hint is hidden");
await closeIdentityPopup();
await closePermissionPopup();
PermissionTestUtils.add(
gBrowser.currentURI,
@ -210,40 +220,33 @@ add_task(async function testPermissionHints() {
Services.perms.DENY_ACTION
);
await openIdentityPopup();
await openPermissionPopup();
ok(BrowserTestUtils.is_hidden(emptyHint), "Empty hint is hidden");
ok(BrowserTestUtils.is_hidden(reloadHint), "Reload hint is hidden");
let cancelButtons = permissionsList.querySelectorAll(
".identity-popup-permission-remove-button"
".permission-popup-permission-remove-button"
);
PermissionTestUtils.remove(gBrowser.currentURI, "camera");
cancelButtons[0].click();
ok(BrowserTestUtils.is_hidden(emptyHint), "Empty hint is hidden");
ok(!BrowserTestUtils.is_hidden(reloadHint), "Reload hint is visible");
cancelButtons[1].click();
ok(BrowserTestUtils.is_hidden(emptyHint), "Empty hint is hidden");
ok(!BrowserTestUtils.is_hidden(reloadHint), "Reload hint is visible");
await closeIdentityPopup();
await closePermissionPopup();
let loaded = BrowserTestUtils.browserLoaded(browser);
BrowserTestUtils.loadURI(browser, PERMISSIONS_PAGE);
await loaded;
await openIdentityPopup();
await openPermissionPopup();
ok(
!BrowserTestUtils.is_hidden(emptyHint),
"Empty hint is visible after reloading"
);
ok(
BrowserTestUtils.is_hidden(reloadHint),
"Reload hint is hidden after reloading"
);
await closeIdentityPopup();
await closePermissionPopup();
});
});
@ -260,12 +263,12 @@ add_task(async function testPermissionIcons() {
Services.perms.DENY_ACTION
);
let geoIcon = gIdentityHandler._identityBox.querySelector(
let geoIcon = gPermissionPanel._identityPermissionBox.querySelector(
".blocked-permission-icon[data-permission-id='geo']"
);
ok(geoIcon.hasAttribute("showing"), "blocked permission icon is shown");
let cameraIcon = gIdentityHandler._identityBox.querySelector(
let cameraIcon = gPermissionPanel._identityPermissionBox.querySelector(
".blocked-permission-icon[data-permission-id='camera']"
);
ok(
@ -374,7 +377,7 @@ add_task(async function testPolicyPermission() {
});
let permissionsList = document.getElementById(
"identity-popup-permission-list"
"permission-popup-permission-list"
);
PermissionTestUtils.add(
gBrowser.currentURI,
@ -383,18 +386,20 @@ add_task(async function testPolicyPermission() {
Services.perms.EXPIRE_POLICY
);
await openIdentityPopup();
await openPermissionPopup();
// Check if the icon, nameLabel and stateLabel are visible.
let img, labelText, labels;
img = permissionsList.querySelector("image.identity-popup-permission-icon");
img = permissionsList.querySelector(
"image.permission-popup-permission-icon"
);
ok(img, "There is an image for the popup permission");
ok(img.classList.contains("popup-icon"), "proper class is in image class");
labelText = SitePermissions.getPermissionLabel("popup");
labels = permissionsList.querySelectorAll(
".identity-popup-permission-label"
".permission-popup-permission-label"
);
is(labels.length, 1, "One permission visible in main view");
is(labels[0].textContent, labelText, "Correct name label value");
@ -404,36 +409,36 @@ add_task(async function testPolicyPermission() {
SitePermissions.SCOPE_POLICY
);
labels = permissionsList.querySelectorAll(
".identity-popup-permission-state-label"
".permission-popup-permission-state-label"
);
is(labels[0].textContent, labelText, "Correct state label value");
// Check if the menulist and the remove button are hidden.
// The menulist is specific to the "popup" permission.
let menulist = document.getElementById("identity-popup-popup-menulist");
let menulist = document.getElementById("permission-popup-menulist");
ok(menulist == null, "The popup permission menulist is not visible");
let removeButton = permissionsList.querySelector(
".identity-popup-permission-remove-button"
".permission-popup-permission-remove-button"
);
ok(removeButton == null, "The permission remove button is not visible");
Services.perms.removeAll();
await closeIdentityPopup();
await closePermissionPopup();
});
});
add_task(async function testHiddenAfterRefresh() {
await BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, async function(browser) {
ok(
BrowserTestUtils.is_hidden(gIdentityHandler._identityPopup),
BrowserTestUtils.is_hidden(gPermissionPanel._permissionPopup),
"Popup is hidden"
);
await openIdentityPopup();
await openPermissionPopup();
ok(
!BrowserTestUtils.is_hidden(gIdentityHandler._identityPopup),
!BrowserTestUtils.is_hidden(gPermissionPanel._permissionPopup),
"Popup is shown"
);
@ -446,7 +451,7 @@ add_task(async function testHiddenAfterRefresh() {
await reloaded;
ok(
BrowserTestUtils.is_hidden(gIdentityHandler._identityPopup),
BrowserTestUtils.is_hidden(gPermissionPanel._permissionPopup),
"Popup is hidden"
);
});
@ -462,22 +467,23 @@ add_task(async function test3rdPartyStoragePermission() {
});
await BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, async function(browser) {
await openIdentityPopup();
await openPermissionPopup();
let permissionsList = document.getElementById(
"identity-popup-permission-list"
"permission-popup-permission-list"
);
let storagePermissionAnchor = permissionsList.querySelector(
`.identity-popup-permission-list-anchor[anchorfor="3rdPartyStorage"]`
`.permission-popup-permission-list-anchor[anchorfor="3rdPartyStorage"]`
);
let emptyLabel = permissionsList.nextElementSibling.nextElementSibling;
ok(!BrowserTestUtils.is_hidden(emptyLabel), "List of permissions is empty");
testPermListHasEntries(false);
ok(
BrowserTestUtils.is_hidden(storagePermissionAnchor.firstElementChild),
"Anchor header is hidden"
);
await closeIdentityPopup();
await closePermissionPopup();
let storagePermissionID = "3rdPartyStorage^example2.com";
PermissionTestUtils.add(
@ -486,12 +492,9 @@ add_task(async function test3rdPartyStoragePermission() {
Services.perms.ALLOW_ACTION
);
await openIdentityPopup();
await openPermissionPopup();
ok(
BrowserTestUtils.is_hidden(emptyLabel),
"List of permissions is not empty"
);
testPermListHasEntries(true);
ok(
BrowserTestUtils.is_visible(storagePermissionAnchor.firstElementChild),
"Anchor header is visible"
@ -499,7 +502,7 @@ add_task(async function test3rdPartyStoragePermission() {
let labelText = SitePermissions.getPermissionLabel(storagePermissionID);
let labels = storagePermissionAnchor.querySelectorAll(
".identity-popup-permission-label"
".permission-popup-permission-label"
);
is(labels.length, 1, "One permission visible in 3rdPartyStorage anchor");
is(
@ -508,7 +511,7 @@ add_task(async function test3rdPartyStoragePermission() {
"Permission label has the correct value"
);
await closeIdentityPopup();
await closePermissionPopup();
PermissionTestUtils.add(
browser.currentURI,
@ -516,32 +519,29 @@ add_task(async function test3rdPartyStoragePermission() {
Services.perms.ALLOW_ACTION
);
await openIdentityPopup();
await openPermissionPopup();
ok(
BrowserTestUtils.is_hidden(emptyLabel),
"List of permissions is not empty"
);
testPermListHasEntries(true);
ok(
BrowserTestUtils.is_visible(storagePermissionAnchor.firstElementChild),
"Anchor header is visible"
);
labels = permissionsList.querySelectorAll(
".identity-popup-permission-label"
".permission-popup-permission-label"
);
is(labels.length, 2, "Two permissions visible in main view");
labels = storagePermissionAnchor.querySelectorAll(
".identity-popup-permission-label"
".permission-popup-permission-label"
);
is(labels.length, 1, "One permission visible in 3rdPartyStorage anchor");
storagePermissionAnchor
.querySelector(".identity-popup-permission-remove-button")
.querySelector(".permission-popup-permission-remove-button")
.click();
is(
storagePermissionAnchor.querySelectorAll(
".identity-popup-permission-label"
".permission-popup-permission-label"
).length,
0,
"Permission item should be removed"
@ -555,36 +555,33 @@ add_task(async function test3rdPartyStoragePermission() {
"Permission removed from permission manager"
);
await closeIdentityPopup();
await closePermissionPopup();
await openIdentityPopup();
await openPermissionPopup();
ok(
BrowserTestUtils.is_hidden(emptyLabel),
"List of permissions is not empty"
);
testPermListHasEntries(true);
ok(
BrowserTestUtils.is_hidden(storagePermissionAnchor.firstElementChild),
"Anchor header is hidden"
);
labels = permissionsList.querySelectorAll(
".identity-popup-permission-label"
".permission-popup-permission-label"
);
is(labels.length, 1, "One permission visible in main view");
await closeIdentityPopup();
await closePermissionPopup();
PermissionTestUtils.remove(browser.currentURI, "camera");
await openIdentityPopup();
await openPermissionPopup();
ok(!BrowserTestUtils.is_hidden(emptyLabel), "List of permissions is empty");
testPermListHasEntries(false);
ok(
BrowserTestUtils.is_hidden(storagePermissionAnchor.firstElementChild),
"Anchor header is hidden"
);
await closeIdentityPopup();
await closePermissionPopup();
});
});

View File

@ -44,7 +44,7 @@ add_task(async function testTempPermissionRequestAfterExpiry() {
await BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, async function(
browser
) {
let blockedIcon = gIdentityHandler._identityBox.querySelector(
let blockedIcon = gPermissionPanel._identityPermissionBox.querySelector(
`.blocked-permission-icon[data-permission-id='${id}']`
);

View File

@ -22,23 +22,23 @@ const PRINCIPAL = Services.scriptSecurityManager.createContentPrincipal(
{}
);
function openIdentityPopup() {
function openPermissionPopup() {
let promise = BrowserTestUtils.waitForEvent(
window,
"popupshown",
true,
event => event.target == gIdentityHandler._identityPopup
event => event.target == gPermissionPanel._permissionPopup
);
gIdentityHandler._identityBox.click();
gPermissionPanel._identityPermissionBox.click();
return promise;
}
function closeIdentityPopup() {
function closePermissionPopup() {
let promise = BrowserTestUtils.waitForEvent(
gIdentityHandler._identityPopup,
gPermissionPanel._permissionPopup,
"popuphidden"
);
gIdentityHandler._identityPopup.hidePopup();
gPermissionPanel._permissionPopup.hidePopup();
return promise;
}
@ -56,12 +56,12 @@ add_task(async function check_blocked_popup_indicator() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
// Blocked popup indicator should not exist in the identity popup when there are no blocked popups.
await openIdentityPopup();
await openPermissionPopup();
Assert.equal(document.getElementById("blocked-popup-indicator-item"), null);
await closeIdentityPopup();
await closePermissionPopup();
// Blocked popup notification icon should be hidden in the identity block when no popups are blocked.
let icon = gIdentityHandler._identityBox.querySelector(
let icon = gPermissionPanel._identityPermissionBox.querySelector(
".blocked-permission-icon[data-permission-id='popup']"
);
Assert.equal(icon.hasAttribute("showing"), false);
@ -77,18 +77,18 @@ add_task(async function check_blocked_popup_indicator() {
);
// Check if blocked popup indicator text is visible in the identity popup. It should be visible.
document.getElementById("identity-icon").click();
await openIdentityPopup();
document.getElementById("identity-permission-box").click();
await openPermissionPopup();
await TestUtils.waitForCondition(
() => document.getElementById("blocked-popup-indicator-item") !== null
);
// Check that the default state is correctly set to "Block".
let menulist = document.getElementById("identity-popup-popup-menulist");
let menulist = document.getElementById("permission-popup-menulist");
Assert.equal(menulist.value, "0");
Assert.equal(menulist.label, "Block");
await closeIdentityPopup();
await closePermissionPopup();
// Check if blocked popup icon is visible in the identity block.
Assert.equal(icon.getAttribute("showing"), "true");
@ -118,7 +118,7 @@ add_task(async function check_popup_showing() {
gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen);
// Open identity popup and click on "Show blocked popups".
await openIdentityPopup();
await openPermissionPopup();
let e = document.getElementById("blocked-popup-indicator-item");
let text = e.getElementsByTagName("label")[0];
text.click();
@ -159,12 +159,12 @@ add_task(async function check_permission_state_change() {
);
// Open identity popup and change permission state to allow.
await openIdentityPopup();
let menulist = document.getElementById("identity-popup-popup-menulist");
await openPermissionPopup();
let menulist = document.getElementById("permission-popup-menulist");
menulist.menupopup.openPopup(); // Open the allow/block menu
let menuitem = menulist.getElementsByTagName("menuitem")[0];
menuitem.click();
await closeIdentityPopup();
await closePermissionPopup();
state = SitePermissions.getForPrincipal(PRINCIPAL, "popup", gBrowser).state;
Assert.equal(state, SitePermissions.ALLOW);
@ -198,12 +198,12 @@ add_task(async function check_permission_state_change() {
gBrowser.removeTab(popup);
// Open identity popup and change permission state to block.
await openIdentityPopup();
menulist = document.getElementById("identity-popup-popup-menulist");
await openPermissionPopup();
menulist = document.getElementById("permission-popup-menulist");
menulist.menupopup.openPopup(); // Open the allow/block menu
menuitem = menulist.getElementsByTagName("menuitem")[1];
menuitem.click();
await closeIdentityPopup();
await closePermissionPopup();
// Clicking on the "Block" menuitem should remove the permission object(same behavior as UNKNOWN state).
// We have already confirmed that popups are blocked when the permission state is BLOCK.
@ -222,19 +222,19 @@ add_task(async function check_explicit_default_permission() {
// since SitePermissions.jsm considers setting default permissions to be removal.
PermissionTestUtils.add(URI, "popup", Ci.nsIPermissionManager.DENY_ACTION);
await openIdentityPopup();
let menulist = document.getElementById("identity-popup-popup-menulist");
await openPermissionPopup();
let menulist = document.getElementById("permission-popup-menulist");
Assert.equal(menulist.value, "0");
Assert.equal(menulist.label, "Block");
await closeIdentityPopup();
await closePermissionPopup();
PermissionTestUtils.add(URI, "popup", Services.perms.ALLOW_ACTION);
await openIdentityPopup();
menulist = document.getElementById("identity-popup-popup-menulist");
await openPermissionPopup();
menulist = document.getElementById("permission-popup-menulist");
Assert.equal(menulist.value, "1");
Assert.equal(menulist.label, "Allow");
await closeIdentityPopup();
await closePermissionPopup();
PermissionTestUtils.remove(URI, "popup");
gBrowser.removeTab(tab);

View File

@ -328,7 +328,7 @@ add_task(async function testCookiesSubViewAllowed() {
);
let button = listItem.querySelector(
".identity-popup-permission-remove-button"
".permission-popup-permission-remove-button"
);
ok(
BrowserTestUtils.is_visible(button),
@ -431,7 +431,7 @@ add_task(async function testCookiesSubViewAllowedHeuristic() {
);
let button = listItem.querySelector(
".identity-popup-permission-remove-button"
".permission-popup-permission-remove-button"
);
ok(
BrowserTestUtils.is_visible(button),
@ -501,7 +501,7 @@ add_task(async function testCookiesSubViewBlockedDoublyNested() {
);
let button = listItem.querySelector(
".identity-popup-permission-remove-button"
".permission-popup-permission-remove-button"
);
ok(!button, "Permission remove button doesn't exist");

View File

@ -20,14 +20,14 @@ function getIdentityMode(aWindow = window) {
function getConnectionState() {
// Prevents items that are being lazy loaded causing issues
document.getElementById("identity-box").click();
document.getElementById("identity-icon-box").click();
gIdentityHandler.refreshIdentityPopup();
return document.getElementById("identity-popup").getAttribute("connection");
}
function getSecurityConnectionBG() {
// Get the background image of the security connection.
document.getElementById("identity-box").click();
document.getElementById("identity-icon-box").click();
gIdentityHandler.refreshIdentityPopup();
return gBrowser.ownerGlobal
.getComputedStyle(
@ -40,7 +40,7 @@ function getSecurityConnectionBG() {
function getReaderModeURL() {
// Gets the reader mode URL from "identity-popup mainView panel header span"
document.getElementById("identity-box").click();
document.getElementById("identity-icon-box").click();
gIdentityHandler.refreshIdentityPopup();
return document.getElementById("identity-popup-mainView-panel-header-span")
.innerHTML;

View File

@ -64,7 +64,7 @@ async function checkForDOMElement(state, id) {
return el;
}
async function testIdentityPopupGeoContainer(
async function testPermissionPopupGeoContainer(
containerVisible,
timestampVisible
) {
@ -74,14 +74,14 @@ async function testIdentityPopupGeoContainer(
ok(false, "Can't have timestamp without container");
}
// Only call openIdentityPopup if popup is closed, otherwise it does not resolve
if (!gIdentityHandler._identityBox.hasAttribute("open")) {
await openIdentityPopup();
// Only call openPermissionPopup if popup is closed, otherwise it does not resolve
if (!gPermissionPanel._identityPermissionBox.hasAttribute("open")) {
await openPermissionPopup();
}
let checkContainer = checkForDOMElement(
containerVisible,
"identity-popup-geo-container"
"permission-popup-geo-container"
);
if (containerVisible && timestampVisible) {
@ -90,11 +90,11 @@ async function testIdentityPopupGeoContainer(
let container = await checkContainer;
await BrowserTestUtils.waitForCondition(
() => container.childElementCount == 2,
"identity-popup-geo-container should have two elements."
"permission-popup-geo-container should have two elements."
);
is(
container.childNodes[0].classList[0],
"identity-popup-permission-item",
"permission-popup-permission-item",
"Geo container should have permission item."
);
is(
@ -249,14 +249,14 @@ async function testIndicatorExplicitAllow(persistent) {
await Promise.all([
testGeoSharingIconVisible(true),
testIdentityPopupGeoContainer(true, true),
testPermissionPopupGeoContainer(true, true),
testGeoLocationLastAccessSet(tab.linkedBrowser),
]);
await cleanup(tab);
}
// Indicator and identity popup entry shown after explicit PermissionUI geolocation allow
// Indicator and permission popup entry shown after explicit PermissionUI geolocation allow
add_task(function test_indicator_and_timestamp_after_explicit_allow() {
return testIndicatorExplicitAllow(false);
});
@ -264,7 +264,7 @@ add_task(function test_indicator_and_timestamp_after_explicit_allow_remember() {
return testIndicatorExplicitAllow(true);
});
// Indicator and identity popup entry shown after auto PermissionUI geolocation allow
// Indicator and permission popup entry shown after auto PermissionUI geolocation allow
add_task(async function test_indicator_and_timestamp_after_implicit_allow() {
PermissionTestUtils.add(
EXAMPLE_PAGE_URI,
@ -278,7 +278,7 @@ add_task(async function test_indicator_and_timestamp_after_implicit_allow() {
await Promise.all([
testGeoSharingIconVisible(true),
testIdentityPopupGeoContainer(true, true),
testPermissionPopupGeoContainer(true, true),
testGeoLocationLastAccessSet(tab.linkedBrowser),
]);
@ -295,8 +295,8 @@ add_task(function test_indicator_sharing_state_inactive() {
return testIndicatorGeoSharingState(false);
});
// Identity popup shows permission if geo permission is set to persistent allow
add_task(async function test_identity_popup_permission_scope_permanent() {
// Permission popup shows permission if geo permission is set to persistent allow
add_task(async function test_permission_popup_permission_scope_permanent() {
PermissionTestUtils.add(
EXAMPLE_PAGE_URI,
"geo",
@ -305,35 +305,35 @@ add_task(async function test_identity_popup_permission_scope_permanent() {
);
let tab = await openExamplePage();
await testIdentityPopupGeoContainer(true, false); // Expect permission to be visible, but not lastAccess indicator
await testPermissionPopupGeoContainer(true, false); // Expect permission to be visible, but not lastAccess indicator
await cleanup(tab);
});
// Sharing state set, but no permission
add_task(async function test_identity_popup_permission_sharing_state() {
add_task(async function test_permission_popup_permission_sharing_state() {
let tab = await openExamplePage();
gBrowser.updateBrowserSharing(tab.linkedBrowser, { geo: true });
await testIdentityPopupGeoContainer(true, false);
await testPermissionPopupGeoContainer(true, false);
await cleanup(tab);
});
// Identity popup has correct state if sharing state and last geo access timestamp are set
// Permission popup has correct state if sharing state and last geo access timestamp are set
add_task(
async function test_identity_popup_permission_sharing_state_timestamp() {
async function test_permission_popup_permission_sharing_state_timestamp() {
let tab = await openExamplePage();
gBrowser.updateBrowserSharing(tab.linkedBrowser, { geo: true });
await setGeoLastAccess(tab.linkedBrowser, true);
await testIdentityPopupGeoContainer(true, true);
await testPermissionPopupGeoContainer(true, true);
await cleanup(tab);
}
);
// Clicking permission clear button clears permission and resets geo sharing state
add_task(async function test_identity_popup_permission_clear() {
add_task(async function test_permission_popup_permission_clear() {
PermissionTestUtils.add(
EXAMPLE_PAGE_URI,
"geo",
@ -343,17 +343,17 @@ add_task(async function test_identity_popup_permission_clear() {
let tab = await openExamplePage();
gBrowser.updateBrowserSharing(tab.linkedBrowser, { geo: true });
await openIdentityPopup();
await openPermissionPopup();
let clearButton = document.querySelector(
"#identity-popup-geo-container button"
"#permission-popup-geo-container button"
);
ok(clearButton, "Clear button is visible");
clearButton.click();
await Promise.all([
testGeoSharingIconVisible(false),
testIdentityPopupGeoContainer(false, false),
testPermissionPopupGeoContainer(false, false),
BrowserTestUtils.waitForCondition(() => {
let sharingState = tab._sharingState;
return (
@ -370,12 +370,12 @@ add_task(async function test_identity_popup_permission_clear() {
* Tests that we only show the last access label once when the sharing
* state is updated multiple times while the popup is open.
*/
add_task(async function test_identity_no_duplicate_last_access_label() {
add_task(async function test_permission_no_duplicate_last_access_label() {
let tab = await openExamplePage();
await setGeoLastAccess(tab.linkedBrowser, true);
await openIdentityPopup();
await openPermissionPopup();
gBrowser.updateBrowserSharing(tab.linkedBrowser, { geo: true });
gBrowser.updateBrowserSharing(tab.linkedBrowser, { geo: true });
await testIdentityPopupGeoContainer(true, true);
await testPermissionPopupGeoContainer(true, true);
await cleanup(tab);
});

View File

@ -68,12 +68,12 @@ add_task(async function testWithNotifications() {
"tracking protection icon container should be focused"
);
await synthesizeKeyAndWaitForFocus(
gIdentityHandler._identityBox,
gIdentityHandler._identityIconBox,
"ArrowRight"
);
is(
document.activeElement,
gIdentityHandler._identityBox,
gIdentityHandler._identityIconBox,
"identity block should be focused"
);
let geoIcon = document.getElementById("geo-notification-icon");

View File

@ -86,7 +86,7 @@ async function runTest(options) {
true,
event => event.target == gIdentityHandler._identityPopup
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
await promisePanelOpen;
// Check if the HTTPS-Only UI is visible

View File

@ -56,7 +56,7 @@ async function testClearing(
true,
event => event.target == gIdentityHandler._identityPopup
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
await promisePanelOpen;
let clearFooter = document.getElementById(
@ -139,7 +139,7 @@ async function testClearing(
gIdentityHandler._identityPopup,
"popupshown"
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
await promisePanelOpen;
// Wait for a second to see if the button is shown.

View File

@ -21,7 +21,7 @@ add_task(async function test_https() {
event => event.target == gIdentityHandler._identityPopup
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
await promisePanelOpen;
let customRootWarning = document.getElementById(
"identity-popup-security-decription-custom-root"
@ -55,7 +55,7 @@ add_task(async function test_http() {
true,
event => event.target == gIdentityHandler._identityPopup
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
await promisePanelOpen;
let customRootWarning = document.getElementById(
"identity-popup-security-decription-custom-root"

View File

@ -6,7 +6,7 @@ async function focusIdentityBox() {
gURLBar.inputField.focus();
is(document.activeElement, gURLBar.inputField, "urlbar should be focused");
const focused = BrowserTestUtils.waitForEvent(
gIdentityHandler._identityBox,
gIdentityHandler._identityIconBox,
"focus"
);
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true });
@ -24,7 +24,7 @@ add_task(async function testIdentityPopupFocusClick() {
true,
event => event.target == gIdentityHandler._identityPopup
);
EventUtils.synthesizeMouseAtCenter(gIdentityHandler._identityBox, {});
EventUtils.synthesizeMouseAtCenter(gIdentityHandler._identityIconBox, {});
await shown;
isnot(
Services.focus.focusedElement,

View File

@ -138,7 +138,7 @@ async function runTest(i, forward) {
true,
event => event.target == gIdentityHandler._identityPopup
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
info("Waiting for the Control Center to be shown");
await popupShown;
ok(

View File

@ -6,7 +6,15 @@ function openIdentityPopup() {
gIdentityHandler._initializePopup();
let mainView = document.getElementById("identity-popup-mainView");
let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
return viewShown;
}
function openPermissionPopup() {
gPermissionPanel._initializePopup();
let mainView = document.getElementById("permission-popup-mainView");
let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
gPermissionPanel._openPopup();
return viewShown;
}
@ -247,7 +255,7 @@ async function assertMixedContentBlockingState(tabbrowser, states = {}) {
true,
event => event.target == gIdentityHandler._identityPopup
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
await promisePanelOpen;
let popupAttr = doc
.getElementById("identity-popup")

View File

@ -85,21 +85,25 @@ add_task(async function test_old_modal_ui() {
window,
"popupshown",
true,
event => event.target == gIdentityHandler._identityPopup
event => event.target == gPermissionPanel._permissionPopup
);
gIdentityHandler._identityBox.click();
gPermissionPanel._identityPermissionBox.click();
await shown;
let labelText = SitePermissions.getPermissionLabel("focus-tab-by-prompt");
let permissionsList = document.getElementById(
"identity-popup-permission-list"
"permission-popup-permission-list"
);
let label = permissionsList.querySelector(
".permission-popup-permission-label"
);
let label = permissionsList.querySelector(".identity-popup-permission-label");
is(label.textContent, labelText);
gIdentityHandler._identityPopup.hidePopup();
gPermissionPanel._permissionPopup.hidePopup();
// Check if the identity icon signals granted permission.
ok(
gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
gPermissionPanel._identityPermissionBox.hasAttribute(
"hasGrantedPermissions"
),
"identity-box signals granted permissions"
);
@ -210,22 +214,26 @@ add_task(async function test_new_modal_ui() {
window,
"popupshown",
true,
event => event.target == gIdentityHandler._identityPopup
event => event.target == gPermissionPanel._permissionPopup
);
gIdentityHandler._identityBox.click();
gPermissionPanel._identityPermissionBox.click();
await shown;
let labelText = SitePermissions.getPermissionLabel("focus-tab-by-prompt");
let permissionsList = document.getElementById(
"identity-popup-permission-list"
"permission-popup-permission-list"
);
let label = permissionsList.querySelector(
".permission-popup-permission-label"
);
let label = permissionsList.querySelector(".identity-popup-permission-label");
is(label.textContent, labelText);
gIdentityHandler._identityPopup.hidePopup();
gPermissionPanel.hidePopup();
// Check if the identity icon signals granted permission.
ok(
gIdentityHandler._identityBox.classList.contains("grantedPermissions"),
"identity-box signals granted permissions"
gPermissionPanel._identityPermissionBox.hasAttribute(
"hasGrantedPermissions"
),
"identity-permission-box signals granted permissions"
);
let openedTabSelectedPromise = BrowserTestUtils.waitForAttribute(

View File

@ -715,10 +715,10 @@ var gTests = [
},
{
desc: "test showControlCenter",
run: async function checkShowControlCenter() {
desc: "test showPermissionPanel",
run: async function checkShowPermissionPanel() {
if (!USING_LEGACY_INDICATOR) {
// The indicator only links to the control center for the
// The indicator only links to the permission panel for the
// legacy indicator.
return;
}
@ -749,7 +749,7 @@ var gTests = [
await indicator;
await checkSharingUI({ video: true });
ok(identityPopupHidden(), "control center should be hidden");
ok(permissionPopupHidden(), "permission panel should be hidden");
if (IS_MAC) {
let activeStreams = webrtcUI.getActiveStreams(true, false, false);
webrtcUI.showSharingDoorhanger(activeStreams[0]);
@ -763,12 +763,12 @@ var gTests = [
}
await TestUtils.waitForCondition(
() => !identityPopupHidden(),
"wait for control center to open"
() => !permissionPopupHidden(),
"wait for permission panel to open"
);
ok(!identityPopupHidden(), "control center should be open");
ok(!permissionPopupHidden(), "permission panel should be open");
gIdentityHandler._identityPopup.hidePopup();
gPermissionPanel._permissionPopup.hidePopup();
await closeStream();
},

View File

@ -158,7 +158,7 @@ var gTests = [
// Wait for capture state to propagate to the UI asynchronously.
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_DISABLED,
"video should be disabled"
);
@ -177,7 +177,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_ENABLED,
"audio should be enabled"
);
@ -196,7 +196,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_ENABLED,
"video should be enabled"
);
@ -258,9 +258,9 @@ var gTests = [
// Wait for capture state to propagate to the UI asynchronously.
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_DISABLED &&
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_DISABLED,
"video and audio should be disabled"
);
@ -279,7 +279,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_ENABLED,
"audio should be enabled"
);
@ -298,7 +298,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_ENABLED,
"video should be enabled"
);
@ -362,7 +362,7 @@ var gTests = [
// Wait for capture state to propagate to the UI asynchronously.
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.screen == "ScreenPaused",
window.gPermissionPanel._sharingState.webRTC.screen == "ScreenPaused",
"screen should be disabled"
);
await observerPromise;
@ -374,7 +374,7 @@ var gTests = [
await setTrackEnabled(null, true);
await BrowserTestUtils.waitForCondition(
() => window.gIdentityHandler._sharingState.webRTC.screen == "Screen",
() => window.gPermissionPanel._sharingState.webRTC.screen == "Screen",
"screen should be enabled"
);
await observerPromise;
@ -428,7 +428,7 @@ var gTests = [
// Wait for capture state to propagate to the UI asynchronously.
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_DISABLED,
"video should be muted"
);
@ -449,7 +449,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_ENABLED,
"video should be enabled"
);
@ -516,7 +516,7 @@ var gTests = [
// Wait for capture state to propagate to the UI asynchronously.
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_DISABLED,
"audio should be muted"
);
@ -537,7 +537,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_ENABLED,
"audio should be enabled"
);
@ -605,7 +605,7 @@ var gTests = [
// Wait for capture state to propagate to the UI asynchronously.
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_DISABLED,
"video should be disabled"
);
@ -631,7 +631,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_DISABLED,
"audio should be disabled"
);
@ -656,7 +656,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_ENABLED,
"audio should be enabled"
);
@ -677,7 +677,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_ENABLED,
"video should be enabled"
);
@ -703,7 +703,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_DISABLED,
"video should be disabled"
);
@ -729,7 +729,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_ENABLED,
"audio should be enabled"
);
@ -754,7 +754,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_ENABLED,
"video should be enabled"
);
@ -823,7 +823,7 @@ var gTests = [
// Wait for capture state to propagate to the UI asynchronously.
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_DISABLED,
"audio should be disabled"
);
@ -849,7 +849,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_DISABLED,
"camera should be disabled"
);
@ -874,7 +874,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_ENABLED,
"video should be enabled"
);
@ -895,7 +895,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_ENABLED,
"audio should be enabled"
);
@ -921,7 +921,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_DISABLED,
"audio should be disabled"
);
@ -947,7 +947,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.camera ==
window.gPermissionPanel._sharingState.webRTC.camera ==
STATE_CAPTURE_ENABLED,
"video should be enabled"
);
@ -972,7 +972,7 @@ var gTests = [
await BrowserTestUtils.waitForCondition(
() =>
window.gIdentityHandler._sharingState.webRTC.microphone ==
window.gPermissionPanel._sharingState.webRTC.microphone ==
STATE_CAPTURE_ENABLED,
"audio should be enabled"
);

View File

@ -664,7 +664,7 @@ var gTests = [
await indicator;
await checkSharingUI({ screen: "Screen" });
ok(identityPopupHidden(), "control center should be hidden");
ok(permissionPopupHidden(), "control center should be hidden");
if (IS_MAC) {
let activeStreams = webrtcUI.getActiveStreams(false, false, true);
webrtcUI.showSharingDoorhanger(activeStreams[0]);
@ -676,12 +676,12 @@ var gTests = [
EventUtils.synthesizeMouseAtCenter(elt, {}, win);
}
await TestUtils.waitForCondition(
() => !identityPopupHidden(),
() => !permissionPopupHidden(),
"wait for control center to open"
);
ok(!identityPopupHidden(), "control center should be open");
ok(!permissionPopupHidden(), "control center should be open");
gIdentityHandler._identityPopup.hidePopup();
gPermissionPanel._permissionPopup.hidePopup();
await closeStream();
},

View File

@ -48,21 +48,21 @@ var gTests = [
// Clicking the global sharing indicator should open the control center in
// the second window.
ok(identityPopupHidden(win), "control center should be hidden");
ok(permissionPopupHidden(win), "control center should be hidden");
let activeStreams = webrtcUI.getActiveStreams(true, false, false);
webrtcUI.showSharingDoorhanger(activeStreams[0], "Devices");
// If the popup gets hidden before being shown, by stray focus/activate
// events, don't bother failing the test. It's enough to know that we
// started showing the popup.
let popup = win.gIdentityHandler._identityPopup;
let popup = win.gPermissionPanel._permissionPopup;
let hiddenEvent = BrowserTestUtils.waitForEvent(popup, "popuphidden");
let shownEvent = BrowserTestUtils.waitForEvent(popup, "popupshown");
let ev = await Promise.race([hiddenEvent, shownEvent]);
ok(ev.type, "Tried to show popup");
win.gIdentityHandler._identityPopup.hidePopup();
win.gPermissionPanel._permissionPopup.hidePopup();
ok(
identityPopupHidden(window),
permissionPopupHidden(window),
"control center should be hidden in the first window"
);

View File

@ -552,8 +552,8 @@ async function stopSharing(
1,
aFrameBC
);
aWindow.gIdentityHandler._identityBox.click();
let popup = aWindow.gIdentityHandler._identityPopup;
aWindow.gPermissionPanel._identityPermissionBox.click();
let popup = aWindow.gPermissionPanel._permissionPopup;
// If the popup gets hidden before being shown, by stray focus/activate
// events, don't bother failing the test. It's enough to know that we
// started showing the popup.
@ -561,12 +561,12 @@ async function stopSharing(
let shownEvent = BrowserTestUtils.waitForEvent(popup, "popupshown");
await Promise.race([hiddenEvent, shownEvent]);
let doc = aWindow.document;
let permissions = doc.getElementById("identity-popup-permission-list");
let permissions = doc.getElementById("permission-popup-permission-list");
let cancelButton = permissions.querySelector(
".identity-popup-permission-icon." +
".permission-popup-permission-icon." +
aType +
"-icon ~ " +
".identity-popup-permission-remove-button"
".permission-popup-permission-remove-button"
);
let observerPromise1 = expectObserverCalled(
"getUserMedia:revoke",
@ -773,7 +773,7 @@ async function checkSharingUI(
let doc = aWin.document;
// First check the icon above the control center (i) icon.
let identityBox = doc.getElementById("identity-box");
let permissionBox = doc.getElementById("identity-permission-box");
let webrtcSharingIcon = doc.getElementById("webrtc-sharing-icon");
ok(webrtcSharingIcon.hasAttribute("sharing"), "sharing attribute is set");
let sharing = webrtcSharingIcon.getAttribute("sharing");
@ -796,16 +796,16 @@ async function checkSharingUI(
"sharing icon(s) should be in paused state when paused"
);
// Then check the sharing indicators inside the control center panel.
identityBox.click();
let popup = aWin.gIdentityHandler._identityPopup;
// Then check the sharing indicators inside the permission popup.
permissionBox.click();
let popup = aWin.gPermissionPanel._permissionPopup;
// If the popup gets hidden before being shown, by stray focus/activate
// events, don't bother failing the test. It's enough to know that we
// started showing the popup.
let hiddenEvent = BrowserTestUtils.waitForEvent(popup, "popuphidden");
let shownEvent = BrowserTestUtils.waitForEvent(popup, "popupshown");
await Promise.race([hiddenEvent, shownEvent]);
let permissions = doc.getElementById("identity-popup-permission-list");
let permissions = doc.getElementById("permission-popup-permission-list");
for (let id of ["microphone", "camera", "screen"]) {
let convertId = idToConvert => {
if (idToConvert == "camera") {
@ -818,22 +818,22 @@ async function checkSharingUI(
};
let expected = aExpected[convertId(id)];
is(
!!aWin.gIdentityHandler._sharingState.webRTC[id],
!!aWin.gPermissionPanel._sharingState.webRTC[id],
!!expected,
"sharing state for " + id + " as expected"
);
let icon = permissions.querySelectorAll(
".identity-popup-permission-icon." + id + "-icon"
".permission-popup-permission-icon." + id + "-icon"
);
if (expected) {
is(icon.length, 1, "should show " + id + " icon in control center panel");
is(icon.length, 1, "should show " + id + " icon in permission panel");
is(
icon[0].classList.contains("in-use"),
expected && !isPaused(expected),
"icon should have the in-use class, unless paused"
);
} else if (!icon.length) {
ok(true, "should not show " + id + " icon in the control center panel");
ok(true, "should not show " + id + " icon in the permission panel");
} else {
// This will happen if there are persistent permissions set.
ok(
@ -843,9 +843,9 @@ async function checkSharingUI(
is(icon.length, 1, "should not show more than 1 " + id + " icon");
}
}
aWin.gIdentityHandler._identityPopup.hidePopup();
aWin.gPermissionPanel._permissionPopup.hidePopup();
await TestUtils.waitForCondition(
() => identityPopupHidden(aWin),
() => permissionPopupHidden(aWin),
"identity popup should be hidden"
);
@ -967,8 +967,8 @@ async function disableObserverVerification() {
}
}
function identityPopupHidden(win = window) {
let popup = win.gIdentityHandler._identityPopup;
function permissionPopupHidden(win = window) {
let popup = win.gPermissionPanel._permissionPopup;
return !popup || popup.state == "closed";
}
@ -981,8 +981,8 @@ async function runTests(tests, options = {}) {
"should start the test without any prior popup notification"
);
ok(
identityPopupHidden(),
"should start the test with the control center hidden"
permissionPopupHidden(),
"should start the test with the permission panel hidden"
);
// Set prefs so that permissions prompts are shown and loopback devices

View File

@ -25,7 +25,7 @@ add_task(async function() {
let widgetOverflowPanel = document.getElementById("widget-overflow");
let panelShownPromise = promisePanelElementShown(window, widgetOverflowPanel);
let identityBox = document.getElementById("identity-box");
let identityBox = document.getElementById("identity-icon-box");
let overflowChevron = document.getElementById("nav-bar-overflow-button");
// Listen for hiding immediately so we don't miss the event because of the

View File

@ -6,58 +6,62 @@ const { PermissionTestUtils } = ChromeUtils.import(
"resource://testing-common/PermissionTestUtils.jsm"
);
function openIdentityPopup() {
function openPermissionPopup() {
let promise = BrowserTestUtils.waitForEvent(
window,
"popupshown",
true,
event => event.target == gIdentityHandler._identityPopup
event => event.target == gPermissionPanel._permissionPopup
);
gIdentityHandler._identityBox.click();
gPermissionPanel._identityPermissionBox.click();
return promise;
}
function closeIdentityPopup() {
function closePermissionPopup() {
let promise = BrowserTestUtils.waitForEvent(
gIdentityHandler._identityPopup,
gPermissionPanel._permissionPopup,
"popuphidden"
);
gIdentityHandler._identityPopup.hidePopup();
gPermissionPanel._permissionPopup.hidePopup();
return promise;
}
async function testIdentityPopup({ expectPermissionHidden }) {
await openIdentityPopup();
async function testPermissionPopup({ expectPermissionHidden }) {
await openPermissionPopup();
if (expectPermissionHidden) {
let permissionsList = document.getElementById(
"permission-popup-permission-list"
);
is(
permissionsList.querySelectorAll(
".permission-popup-permission-label-persistent-storage"
).length,
0,
"Persistent storage Permission should be hidden"
);
}
await closePermissionPopup();
// We need to test this after the popup has been closed.
// The permission icon will be shown as long as the popup is open, event if
// no permissions are set.
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() {
@ -78,7 +82,7 @@ add_task(async function testPersistentStoragePermissionHidden() {
let url = await extension.awaitMessage("url");
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function() {
await testIdentityPopup({ expectPermissionHidden: true });
await testPermissionPopup({ expectPermissionHidden: true });
});
await extension.unload();
@ -110,7 +114,7 @@ add_task(async function testPersistentStoragePermissionVisible() {
);
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function() {
await testIdentityPopup({ expectPermissionHidden: false });
await testPermissionPopup({ expectPermissionHidden: false });
});
await extension.unload();

View File

@ -304,7 +304,7 @@ async function openIdentityPopup(expand) {
if (AppConstants.platform == "macosx") {
gIdentityHandler._identityPopup.classList.add("no-shadow");
}
gIdentityHandler._identityBox.querySelector("#identity-icon").click();
gIdentityHandler._identityIconBox.click();
if (expand) {
// give some time for opening to avoid weird style issues
await new Promise(c => setTimeout(c, 500));

View File

@ -33,7 +33,7 @@ const BAD_CERTS = [
function getConnectionState() {
// prevents items that are being lazy loaded causing issues
document.getElementById("identity-box").click();
document.getElementById("identity-icon-box").click();
gIdentityHandler.refreshIdentityPopup();
return document.getElementById("identity-popup").getAttribute("connection");
}

View File

@ -220,28 +220,28 @@ async function testDoorHanger(
await Promise.all([ct, permChanged]);
}
if (choice != BLOCK) {
let identityPopupPromise = BrowserTestUtils.waitForEvent(
let permissionPopupPromise = BrowserTestUtils.waitForEvent(
window,
"popupshown",
true,
event => event.target == gIdentityHandler._identityPopup
event => event.target == gPermissionPanel._permissionPopup
);
gIdentityHandler._identityBox.click();
await identityPopupPromise;
gPermissionPanel._identityPermissionBox.click();
await permissionPopupPromise;
let permissionItem = document.getElementById(
`identity-popup-permission-label-3rdPartyStorage^https://tracking.example.org`
`permission-popup-permission-label-3rdPartyStorage^https://tracking.example.org`
);
ok(permissionItem, "Permission item exists");
ok(
BrowserTestUtils.is_visible(permissionItem),
"Permission item visible in the identity panel"
);
identityPopupPromise = BrowserTestUtils.waitForEvent(
gIdentityHandler._identityPopup,
permissionPopupPromise = BrowserTestUtils.waitForEvent(
gPermissionPanel._permissionPopup,
"popuphidden"
);
gIdentityHandler._identityPopup.hidePopup();
await identityPopupPromise;
gPermissionPanel._permissionPopup.hidePopup();
await permissionPopupPromise;
}
BrowserTestUtils.removeTab(tab);

View File

@ -7,7 +7,7 @@ function openIdentityPopup() {
true,
event => event.target == gIdentityHandler._identityPopup
);
gIdentityHandler._identityBox.click();
gIdentityHandler._identityIconBox.click();
return promise;
}