Bug 1799491 - Use a more reliable visibility check in toolbar key navigation. r=Gijs

The existing check didn't work for visibility: collapse items.

Before switching to modern flexbox, we were saved by the width==0 check, but
modern flexbox preserves the padding of collapsed items (even though they take
no space and aren't painted).

checkVisibility() is the right thing to check for this, and should also handle
visibility: hidden properly as a bonus.

Differential Revision: https://phabricator.services.mozilla.com/D161501
This commit is contained in:
Emilio Cobos Álvarez
2022-11-09 13:23:07 +00:00
parent a63393aa92
commit a43622ee87
2 changed files with 35 additions and 11 deletions

View File

@@ -148,8 +148,12 @@ add_task(async function testTabStopsNoPageWithHomeButton() {
RemoveHomeButton();
});
// Test tab stops with a page loaded.
add_task(async function testTabStopsPageLoaded() {
async function doTestTabStopsPageLoaded(aPageActionsVisible) {
info(`doTestTabStopsPageLoaded(${aPageActionsVisible})`);
BrowserPageActions.mainButtonNode.style.visibility = aPageActionsVisible
? "visible"
: "";
await BrowserTestUtils.withNewTab("https://example.com", async function() {
await waitUntilReloadEnabled();
startFromUrlBar();
@@ -164,10 +168,24 @@ add_task(async function testTabStopsPageLoaded() {
await expectFocusAfterKey("Tab", "reload-button");
await expectFocusAfterKey("Tab", "tracking-protection-icon-container");
await expectFocusAfterKey("Tab", gURLBar.inputField);
await expectFocusAfterKey("Tab", "pageActionButton");
await expectFocusAfterKey(
"Tab",
aPageActionsVisible ? "pageActionButton" : "star-button-box"
);
await expectFocusAfterKey("Tab", afterUrlBarButton);
await expectFocusAfterKey("Tab", gBrowser.selectedBrowser);
});
}
// Test tab stops with a page loaded.
add_task(async function testTabStopsPageLoaded() {
is(
BrowserPageActions.mainButtonNode.style.visibility,
"visible",
"explicitly shown at the beginning of test"
);
await doTestTabStopsPageLoaded(false);
await doTestTabStopsPageLoaded(true);
});
// Test tab stops with a notification anchor visible.
@@ -266,7 +284,7 @@ add_task(async function testArrowsToolbarbuttons() {
RemoveOldMenuSideButtons();
});
// Test that right/left arrows move through buttons wihch aren't toolbarbuttons
// Test that right/left arrows move through buttons which aren't toolbarbuttons
// but have role="button".
add_task(async function testArrowsRoleButton() {
await BrowserTestUtils.withNewTab("https://example.com", async function() {