Skip to content

Commit

Permalink
Bug 1818303 [wpt PR 38657] - Update popover events test to check bubb…
Browse files Browse the repository at this point in the history
…les/cancelable, a=testonly

Automatic update from web-platform-tests
Update popover events test to check bubbles/cancelable

Per a request [1], this adds a few more checks to ensure the toggle
events have the right values for bubbles and cancelable.

[1] whatwg/html#8888 (comment)

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

--

wpt-commits: 5f995902afeb84dcc1f656f2c23f5dc6547c6565
wpt-pr: 38657
  • Loading branch information
mfreed7 authored and moz-wptsync-bot committed Mar 7, 2023
1 parent 3632eb1 commit e64c109
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,27 @@
let hideCount = 0;
let afterHideCount = 0;
function listener(e) {
assert_false(e.bubbles,'toggle events should not bubble');
if (e.type === "beforetoggle") {
if (e.newState === "open") {
++showCount;
assert_equals(e.oldState,"closed",'The "beforetoggle" event should be fired before the popover is open');
assert_true(e.target.matches(':closed'),'The popover should be in the :closed state when the opening event fires.');
assert_false(e.target.matches(':open'),'The popover should *not* be in the :open state when the opening event fires.');
assert_true(e.cancelable,'beforetoggle should be cancelable only for the "show" transition');
} else {
++hideCount;
assert_equals(e.newState,"closed",'Popover toggleevent states should be "open" and "closed"');
assert_equals(e.oldState,"open",'The "beforetoggle" event should be fired before the popover is closed')
assert_true(e.target.matches(':open'),'The popover should be in the :open state when the hiding event fires.');
assert_false(e.target.matches(':closed'),'The popover should *not* be in the :closed state when the hiding event fires.');
assert_false(e.cancelable,'beforetoggle should be cancelable only for the "show" transition');
e.preventDefault(); // beforetoggle should be cancelable only for the "show" transition
}
} else {
assert_equals(e.type,"toggle",'Popover events should be "beforetoggle" and "toggle"')
assert_false(e.cancelable,'toggle should never be cancelable');
e.preventDefault(); // toggle should never be cancelable
if (e.newState === "open") {
++afterShowCount;
if (document.body.contains(e.target)) {
Expand Down

0 comments on commit e64c109

Please sign in to comment.