15 background-color: blue;
27 <script src=
"../../resources/js-test.js"></script>
29 <body onload=
"runtest()" style=
"margin:0">
31 <script type=
"text/javascript">
36 var redTextWhenHovered
= "Red hovered.";
37 var blueTextWhenNotHovered
= "";
38 var blueTextWhenHovered
= '"Hovered."';
41 if (!window
.testRunner
|| !window
.eventSender
)
44 if (!window
.internals
|| !window
.internals
.setIsCursorVisible
) {
45 debug("window.internals.setIsCursorVisible is required to run this test.");
49 testRunner
.waitUntilDone();
51 containerDiv
= document
.getElementById('container');
53 redDiv
= document
.createElement("div");
55 blueDiv
= document
.createElement("div");
59 document
.addEventListener('keydown', function(e
) {
60 blueDiv
.style
.top
= "50px";
61 redDiv
.parentNode
.removeChild(redDiv
);
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
);
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();
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
);
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>