Skip to content

Commit

Permalink
Bug 1799006 [wpt PR 36808] - Add togglePopover() method for popovers,…
Browse files Browse the repository at this point in the history
… a=testonly

Automatic update from web-platform-tests
Add togglePopover() method for popovers

Per the resolution [1] there's a desire to add a togglePopover()
convenience method. This CL adds that method plus tests.

[1] openui/open-ui#610 (comment)

Bug: 1307772
Change-Id: Icd39c766786e7d1f6475a86ca8a7a1e89b66182e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4000073
Commit-Queue: Joey Arhar <[email protected]>
Auto-Submit: Mason Freed <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1067805}

--

wpt-commits: 1c0c07fc028ab6745609b755ccefc680d4c28230
wpt-pr: 36808
  • Loading branch information
mfreed7 authored and moz-wptsync-bot committed Nov 11, 2022
1 parent 8c1d48b commit b6a08d6
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@
popover.hidePopover();
assertPopoverVisibility(popover, /*isPopover*/true, /*expectedVisibility*/false, 'After hidePopover(), a popover should be hidden');
assert_throws_dom("InvalidStateError",() => popover.hidePopover(),'Calling hidePopover on a hidden popover should throw InvalidStateError');
popover.togglePopover();
assertPopoverVisibility(popover, /*isPopover*/true, /*expectedVisibility*/true, 'After togglePopover() on hidden popover, it should be visible');
popover.togglePopover();
assertPopoverVisibility(popover, /*isPopover*/true, /*expectedVisibility*/false, 'After togglePopover() on visible popover, it should be hidden');
const parent = popover.parentElement;
popover.remove();
assert_throws_dom("InvalidStateError",() => popover.showPopover(),'Calling showPopover on a disconnected popover should throw InvalidStateError');
assert_throws_dom("InvalidStateError",() => popover.hidePopover(),'Calling hidePopover on a disconnected popover should throw InvalidStateError');
assert_throws_dom("InvalidStateError",() => popover.togglePopover(),'Calling hidePopover on a disconnected popover should throw InvalidStateError');
parent.appendChild(popover);
}
function assertNotAPopover(nonPopover) {
Expand All @@ -76,6 +82,8 @@
assertPopoverVisibility(nonPopover, /*isPopover*/false, expectVisible, 'Calling showPopover on a non-popover should leave it visible');
assert_throws_dom("NotSupportedError",() => nonPopover.hidePopover(),'Calling hidePopover on a non-popover should throw NotSupportedError');
assertPopoverVisibility(nonPopover, /*isPopover*/false, expectVisible, 'Calling hidePopover on a non-popover should leave it visible');
assert_throws_dom("NotSupportedError",() => nonPopover.togglePopover(),'Calling togglePopover on a non-popover should throw NotSupportedError');
assertPopoverVisibility(nonPopover, /*isPopover*/false, expectVisible, 'Calling togglePopover on a non-popover should leave it visible');
}

// Start with the provided examples:
Expand Down

0 comments on commit b6a08d6

Please sign in to comment.