Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update popover events test to check bubbles/cancelable #38657

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions html/semantics/popovers/popover-events.html
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