Skip to content

Commit

Permalink
Bug 1858276 [wpt PR 42471] - mousemove_prevent_default_action.tentati…
Browse files Browse the repository at this point in the history
…ve.html unnecessarily listens for selectionchange events when asserting dragstart is fired, a=testonly

Automatic update from web-platform-tests
mousemove_prevent_default_action.tentative.html unnecessarily listens for selectionchange events when asserting dragstart is fired (#42471)

Since the two subtests in
mousemove_prevent_default_action.tentative.html assert that either a
selectionchange or a dragstart event is fired on a cancelled
mousemove event by comparing a set of logged events (obtained from
respective event listeners) against a static set of expected events, it
is important to not listen for events a subtest does not care about, as
that may produce an unnecessary test failure.

For example, we should not care whether or not a selectionchange event
was fired in the second subtest, since we only want to assert that a
dragstart event fires from a cancelled mousemove event on a draggable
element. These two events are not mutually exclusive in any manner
relevant to this WPT.

Thus, this commit makes sure we follow the invariant of listening only
for selectionchange events, and not also dragstart events, in the first
subtest, and similarly listening only for dragstart events, and not also
selectionchange events, in the second subtest.

Signed-off-by: Abrar Rahman Protyasha <a_protyashaapple.com>
--

wpt-commits: 08b5fe94e3503a012eb261e6ab353053f579ed37
wpt-pr: 42471

UltraBlame original commit: 0d55da49bf06f4a6bfe2ab06a41e0533a8fd88fd
  • Loading branch information
marco-c committed Oct 30, 2023
1 parent 45e4949 commit 2dbd6b4
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@

// Deliberately avoiding mouseup here because the last selectionchange
// may be fired before or after the mouseup.
["mousedown", "mousemove", "selectionchange", "dragstart"].forEach(ename => {
document.addEventListener(ename, logEvents);
});
document.addEventListener("mousedown", logEvents);
document.addEventListener("mousemove", logEvents);
document.addEventListener("mousemove", e => e.preventDefault());

promise_test(async () => {
promise_test(async test => {
document.addEventListener("selectionchange", logEvents);
test.add_cleanup(() => { document.removeEventListener("selectionchange", logEvents); });
event_log = [];

const a = document.getElementById("a");
Expand Down Expand Up @@ -60,7 +61,9 @@
"received events");
}, "selectionchange event firing when mousemove event is prevented");

promise_test(async () => {
promise_test(async test => {
document.addEventListener("dragstart", logEvents);
test.add_cleanup(() => { document.removeEventListener("dragstart", logEvents); });
event_log = [];

const b = document.getElementById("b");
Expand Down

0 comments on commit 2dbd6b4

Please sign in to comment.