-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
63a13ac
commit 41a0ee0
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
uievents/mouse/mousemove_prevent_default_action.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |