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_equals(event.target.id, "upbox"); |
| 42 assert_equals(getComputedStyle(event.target).backgroundColor, "rgb(0, 25
5, 255)"); |
| 43 }); |
| 44 } |
| 45 |
| 46 function callbackValidMouseHover() { |
| 47 testHover.step(function () { |
| 48 assert_true(mouseHoverActive); |
| 49 assert_true(mouseHover); |
| 50 assert_equals(getComputedStyle(upbox).backgroundColor, "rgb(0, 255, 255)
"); |
| 51 assert_equals(getComputedStyle(downbox).backgroundColor, "rgb(0, 0, 255)
"); |
| 52 }); |
| 53 testHover.done(); |
| 54 } |
| 55 |
| 56 function testHoverMousePress() { |
| 57 if (window.chrome && chrome.gpuBenchmarking) { |
| 58 var pointerActions = |
| 59 [{source: "mouse", |
| 60 actions: [ |
| 61 { name: "pointerMove", x: x1, y: y1 }, |
| 62 { name: "pointerDown", x: x1, y: y1, button: 'left'}, |
| 63 { name: "pointerMove", x: x2, y: y2, button: 'left' }, |
| 64 { name: 'pause', duration: 0.1 }]}]; |
| 65 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackVal
idMouseHover); |
| 66 } |
| 67 } |
| 68 |
| 69 var testHover = async_test('Tests that if we update the hover states when we mov
e the mouse to the element while the left button is pressed.'); |
| 70 upbox.addEventListener('mouseover', mouseOverHandler); |
| 71 downbox.addEventListener('mousedown', mouseDownHandler); |
| 72 testHoverMousePress(); |
| 73 |
| 74 </script> |
| 75 </body> |
| 76 |
| 77 |
OLD | NEW |