Skip to content

Commit

Permalink
part 1) Add WPT.
Browse files Browse the repository at this point in the history
Currently, the test violates the spec. See
w3c/uievents#278. However, it's the behavior
of all major browsers and the desired one. The spec should be fixed
separately in above ticket.

Differential Revision: https://phabricator.services.mozilla.com/D106082

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1674658
gecko-commit: 580b096a83eaf535229d0d1bce67f5966570ad29
gecko-reviewers: smaug
  • Loading branch information
mbrodesser authored and moz-wptsync-bot committed Feb 24, 2021
1 parent 63a13ac commit 41a0ee0
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions uievents/mouse/mousemove_prevent_default_action.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>mousemove event: preventDefault()</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/uievents/resources/eventrecorder.js></script>
<script src=/resources/testdriver.js></script>
<script src=/resources/testdriver-actions.js></script>
<script src=/resources/testdriver-vendor.js></script>
</head>

<body>
<div id="a">a</div>
<div id="b">b</div>
</body>

<script>
const eventsToRecord = [
"mousedown",
"mousemove",
"selectionchange",
];

const expectedEventRecords = [
{type: "mousemove", target: "a"},
{type: "mousemove", target: "document"},
{type: "mousedown", target: "a"},
{type: "mousedown", target: "document"},
{type: "selectionchange", target: "document"},
{type: "mousemove", target: "b"},
{type: "mousemove", target: "document"},
];

window.onload = function () {
setup({single_test: true});

const a = document.getElementById("a");
const b = document.getElementById("b");
const nodesToListenForEvents = [a, b, document];

EventRecorder.configure({
objectMap: {
"a" : a,
"b" : b,
"document" : document,
}
});

EventRecorder.addEventListenersForNodes(eventsToRecord,
nodesToListenForEvents, null);

document.addEventListener("mousemove", (event) => {
event.preventDefault();
});

EventRecorder.start();

let actions_promise = new test_driver.Actions()
.pointerMove(0, 0, {origin: a})
.pointerDown()
.send();

actions_promise.then(() => {
window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => {
// Requested two animation frames to enforce flushing the
// "selectionchange" event.
})
});
});

actions_promise = new test_driver.Actions()
.pointerMove(0, 0, {origin: b})
.send();

actions_promise.then(() => {
window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => {
// Requested two animation frames to enforce flusing the
// "selectionchange" event, if there was one.

EventRecorder.stop();
assert_true(EventRecorder.checkRecords(expectedEventRecords),
"Events are as expected");

done();
});
});
});
};
</script>
</html>

0 comments on commit 41a0ee0

Please sign in to comment.