Bug 1145910 - Cross ShadowRoot boundary when updating ancestor state in event state manager. r=smaug

This commit is contained in:
William Chen 2015-03-24 03:55:52 -07:00
parent f1111e7f5e
commit c53eea2aef
3 changed files with 51 additions and 2 deletions

View File

@ -4646,7 +4646,7 @@ EventStateManager::UpdateAncestorState(nsIContent* aStartNode,
bool aAddState)
{
for (; aStartNode && aStartNode != aStopBefore;
aStartNode = aStartNode->GetParent()) {
aStartNode = aStartNode->GetParentElementCrossingShadowRoot()) {
// We might be starting with a non-element (e.g. a text node) and
// if someone is doing something weird might be ending with a
// non-element too (e.g. a document fragment)
@ -4674,7 +4674,7 @@ EventStateManager::UpdateAncestorState(nsIContent* aStartNode,
// still be in hover state. To handle this situation we need to
// keep walking up the tree and any time we find a label mark its
// corresponding node as still in our state.
for ( ; aStartNode; aStartNode = aStartNode->GetParent()) {
for ( ; aStartNode; aStartNode = aStartNode->GetParentElementCrossingShadowRoot()) {
if (!aStartNode->IsElement()) {
continue;
}

View File

@ -141,6 +141,7 @@ support-files = bug1017086_inner.html
[test_bug1017086_enable.html]
support-files = bug1017086_inner.html
[test_bug1079236.html]
[test_bug1145910.html]
[test_clickevent_on_input.html]
skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
[test_continuous_wheel_events.html]

View File

@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1145910
-->
<head>
<title>Test for Bug 1145910</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<style>
div:active {
color: rgb(0, 255, 0);
}
</style>
<div id="host">Foo</div>
<script type="application/javascript">
/** Test for Bug 1145910 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var host = document.getElementById("host");
var shadow = host.createShadowRoot();
shadow.innerHTML = '<style>div:active { color: rgb(0, 255, 0); }</style><div id="inner">Bar</div>';
var inner = shadow.getElementById("inner");
is(window.getComputedStyle(host).color, "rgb(0, 0, 0)", "The host should not be active");
is(window.getComputedStyle(inner).color, "rgb(0, 0, 0)", "The div inside the shadow root should not be active.");
synthesizeMouseAtCenter(host, { type: "mousedown" });
is(window.getComputedStyle(inner).color, "rgb(0, 255, 0)", "Div inside shadow root should be active.");
is(window.getComputedStyle(host).color, "rgb(0, 255, 0)", "Host should be active when the inner div is made active.");
synthesizeMouseAtCenter(host, { type: "mouseup" });
is(window.getComputedStyle(inner).color, "rgb(0, 0, 0)", "Div inside shadow root should no longer be active.");
is(window.getComputedStyle(host).color, "rgb(0, 0, 0)", "Host should no longer be active.");
SimpleTest.finish();
});
</script>
</body>
</html>