OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src='../../resources/testharness.js'></script> |
| 3 <script src='../../resources/testharnessreport.js'></script> |
| 4 <style type="text/css"> |
| 5 .box:hover {background-color: rgb(0, 255, 255);} |
| 6 .box:active {background-color: rgb(0, 0, 255);} |
| 7 .box:active:hover {background-color: rgb(255, 255, 0);} |
| 8 |
| 9 .box{border:2px solid #aaa; width:100px; height:100px; background-color: rgb(0,
0, 0);} |
| 10 </style> |
| 11 |
| 12 <body> |
| 13 <div class="box" draggable="true" id="upbox"></div> |
| 14 <div class="box" id="downbox"></div> |
| 15 |
| 16 <script type="text/javascript"> |
| 17 var upbox = document.getElementById("upbox"); |
| 18 var downbox = document.getElementById("downbox"); |
| 19 var targetRect = upbox.getBoundingClientRect(); |
| 20 var offset = 20; |
| 21 var x1 = targetRect.left + offset; |
| 22 var y1 = targetRect.top + offset; |
| 23 targetRect = downbox.getBoundingClientRect(); |
| 24 var x2 = targetRect.left + offset; |
| 25 var y2 = targetRect.top + offset; |
| 26 |
| 27 |
| 28 function mouseDownHandler(event) { |
| 29 testHover.step(function () { |
| 30 assert_equals(event.target.id, "upbox"); |
| 31 assert_equals(getComputedStyle(event.target).backgroundColor, "rgb(255,
255, 0)"); |
| 32 }); |
| 33 } |
| 34 |
| 35 function mouseDragHandler(event) { |
| 36 testHover.step(function () { |
| 37 assert_equals(getComputedStyle(downbox).backgroundColor, "rgb(0, 0, 0)")
; |
| 38 assert_equals(getComputedStyle(event.target).backgroundColor, "rgb(255,
255, 0)"); |
| 39 }); |
| 40 } |
| 41 |
| 42 function mouseDragEndHandler(event) { |
| 43 testHover.step(function () { |
| 44 assert_equals(getComputedStyle(downbox).backgroundColor, "rgb(0, 255, 25
5)"); |
| 45 assert_equals(getComputedStyle(upbox).backgroundColor, "rgb(0, 0, 0)"); |
| 46 }); |
| 47 testHover.done(); |
| 48 } |
| 49 |
| 50 function testHoverMouseDrag() { |
| 51 if (window.eventSender) { |
| 52 eventSender.mouseMoveTo(x1, y1); |
| 53 eventSender.mouseDown(); |
| 54 eventSender.leapForward(100); |
| 55 eventSender.mouseMoveTo(x1, y1+10); |
| 56 eventSender.mouseMoveTo(x1, y1+20); |
| 57 eventSender.mouseMoveTo(x2, y2); |
| 58 eventSender.mouseUp(); |
| 59 } |
| 60 } |
| 61 |
| 62 var testHover = async_test('Tests that we do not update the hover states of any
element when we are dragging an element around.'); |
| 63 upbox.addEventListener('drag', mouseDragHandler); |
| 64 upbox.addEventListener('dragend', mouseDragEndHandler); |
| 65 upbox.addEventListener('mousedown', mouseDownHandler); |
| 66 testHoverMouseDrag(); |
| 67 |
| 68 </script> |
| 69 </body> |
| 70 |
| 71 |
OLD | NEW |