Skip to content

Commit

Permalink
Bug 1804478 [wpt PR 37377] - [Interop] Add a WPT that canceling mouse…
Browse files Browse the repository at this point in the history
…move doesn't affect drag., a=testonly

Automatic update from web-platform-tests
[Interop] Add a WPT that canceling mousemove doesn't affect drag.

This is related to w3c/uievents#278.

Bug: 346473
Change-Id: I0bc9d732369a0fa5eb8f4a4bcc04c7eabce26e6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4086261
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: Mustaq Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1080459}

--

wpt-commits: 295326a59547f180def6ca57e5794fa68e07939f
wpt-pr: 37377
  • Loading branch information
mustaqahmed authored and moz-wptsync-bot committed Dec 12, 2022
1 parent c2cdefc commit 72e4d30
Showing 1 changed file with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@
<body>
<div id="a">div a</div>
<div id="b">div b</div>
<div id="c" draggable="true">div c</div>
</body>

<script>
'use strict';

const a = document.getElementById("a");
const b = document.getElementById("b");

const expected_events = ["mousemove", "mousedown", "selectionchange",
"mousemove", "selectionchange"];

let event_log = [];

function logEvents(e) {
Expand All @@ -32,15 +27,18 @@

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

promise_test(async () => {
event_log = [];

let mouseup_promise = getEvent("mouseup", document);
const a = document.getElementById("a");
const b = document.getElementById("b");

let mouseup_promise = getEvent("mouseup", document);

await new test_driver.Actions()
.pointerMove(0, 0, {origin: a})
Expand All @@ -55,7 +53,41 @@

await mouseup_promise;

const expected_events = ["mousemove", "mousedown", "selectionchange",
"mousemove", "selectionchange"];

assert_equals(event_log.toString(), expected_events.toString(),
"received events");
}, "selectionchange event firing when mousemove event is prevented");

promise_test(async () => {
event_log = [];

const b = document.getElementById("b");
const c = document.getElementById("c");

let dragstart_promise = getEvent("dragstart", document);

// A mouseup event is not expected. This avoids timing out when the
// dragstart event is missing.
let mouseup_promise = getEvent("mouseup", document);

await new test_driver.Actions()
.pointerMove(0, 0, {origin: c})
.pointerDown()
.addTick()
.addTick()
.pointerMove(0, 0, {origin: b})
.addTick()
.addTick()
.pointerUp()
.send();

await Promise.race([dragstart_promise, mouseup_promise]);

const expected_events = ["mousemove", "mousedown", "mousemove", "dragstart"];

assert_equals(event_log.toString(), expected_events.toString(),
"received events");
}, "dragstart event firing when mousemove event is prevented");
</script>

0 comments on commit 72e4d30

Please sign in to comment.