Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / scrolling / hover-during-scroll.html
blobdd43bcd495b7cebf6c63979b7c3679018a1ee8c0
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style>
5 div {
6 line-height: 50px;
9 .hoverme {
10 background-color: lightblue;
13 </style>
14 <script src="../../resources/js-test.js"></script>
15 </head>
16 <body onload="runtest()" style="margin:0">
18 <script type="text/javascript">
20 function centerOfDivAtIndex(n)
22 return elementHeight * n + elementHeight / 2;
25 function scrolledWhileCursorNotVisible()
27 // The delay is necessary to guarantee that the fake mouse move
28 // event timer has fired. We have to wait the full length of time
29 // since the cursor is not visible and so we do not expect the
30 // hover effect to be invoked.
31 if (Date.now() - startTime < fakeMouseMoveTimerDelay) {
32 window.setTimeout(scrolledWhileCursorNotVisible, 10);
33 return;
36 shouldBeEqualToString("array[0].innerHTML", textWhenWasHovered);
37 shouldBeEqualToString("array[1].innerHTML", textWhenWasHovered);
38 shouldBeEqualToString("array[2].innerHTML", textWhenHovered);
39 shouldBeEqualToString("array[3].innerHTML", textWhenNotHovered);
40 shouldBeEqualToString("array[4].innerHTML", textWhenNotHovered);
41 shouldBe("document.scrollingElement.scrollTop", "100");
43 testRunner.notifyDone();
46 function scrolledWhileCursorVisible()
48 // The delay is necessary to guarantee that the fake mouse move
49 // event timer has fired. But since the cursor is visible, we
50 // can stop waiting as soon as the hover effect has been invoked.
51 var elementHovered = array[2].innerHTML == textWhenHovered;
52 if (!elementHovered && Date.now() - startTime < fakeMouseMoveTimerDelay) {
53 window.setTimeout(scrolledWhileCursorVisible, 10);
54 return;
57 shouldBeEqualToString("array[0].innerHTML", textWhenWasHovered);
58 shouldBeEqualToString("array[1].innerHTML", textWhenWasHovered);
59 shouldBeEqualToString("array[2].innerHTML", textWhenHovered);
60 shouldBeEqualToString("array[3].innerHTML", textWhenNotHovered);
62 debug("Mouse is not visible, scrolling page so the mouse ends up on the fourth div.");
63 shouldBe("document.scrollingElement.scrollTop", "50");
64 internals.setIsCursorVisible(document, false);
65 startTime = Date.now();
66 eventSender.continuousMouseScrollBy(0, -elementHeight);
67 scrolledWhileCursorNotVisible();
70 var array;
71 var numHoverElements = 30;
72 var elementHeight = 50;
73 var fakeMouseMoveTimerDelay = 150;
74 var textWhenNotHovered = "hover over me";
75 var textWhenHovered = "currently hovered";
76 var textWhenWasHovered = "was hovered";
77 var startTime;
79 function runtest()
81 buildPage();
83 array = document.getElementsByClassName('hoverme');
85 for (var i = 0; i < array.length; i++) {
86 array[i].addEventListener('mouseover', function(e) {
87 this.innerHTML = textWhenHovered;
88 this.style.backgroundColor = "yellow";
89 });
90 array[i].addEventListener('mouseout', function(e) {
91 this.innerHTML = textWhenWasHovered;
92 this.style.backgroundColor = "green";
93 });
96 if (!window.testRunner || !window.eventSender)
97 return;
99 if (!window.internals || !window.internals.setIsCursorVisible) {
100 debug("window.internals.setIsCursorVisible is required to run this test.");
101 return;
104 testRunner.waitUntilDone();
106 debug("Mouse is visible, moving it over the first div.");
107 internals.setIsCursorVisible(document, true);
108 eventSender.mouseMoveTo(42, centerOfDivAtIndex(0));
109 shouldBeEqualToString("array[0].innerHTML", textWhenHovered);
110 shouldBeEqualToString("array[1].innerHTML", textWhenNotHovered);
112 debug("Mouse is visible, moving it over the second div.");
113 eventSender.mouseMoveTo(53, centerOfDivAtIndex(1));
114 shouldBeEqualToString("array[0].innerHTML", textWhenWasHovered);
115 shouldBeEqualToString("array[1].innerHTML", textWhenHovered);
116 shouldBeEqualToString("array[2].innerHTML", textWhenNotHovered);
118 debug("Mouse is visible, scrolling page so the mouse ends up on the third div.");
119 shouldBe("document.scrollingElement.scrollTop", "0");
120 startTime = Date.now();
121 eventSender.continuousMouseScrollBy(0, -elementHeight);
122 scrolledWhileCursorVisible();
125 function buildPage()
127 var table = document.getElementById('table_to_fill');
128 var i;
129 for (i = 0; i < numHoverElements; i++) {
130 var p = document.createElement('tr');
131 p.innerHTML = '<tr><td><div class="hoverme">' + textWhenNotHovered + '</div></td></tr>';
132 table.appendChild(p);
135 </script>
137 <table id="table_to_fill" width="100%" cellpadding="0px" cellspacing="0px" border="0px">
138 <tr><td><div class="hoverme">hover over me</div></td></tr>
139 </table>
141 <p>Test for <a href="http://crbug.com/153784">http://crbug.com/153784</a>. New hover effects should not be invoked during scroll if the mouse cursor is not visible.</p>
143 <div id="console"></div>
144 </body>
145 </html>