Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/events/update-hover-when-mouse-press.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/events/update-hover-when-mouse-press.html b/third_party/WebKit/LayoutTests/fast/events/update-hover-when-mouse-press.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..494a07b830b33f9c9b75d05de253bc7e5141a3a3 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/events/update-hover-when-mouse-press.html |
| @@ -0,0 +1,77 @@ |
| +<!DOCTYPE html> |
| +<script src='../../resources/testharness.js'></script> |
| +<script src='../../resources/testharnessreport.js'></script> |
| +<style type="text/css"> |
| +.box:hover{background-color: rgb(0, 255, 255);} |
| +.box:active{background-color: rgb(0, 0, 255);} |
| +.box:active:hover{background-color: rgb(255, 255, 0);} |
| + |
| +.box{border:2px solid #aaa; width:100px; height:100px;} |
| +</style> |
| + |
| +<body> |
| +<div class="box" id="upbox"></div> |
| +<div class="box" id="downbox"></div> |
| + |
| +<script type="text/javascript"> |
| +var mouseover = false; |
| +var mousedown = false; |
| +var upbox = document.getElementById("upbox"); |
| +var downbox = document.getElementById("downbox"); |
| +var targetRect = downbox.getBoundingClientRect(); |
| +var offset = 20; |
| +var x1 = targetRect.left + offset; |
| +var y1 = targetRect.top + offset; |
| +targetRect = upbox.getBoundingClientRect(); |
| +var x2 = targetRect.left + offset; |
| +var y2 = targetRect.top + offset; |
| + |
| + |
| +function mouseDownHandler(event) { |
| + mouseHoverActive = true; |
| + testHover.step(function () { |
| + assert_equals(event.target.id, "downbox"); |
| + assert_equals(getComputedStyle(event.target).backgroundColor, "rgb(255, 255, 0)"); |
| + }); |
| +} |
| + |
| +function mouseOverHandler(event) { |
| + mouseHover = true; |
| + testHover.step(function () { |
| + assert_equals(event.target.id, "upbox"); |
| + assert_equals(getComputedStyle(event.target).backgroundColor, "rgb(0, 255, 255)"); |
| + }); |
| +} |
| + |
| +function callbackValidMouseHover() { |
| + testHover.step(function () { |
| + assert_true(mouseHoverActive); |
| + assert_true(mouseHover); |
| + assert_equals(getComputedStyle(upbox).backgroundColor, "rgb(0, 255, 255)"); |
| + assert_equals(getComputedStyle(downbox).backgroundColor, "rgb(0, 0, 255)"); |
| + }); |
| + testHover.done(); |
| +} |
| + |
| +function testHoverMousePress() { |
| + if (window.chrome && chrome.gpuBenchmarking) { |
| + var pointerActions = |
| + [{source: "mouse", |
| + actions: [ |
| + { name: "pointerMove", x: x1, y: y1 }, |
| + { name: "pointerDown", x: x1, y: y1, button: 'left'}, |
| + { name: "pointerMove", x: x2, y: y2, button: 'left' }, |
| + { name: 'pause', duration: 0.1 }]}]; |
| + chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackValidMouseHover); |
| + } |
| +} |
| + |
| +var testHover = async_test('Tests that if we update the hover states when we move the mouse to the element while the left button is pressed.'); |
|
Rick Byers
2017/07/07 20:02:17
nit: typo? "Test that we update..."?
lanwei
2017/07/12 21:03:10
Done.
|
| +upbox.addEventListener('mouseover', mouseOverHandler); |
| +downbox.addEventListener('mousedown', mouseDownHandler); |
| +testHoverMousePress(); |
| + |
| +</script> |
| +</body> |
| + |
| + |