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

Run focus async when removing open attribute #44510

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
const button = document.querySelector('button');

promise_test(async t => {
button.focus();
dialog.showModal();

let closeFired = false;
Expand All @@ -32,6 +33,9 @@
assert_true(closeFired,
'The close event should be fired when removing the open attribute.');

assert_equals(document.activeElement, button,
'The previously focused element should be focused after removing the open attribute.');

let buttonFiredClick = false;
button.addEventListener('click', () => buttonFiredClick = true);
await test_driver.click(button);
Expand All @@ -40,6 +44,7 @@
}, 'Removing the open attribute from an open modal dialog should run the closing algorithm.');

promise_test(async t => {
button.focus();
dialog.show();

let closeFired = false;
Expand All @@ -55,5 +60,8 @@
'The cancel event should not fire when removing the open attribute.');
assert_true(closeFired,
'The close event should be fired when removing the open attribute.');

assert_equals(document.activeElement, button,
'The previously focused element should be focused after removing the open attribute.');
}, 'Removing the open attribute from an open non-modal dialog should fire a close event.');
</script>