Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: LayoutTests/fast/dom/hover-after-dom-delete-invisible-cursor.html

Issue 16285002: Do not invoke or clear hover effects on node deletion when cursor is invisible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tests changed Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style>
5 #red {
6 background-color: red;
7 position: absolute;
8 left: 50px;
9 top: 50px;
10 height: 100px;
11 width: 100px;
12 }
13
14 #blue {
15 background-color: blue;
16 position: absolute;
17 left: 50px;
18 top: 200px;
19 height: 100px;
20 width: 100px;
21 }
22 #blue:hover::after {
23 content: "Hovered.";
24 }
25
26 </style>
27 <script src="../js/resources/js-test-pre.js"></script>
28 </head>
29 <body onload="runtest()" style="margin:0">
30
31 <script type="text/javascript">
32 var redDiv;
33 var blueDiv;
34 var blueText;
35 var redTextWhenHovered = "Red hovered.";
36 var blueTextWhenNotHovered = "";
37 var blueTextWhenHovered = "'Hovered.'";
38 function runtest()
39 {
40 if (!window.testRunner || !window.eventSender)
41 return;
42
43 if (!window.internals || !window.internals.setIsCursorVisible) {
44 debug("window.internals.setIsCursorVisible is required to run this test. ");
45 return;
46 }
47
48 testRunner.waitUntilDone();
49
50 redDiv = document.getElementById('red');
51 blueDiv = document.getElementById('blue');
52
53 redDiv.addEventListener('mouseover', function(e) {
54 this.innerHTML = redTextWhenHovered;
55 });
56
57 document.addEventListener('keydown', function(e) {
58 blueDiv.style.top = "50px";
59 redDiv.parentNode.removeChild(redDiv);
60 });
61
62 debug("Mouse is visible, moving it over the red div.");
63 internals.setIsCursorVisible(document, true);
64 eventSender.mouseMoveTo(100, 100);
65 shouldBeEqualToString("redDiv.innerHTML", redTextWhenHovered);
66 shouldBeEqualToString("blueDiv.innerHTML", blueTextWhenNotHovered);
67
68 debug("Mouse is visible, deleting the red div.");
69 eventSender.keyDown("a");
70 window.setTimeout(testAfterDeleteCursorVisible, 0);
71 }
72
73 function testAfterDeleteCursorVisible()
74 {
75 checkBlueHoverText(blueTextWhenHovered);
76 window.setTimeout(testWithInvisibleCursor, 0);
77 }
78
79 function testWithInvisibleCursor()
80 {
81 debug("Re-adding the red and blue divs.");
82 blueDiv.parentNode.removeChild(blueDiv);
83 document.body.innerHTML += "<div id='red'></div>";
Rick Byers 2013/06/05 14:47:13 rather than re-add them with html, it would be cle
tdanderson 2013/06/05 17:43:27 Done.
84 document.body.innerHTML += "<div id='blue'></div>";
85 redDiv = document.getElementById('red');
86 blueDiv = document.getElementById('blue');
87 redDiv.addEventListener('mouseover', function(e) {
88 this.innerHTML = redTextWhenHovered;
89 });
90 shouldBe("blueDiv.offsetTop", "200");
91 shouldBe("redDiv.offsetTop", "50");
92
93 debug("Mouse is visible, moving it over the red div.");
94 internals.setIsCursorVisible(document, true);
95 eventSender.mouseMoveTo(100, 100);
96 shouldBeEqualToString("redDiv.innerHTML", redTextWhenHovered);
97 shouldBeEqualToString("blueDiv.innerHTML", blueTextWhenNotHovered);
98
99 debug("Setting the mouse cursor to be invisible.");
100 internals.setIsCursorVisible(document, false);
101 shouldBeEqualToString("redDiv.innerHTML", redTextWhenHovered);
102 shouldBeEqualToString("blueDiv.innerHTML", blueTextWhenNotHovered);
103
104 debug("Mouse is invisible, deleting the red div.");
105 eventSender.keyDown("a");
106 window.setTimeout(testAfterDeleteCursorInvisible, 0);
107 }
108
109 function testAfterDeleteCursorInvisible()
110 {
111 checkBlueHoverText(blueTextWhenNotHovered);
112 testRunner.notifyDone();
113 }
114
115 function checkBlueHoverText(expectedText)
116 {
117 shouldBe("blueDiv.offsetTop", "50");
118 blueText = window.getComputedStyle(document.querySelector('#blue'), ':after' ).content;
119 shouldBeEqualToString("blueText", expectedText);
120 }
121 </script>
122
123 <div id="red"></div>
124 <div id="blue"></div>
125
126 <p>Test for <a href="http://crbug.com/240722">http://crbug.com/240722</a>. If th e mouse cursor is not visible, no new hover effects should be invoked when the c urrently hovered node is removed from the DOM. Press any key to delete the red d iv.</p>
127
128 <div id="console"></div>
129 </body>
130 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698