Bug 1674658: part 2) Don't peform the default action for `mousemove` events when...
[gecko.git] / testing / web-platform / tests / uievents / mouse / mousemove_prevent_default_action.tentative.html
blobb87385d79c5c20aed8c1ce79465c532d36e10908
1 <!doctype html>
2 <html>
3 <head>
4 <meta charset=utf-8>
5 <title>mousemove event: preventDefault()</title>
6 <link rel="author" title="Mirko Brodesser" href="mailto:mbrodesser@mozilla.com">
7 <link rel="help" href="https://github.com/w3c/uievents/issues/278">
8 <script src=/resources/testharness.js></script>
9 <script src=/resources/testharnessreport.js></script>
10 <script src=/uievents/resources/eventrecorder.js></script>
11 <script src=/resources/testdriver.js></script>
12 <script src=/resources/testdriver-actions.js></script>
13 <script src=/resources/testdriver-vendor.js></script>
14 </head>
16 <body>
17 <div id="a">a</div>
18 <div id="b">b</div>
19 </body>
21 <script>
22 const eventsToRecord = [
23 "mousedown",
24 "mousemove",
25 "selectionchange",
28 const expectedEventRecords = [
29 {type: "mousemove", target: "a"},
30 {type: "mousemove", target: "document"},
31 {type: "mousedown", target: "a"},
32 {type: "mousedown", target: "document"},
33 {type: "selectionchange", target: "document"},
34 {type: "mousemove", target: "b"},
35 {type: "mousemove", target: "document"},
38 window.onload = function () {
39 setup({single_test: true});
41 const a = document.getElementById("a");
42 const b = document.getElementById("b");
43 const nodesToListenForEvents = [a, b, document];
45 EventRecorder.configure({
46 objectMap: {
47 "a" : a,
48 "b" : b,
49 "document" : document,
51 });
53 EventRecorder.addEventListenersForNodes(eventsToRecord,
54 nodesToListenForEvents, null);
56 document.addEventListener("mousemove", (event) => {
57 event.preventDefault();
58 });
60 EventRecorder.start();
62 let actions_promise = new test_driver.Actions()
63 .pointerMove(0, 0, {origin: a})
64 .pointerDown()
65 .send();
67 actions_promise.then(() => {
68 window.requestAnimationFrame(() => {
69 window.requestAnimationFrame(() => {
70 // Requested two animation frames to enforce flushing the
71 // "selectionchange" event.
73 });
74 });
76 actions_promise = new test_driver.Actions()
77 .pointerMove(0, 0, {origin: b})
78 .send();
80 actions_promise.then(() => {
81 window.requestAnimationFrame(() => {
82 window.requestAnimationFrame(() => {
83 // Requested two animation frames to enforce flusing the
84 // "selectionchange" event, if there was one.
86 EventRecorder.stop();
87 assert_true(EventRecorder.checkRecords(expectedEventRecords),
88 "Events are as expected");
90 done();
91 });
92 });
93 });
95 </script>
96 </html>