REGRESSION (r151839): Subframe keeps getting mousemove events with the same coordinat...
[WebKit-https.git] / LayoutTests / fast / events / ghostly-mousemoves-in-subframe.html
1 <!DOCTYPE html>
2 <html id="main_frame">
3 <head>
4 <meta charset="utf-8">
5 <script src="../../resources/js-test-pre.js"></script>
6 <style>
7 #subframe {
8     position: absolute;
9     left: 0;
10     top: 0;
11     width: 200px;
12     height: 200px;
13     background: white;
14 }
15
16 #overlapping_div_in_main_frame {
17     position: absolute;
18     background: black;
19     top: 0;
20     left: 0;
21     height: 50px;
22     width: 50px;
23     display: none;
24     z-index: 10;
25 }
26 </style>
27 </head>
28 <body>
29 <iframe id="subframe" src="resources/ghostly-mousemoves-in-subframe-the-actual-subframe.html"></iframe>
30 <div id="overlapping_div_in_main_frame"></div>
31 <script>
32
33 description("Test for http://webkit.org/b/131974 REGRESSION (r151839): Subframe keeps getting mousemove events with the same coordinates after hiding a hovered element.");
34 var jsTestIsAsync = true;
35
36 function logEvent(e) {
37     debug(e.target.id + " got " + event.type + " at " + event.x + "," + event.y);
38 }
39
40 window.onload = function() {
41     window.onclick = function(event) {
42         logEvent(event);
43
44         var clickable_div_in_subframe = document.querySelector("iframe").contentDocument.querySelector("#clickable_div_in_subframe");
45         clickable_div_in_subframe.style.display = "none";
46         clickable_div_in_subframe.clientHeight;
47         clickable_div_in_subframe.style.display = "block";
48         clickable_div_in_subframe.clientHeight;
49     };
50
51     if (!window.eventSender) {
52         debug("This test requires eventSender from the WebKit layout test internals.");
53         return;
54     }
55
56     // Move the mouse over clickable_div_in_subframe so it becomes the subframe document's hovered element.
57     eventSender.mouseMoveTo(15, 15);
58     setTimeout(function() {
59         // Fire the subframe's clickable_div_in_subframe.onclick handler.
60         // This will cause a overlapping_div_in_main_frame to overlap the currently hovered element in the subframe.
61         eventSender.mouseDown();
62         eventSender.mouseUp();
63         setTimeout(function() {
64             // Jiggle the mouse inside the newly hovered element a bit.
65             eventSender.mouseMoveTo(16, 16);
66             setTimeout(function() {
67                 eventSender.mouseMoveTo(400, 400);
68                 setTimeout(function() {
69                     // Cause a click in the main frame, so the above window.onclick handler will run,
70                     // killing and then recreating clickable_div_in_subframe's renderer.
71                     eventSender.mouseDown();
72                     eventSender.mouseUp();
73                     setTimeout(function() {
74                         finishJSTest();
75                     }, 500);
76                 }, 0);
77             }, 0);
78         }, 0);
79     }, 0);
80 };
81
82 window.onmousemove = function(event) {
83     logEvent(event);
84 };
85
86 </script>
87 <script src="../../resources/js-test-post.js"></script>
88 </body>
89 </html>