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;} |
| 10 </style> |
| 11 |
| 12 <body> |
| 13 <div class="box" id="upbox"></div> |
| 14 <div class="box" id="downbox"></div> |
| 15 |
| 16 <script type="text/javascript"> |
| 17 var mouseover = false; |
| 18 var mousedown = false; |
| 19 var upbox = document.getElementById("upbox"); |
| 20 var downbox = document.getElementById("downbox"); |
| 21 var targetRect = downbox.getBoundingClientRect(); |
| 22 var offset = 20; |
| 23 var x1 = targetRect.left + offset; |
| 24 var y1 = targetRect.top + offset; |
| 25 targetRect = upbox.getBoundingClientRect(); |
| 26 var x2 = targetRect.left + offset; |
| 27 var y2 = targetRect.top + offset; |
| 28 |
| 29 |
| 30 function mouseDownHandler(event) { |
| 31 mouseHoverActive = true; |
| 32 testHover.step(function () { |
| 33 assert_equals(event.target.id, "downbox"); |
| 34 assert_equals(getComputedStyle(event.target).backgroundColor, "rgb(255,
255, 0)"); |
| 35 }); |
| 36 } |
| 37 |
| 38 function mouseOverHandler(event) { |
| 39 mouseHover = true; |
| 40 testHover.step(function () { |
| 41 assert_true(mouseHoverActive); |
| 42 assert_true(mouseHover); |
| 43 assert_equals(event.target.id, "upbox"); |
| 44 assert_equals(getComputedStyle(upbox).backgroundColor, "rgb(0, 255, 255)
"); |
| 45 assert_equals(getComputedStyle(downbox).backgroundColor, "rgb(0, 0, 255)
"); |
| 46 testHover.done(); |
| 47 }); |
| 48 } |
| 49 |
| 50 function testHoverMousePress() { |
| 51 if (window.chrome && chrome.gpuBenchmarking) { |
| 52 var pointerActions = |
| 53 [{source: "mouse", |
| 54 actions: [ |
| 55 { name: "pointerMove", x: x1, y: y1 }, |
| 56 { name: "pointerDown", x: x1, y: y1, button: 'left'}, |
| 57 { name: "pointerMove", x: x2, y: y2, button: 'left' }]}]; |
| 58 chrome.gpuBenchmarking.pointerActionSequence(pointerActions); |
| 59 } |
| 60 } |
| 61 |
| 62 var testHover = async_test('Test that we update the hover states when we move th
e mouse to the element while the left button is pressed.'); |
| 63 upbox.addEventListener('mouseover', mouseOverHandler); |
| 64 downbox.addEventListener('mousedown', mouseDownHandler); |
| 65 testHoverMousePress(); |
| 66 |
| 67 </script> |
| 68 </body> |
| 69 |
| 70 |
OLD | NEW |