OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Pointermove on button state changes</title> |
| 5 <meta name="viewport" content="width=device-width"> |
| 6 <meta name="assert" content="When a pointer changes button state and doe
s not produce a different event, the pointermove event must be dispatched."/> |
| 7 <link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> |
| 8 <script src="/resources/testharness.js"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> |
| 10 <!-- Additional helper script for common checks across event types --> |
| 11 <script type="text/javascript" src="pointerevent_support.js"></script> |
| 12 </head> |
| 13 <body onload="run()"> |
| 14 <h2>PointerMove</h2> |
| 15 <h4>Test Description: This test checks if pointermove event are triggere
d by button state changes |
| 16 <ol> |
| 17 <li>Put your mouse over the black rectangle</li> |
| 18 <li>Press a button and hold it</li> |
| 19 <li>Press a second button</li> |
| 20 <li>Release the second button</li> |
| 21 <li>Release the first button to complete the test</li> |
| 22 </ol> |
| 23 </h4> |
| 24 <div id="target0" style="background:black"></div> |
| 25 <script> |
| 26 var eventTested = false; |
| 27 var detected_pointertypes = {}; |
| 28 var test_pointermove = async_test("pointermove events received for b
utton state changes"); |
| 29 add_completion_callback(showPointerTypes); |
| 30 |
| 31 var step = 0; |
| 32 var firstButton = 0; |
| 33 |
| 34 function run() { |
| 35 var target0 = document.getElementById("target0"); |
| 36 |
| 37 // When a pointer changes button state and the circumstances pro
duce no other pointer event, the pointermove event must be dispatched. |
| 38 // 5.2.6 |
| 39 |
| 40 on_event(target0, "pointerdown", function (event) { |
| 41 detected_pointertypes[event.pointerType] = true; |
| 42 test_pointermove.step(function() {assert_true(step === 0, "T
here must not be more than one pointer down event.");}); |
| 43 if (step == 0) { |
| 44 step = 1; |
| 45 firstButton = event.buttons; |
| 46 } |
| 47 }); |
| 48 on_event(target0, "pointermove", function (event) { |
| 49 detected_pointertypes[event.pointerType] = true; |
| 50 |
| 51 if (step == 1 && event.button != -1) { // second button pres
sed |
| 52 test_pointermove.step(function() {assert_true(event.butt
ons !== firstButton, "The pointermove event must be triggered by pressing a seco
nd button.");}); |
| 53 test_pointermove.step(function() {assert_true((event.but
tons & firstButton) != 0, "The first button must still be reported pressed.");})
; |
| 54 step = 2; |
| 55 } else if (step == 2 && event.button != -1) { // second butt
on released |
| 56 test_pointermove.step(function() {assert_true(event.butt
ons === firstButton, "The pointermove event must be triggered by releasing the s
econd button.");}); |
| 57 step = 3; |
| 58 } |
| 59 }); |
| 60 on_event(target0, "pointerup", function (event) { |
| 61 detected_pointertypes[event.pointerType] = true; |
| 62 test_pointermove.step(function() {assert_true(step === 3, "T
he pointerup event must be triggered after pressing and releasing the second but
ton.");}); |
| 63 test_pointermove.step(function() {assert_true(event.buttons
=== 0, "The pointerup event must be triggered by releasing the last pressed butt
on.");}); |
| 64 test_pointermove.done(); |
| 65 eventTested = true; |
| 66 }); |
| 67 } |
| 68 </script> |
| 69 <h1>Pointer Events pointermove on button state changes Tests</h1> |
| 70 <div id="complete-notice"> |
| 71 <p>The following pointer types were detected: <span id="pointertype-
log"></span>.</p> |
| 72 <p>Refresh the page to run the tests again.</p> |
| 73 </div> |
| 74 <div id="log"></div> |
| 75 </body> |
| 76 </html> |
OLD | NEW |