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 #blue { |
| 6 background-color: rgb(0, 0, 255); |
| 7 position: absolute; |
| 8 left: 75px; |
| 9 top: 75px; |
| 10 height: 100px; |
| 11 width: 100px; |
| 12 } |
| 13 #blue:hover { |
| 14 background-color: rgb(255, 255, 0); |
| 15 } |
| 16 </style> |
| 17 |
| 18 <body onload="loaded();"> |
| 19 |
| 20 <script type="text/javascript"> |
| 21 var eventList = []; |
| 22 var x = 100; |
| 23 var y = 100; |
| 24 |
| 25 function addBlue() { |
| 26 document.body.innerHTML += '<div id="blue"></div>'; |
| 27 var blue = document.getElementById("blue"); |
| 28 var events = ['mouseover', 'mousemove', 'mouseout', 'mouseenter', 'mouseleav
e']; |
| 29 events.forEach(function (event) { |
| 30 blue.addEventListener(event, validMouseEventsResult); |
| 31 }); |
| 32 } |
| 33 |
| 34 function loaded() { |
| 35 document.addEventListener('click', addBlue); |
| 36 } |
| 37 |
| 38 function validMouseEventsResult(event) { |
| 39 eventList.push(event.type); |
| 40 testMouseOver.step(function () { |
| 41 assert_equals(event.target.id, "blue"); |
| 42 assert_equals(getComputedStyle(event.target).backgroundColor, "rgb(255,
255, 0)"); |
| 43 if (event.type == "mouseenter") { |
| 44 var result = eventList.join(); |
| 45 assert_true(result == 'mouseover,mouseenter'); |
| 46 testMouseOver.done(); |
| 47 } |
| 48 }); |
| 49 |
| 50 } |
| 51 |
| 52 function testMouseOverAddElement() { |
| 53 if (window.chrome && chrome.gpuBenchmarking) { |
| 54 var pointerActions = |
| 55 [{source: "mouse", |
| 56 actions: [ |
| 57 { name: "pointerDown", x: x, y: y }, |
| 58 { name: "pointerUp" }]}]; |
| 59 chrome.gpuBenchmarking.pointerActionSequence(pointerActions); |
| 60 } |
| 61 } |
| 62 |
| 63 var testMouseOver = async_test('Tests that the mouseover event is fired and the
element has a hover effect when the element underneath the mouse cursor is chang
ed.'); |
| 64 testMouseOverAddElement(); |
| 65 |
| 66 </script> |
| 67 </body> |
| 68 |
| 69 |
OLD | NEW |