Bug 1930252 [wpt PR 49076] - moveBefore: don't fire focusin/focusout, a=testonly

Automatic update from web-platform-tests
moveBefore: don't fire focusin/focusout

Following spec conversation at WHATNOT, this will be deferred
until we receive community feedback.

Bug: 40150299
Change-Id: I18dc4ebd50d52fa83ea3a4cc8cf376e7b33d835b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5992801
Commit-Queue: Dominic Farolino <dom@chromium.org>
Reviewed-by: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1380625}

--

wpt-commits: e44f4535f4fe673f00e6f487c6240a4c4647b5a6
wpt-pr: 49076
This commit is contained in:
Noam Rosenthal 2024-11-09 10:00:07 +00:00 committed by moz-wptsync-bot
parent 229ed0aed4
commit 4ccd84a45d

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>moveBefore should handle focus bubbling correctly</title> <title>moveBefore should not fire focus events</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<body> <body>
@ -48,10 +48,8 @@ test(t => {
new_parent.moveBefore(button, null); new_parent.moveBefore(button, null);
assert_collected_events_equals(collected_events, [ assert_collected_events_equals(collected_events, [
{type: "focusin", target: button}, {type: "focusin", target: button},
{type: "focusout", target: old_parent},
{type: "focusin", target: new_parent}
]); ]);
}, "Fire focusin/out when reparenting focused element directly"); }, "Don't fire focusin/out when reparenting focused element directly");
test(t => { test(t => {
const collected_events = collect_focusinout_events(t); const collected_events = collect_focusinout_events(t);
@ -62,10 +60,8 @@ test(t => {
new_parent.moveBefore(old_parent, null); new_parent.moveBefore(old_parent, null);
assert_collected_events_equals(collected_events, [ assert_collected_events_equals(collected_events, [
{type: "focusin", target: button}, {type: "focusin", target: button},
{type: "focusout", target: document.body},
{type: "focusin", target: new_parent}
]); ]);
}, "Fire focusin/out when reparenting an element that has focus within"); }, "Don't fire focusin/out when reparenting an element that has focus within");
test(t => { test(t => {
const collected_events = collect_focusinout_events(t); const collected_events = collect_focusinout_events(t);
@ -88,18 +84,13 @@ promise_test(async t => {
button.focus(); button.focus();
inert_parent.moveBefore(button, null); inert_parent.moveBefore(button, null);
assert_collected_events_equals(collected_events, [ assert_collected_events_equals(collected_events, [
{type: "focusin", target: button}, {type: "focusin", target: button}]);
{type: "focusout", target: old_parent},
{type: "focusin", target: inert_parent}
]);
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))); await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
assert_collected_events_equals(collected_events, [ assert_collected_events_equals(collected_events, [
{type: "focusin", target: button}, {type: "focusin", target: button},
{type: "focusout", target: old_parent},
{type: "focusin", target: inert_parent},
{type: "focusout", target: button}, {type: "focusout", target: button},
]); ]);
}, "Fire focusin and then correct when moving to an inert subtree"); }, "Don't fire focusin and then correct when moving to an inert subtree");
promise_test(async t => { promise_test(async t => {
const collected_events = collect_focusinout_events(t); const collected_events = collect_focusinout_events(t);
@ -111,16 +102,12 @@ promise_test(async t => {
inert_when_not_empty_parent.moveBefore(button, null); inert_when_not_empty_parent.moveBefore(button, null);
assert_collected_events_equals(collected_events, [ assert_collected_events_equals(collected_events, [
{type: "focusin", target: button}, {type: "focusin", target: button},
{type: "focusout", target: old_parent},
{type: "focusin", target: inert_when_not_empty_parent}
]); ]);
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))); await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
assert_collected_events_equals(collected_events, [ assert_collected_events_equals(collected_events, [
{type: "focusin", target: button}, {type: "focusin", target: button},
{type: "focusout", target: old_parent},
{type: "focusin", target: inert_when_not_empty_parent},
{type: "focusout", target: button}, {type: "focusout", target: button},
]); ]);
}, "Fire focusin and then correct when moving to a tree that is made inert using style"); }, "Don't fire focusin and then correct when moving to a tree that is made inert using style");
</script> </script>