Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / hover-after-dom-delete.html
blob9f52a1f6e39bcc8e8dace6d789c3cd8217c16b21
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;
14 #blue {
15 background-color: blue;
16 position: absolute;
17 left: 50px;
18 top: 200px;
19 height: 100px;
20 width: 100px;
22 #blue:hover::after {
23 content: "Hovered.";
26 </style>
27 <script src="../../resources/js-test.js"></script>
28 </head>
29 <body onload="runtest()" style="margin:0">
31 <script type="text/javascript">
32 var redDiv;
33 var blueDiv;
34 var containerDiv;
35 var blueText;
36 var redTextWhenHovered = "Red hovered.";
37 var blueTextWhenNotHovered = "";
38 var blueTextWhenHovered = '"Hovered."';
39 function runtest()
41 if (!window.testRunner || !window.eventSender)
42 return;
44 if (!window.internals || !window.internals.setIsCursorVisible) {
45 debug("window.internals.setIsCursorVisible is required to run this test.");
46 return;
49 testRunner.waitUntilDone();
51 containerDiv = document.getElementById('container');
53 redDiv = document.createElement("div");
54 redDiv.id = "red";
55 blueDiv = document.createElement("div");
56 blueDiv.id = "blue";
57 insertDivs();
59 document.addEventListener('keydown', function(e) {
60 blueDiv.style.top = "50px";
61 redDiv.parentNode.removeChild(redDiv);
62 });
64 initialHoverOverRedDiv();
66 debug("Mouse is visible, deleting the red div.");
67 eventSender.keyDown("a");
68 window.setTimeout(testAfterDeleteCursorVisible, 0);
71 function testAfterDeleteCursorVisible()
73 checkBlueHoverText(blueTextWhenHovered);
74 window.setTimeout(testWithInvisibleCursor, 0);
77 function testWithInvisibleCursor()
79 blueDiv.parentNode.removeChild(blueDiv);
80 insertDivs();
82 initialHoverOverRedDiv();
84 debug("Setting the mouse cursor to be invisible.");
85 internals.setIsCursorVisible(document, false);
86 shouldBeEqualToString("redDiv.innerHTML", redTextWhenHovered);
87 shouldBeEqualToString("blueDiv.innerHTML", blueTextWhenNotHovered);
89 debug("Mouse is invisible, deleting the red div.");
90 eventSender.keyDown("a");
91 window.setTimeout(testAfterDeleteCursorInvisible, 0);
94 function testAfterDeleteCursorInvisible()
96 checkBlueHoverText(blueTextWhenNotHovered);
97 testRunner.notifyDone();
101 // Helper functions
103 function checkBlueHoverText(expectedText)
105 shouldBe("blueDiv.offsetTop", "50");
106 blueText = window.getComputedStyle(document.querySelector('#blue'), ':after').content;
107 shouldBeEqualToString("blueText", expectedText);
110 function insertDivs()
112 debug("Adding the red and blue divs.");
113 blueDiv.style.top = "200px";
114 containerDiv.appendChild(redDiv);
115 containerDiv.appendChild(blueDiv);
116 redDiv.addEventListener('mouseover', function(e) {
117 this.innerHTML = redTextWhenHovered;
119 shouldBe("blueDiv.offsetTop", "200");
120 shouldBe("redDiv.offsetTop", "50");
123 function initialHoverOverRedDiv()
125 debug("Mouse is visible, moving it over the red div.");
126 internals.setIsCursorVisible(document, true);
127 eventSender.mouseMoveTo(100, 100);
128 shouldBeEqualToString("redDiv.innerHTML", redTextWhenHovered);
129 shouldBeEqualToString("blueDiv.innerHTML", blueTextWhenNotHovered);
131 </script>
133 <div id="container">
134 </div>
136 <p>Test for <a href="http://crbug.com/240722">http://crbug.com/240722</a>. If the mouse cursor is not visible, no new hover effects should be invoked when the currently hovered node is removed from the DOM. Press any key to delete the red div.</p>
138 <div id="console"></div>
139 </body>
140 </html>