| OLD | NEW |
| (Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Mouse Events with button depressed</title> |
| 5 <meta name="viewport" content="width=device-width"> |
| 6 <script src="/resources/testharness.js"></script> |
| 7 <script src="/resources/testharnessreport.js"></script> |
| 8 <style> |
| 9 div.box { |
| 10 border: 2px solid lightgray; |
| 11 margin: 25px; |
| 12 padding: 25px; |
| 13 float: left; |
| 14 } |
| 15 #lightyellow { |
| 16 background-color: lightyellow; |
| 17 } |
| 18 #lightblue { |
| 19 background-color: lightblue; |
| 20 } |
| 21 #lightgreen { |
| 22 background-color: lightgreen; |
| 23 } |
| 24 </style> |
| 25 </head> |
| 26 <body onload="run()"> |
| 27 <h2>Mouse Events</h2> |
| 28 <h4>Test Description: This test checks if mouse events set button proper
ty correctly |
| 29 <ol> |
| 30 <li>Put your mouse over the green rectangle</li> |
| 31 <li>Press a non-primary button and hold it</li> |
| 32 <li>Drag mouse to blue rectangle</li> |
| 33 <li>Release mouse button</li> |
| 34 </ol> |
| 35 </h4> |
| 36 <div class="box" id="lightyellow"> |
| 37 <div class="box" id="lightgreen"></div> |
| 38 <div class="box" id="lightblue"></div> |
| 39 </div> |
| 40 <script> |
| 41 var test = async_test("mouse events fired without button state"); |
| 42 |
| 43 var button = -1; |
| 44 |
| 45 function run() { |
| 46 var lightgreen = document.getElementById("lightgreen"); |
| 47 var lightyellow = document.getElementById("lightyellow"); |
| 48 var lightblue = document.getElementById("lightblue"); |
| 49 |
| 50 on_event(lightgreen, "contextmenu", function (event) { |
| 51 event.preventDefault(); |
| 52 }); |
| 53 |
| 54 on_event(lightgreen, "mousedown", function (event) { |
| 55 test.step(function() {assert_true(button === -1, "There must
only be one mouse down event.");}); |
| 56 test.step(function() {assert_true(event.button != 0, "Must n
ot be primary button.");}); |
| 57 button = event.button; |
| 58 }); |
| 59 on_event(lightyellow, "click", function (event) { |
| 60 test.step(function() {assert_true(event.button === button, "
Button must be the same as mousedown.");}); |
| 61 }); |
| 62 on_event(lightyellow, "mousemove", function (event) { |
| 63 if (button != -1) { |
| 64 test.step(function() {assert_true(event.button === 0, "B
utton must be un-initialized for mousemove.");}); |
| 65 } |
| 66 }); |
| 67 on_event(lightgreen, "mouseleave", function (event) { |
| 68 if (button != -1) { |
| 69 test.step(function() {assert_true(event.button === 0, "B
utton must be un-initialized for mouseleave.");}); |
| 70 } |
| 71 }); |
| 72 on_event(lightblue, "mouseenter", function (event) { |
| 73 if (button != -1) { |
| 74 test.step(function() {assert_true(event.button === 0, "B
utton must be un-initialized for mouseenter.");}); |
| 75 } |
| 76 }); |
| 77 on_event(lightblue, "mouseup", function (event) { |
| 78 if (button != -1) { |
| 79 test.step(function() {assert_true(event.button === butto
n, "Button must be the same as mousedown.");}); |
| 80 test.done(); |
| 81 } |
| 82 }); |
| 83 } |
| 84 </script> |
| 85 </body> |
| 86 </html> |
| OLD | NEW |