Skip to content

Commit

Permalink
Bug 1940129 [wpt PR 49929] - Make dialog focus async when removing op…
Browse files Browse the repository at this point in the history
…en attribute, a=testonly

Automatic update from web-platform-tests
Make dialog focus async when removing open attribute

When the dialog's open attribute is removed which closes the dialog, we
should make the focus async in order to prevent more script from running
inside attribute removal.

Context: whatwg/html#10124 (comment)

Bug: 341935362
Change-Id: I1b76f003e04b802b1868b427a0faddf5f19a3c5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6085725
Reviewed-by: Di Zhang <dizhanggchromium.org>
Commit-Queue: Joey Arhar <jarharchromium.org>
Cr-Commit-Position: refs/heads/main{#1402551}

--

wpt-commits: 58fd4f845204b88a3ae42b72b613a66e84cbb9f8
wpt-pr: 49929

UltraBlame original commit: 17e5e580ddfe60cd7d062ca9cbe0722342cc5638
  • Loading branch information
marco-c committed Jan 16, 2025
1 parent e8a2e4e commit 37dc3c5
Showing 1 changed file with 178 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,16 @@
<
dialog
>
hello
world
<
button
>
button
in
dialog
<
/
button
>
<
/
dialog
Expand Down Expand Up @@ -158,19 +166,62 @@
'
)
;
const
dialogbutton
=
document
.
querySelector
(
'
dialog
>
button
'
)
;
promise_test
(
async
t
=
>
{
button
.
focus
(
)
;
dialog
.
showModal
(
)
;
assert_equals
(
document
.
activeElement
dialogbutton
'
<
button
>
in
<
dialog
>
should
be
focused
after
opening
.
'
)
;
let
closeFired
=
Expand Down Expand Up @@ -222,6 +273,32 @@
'
)
;
assert_equals
(
document
.
activeElement
dialogbutton
'
<
button
>
in
<
dialog
>
should
still
be
focused
immediately
after
removing
open
.
'
)
;
await
new
Promise
Expand All @@ -245,6 +322,28 @@
requestAnimationFrame
)
;
assert_equals
(
document
.
activeElement
button
'
Previously
focused
element
should
be
focused
after
waiting
for
a
task
.
'
)
;
assert_false
(
dialog
Expand Down Expand Up @@ -385,12 +484,41 @@
=
>
{
button
.
focus
(
)
;
dialog
.
show
(
)
;
assert_equals
(
document
.
activeElement
dialogbutton
'
<
button
>
in
<
dialog
>
should
be
focused
after
opening
.
'
)
;
let
closeFired
=
Expand Down Expand Up @@ -442,6 +570,32 @@
'
)
;
assert_equals
(
document
.
activeElement
dialogbutton
'
<
button
>
in
<
dialog
>
should
still
be
focused
immediately
after
removing
open
.
'
)
;
await
new
Promise
Expand All @@ -465,6 +619,28 @@
requestAnimationFrame
)
;
assert_equals
(
document
.
activeElement
button
'
Previously
focused
element
should
be
focused
after
waiting
for
a
task
.
'
)
;
assert_false
(
cancelFired
Expand Down

0 comments on commit 37dc3c5

Please sign in to comment.