зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1674658: part 1) Add WPT. r=smaug
Currently, the test violates the spec. See https://github.com/w3c/uievents/issues/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
This commit is contained in:
Родитель
8bc870864d
Коммит
09da356fe9
|
@ -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>
|
Загрузка…
Ссылка в новой задаче