Chromium Code Reviews| Index: Source/core/css/AffectedByFocusTest.cpp |
| diff --git a/Source/core/css/AffectedByFocusTest.cpp b/Source/core/css/AffectedByFocusTest.cpp |
| index c12f07c7a8fb0f0aa1329f1e09967e3c068ced9d..de9dc0aebdc049573a7a9e05e3151763475ccb88 100644 |
| --- a/Source/core/css/AffectedByFocusTest.cpp |
| +++ b/Source/core/css/AffectedByFocusTest.cpp |
| @@ -250,4 +250,67 @@ TEST_F(AffectedByFocusTest, ChildrenAffectedByFocusUpdate) |
| ASSERT_EQ(11U, accessCount); |
| } |
| +TEST_F(AffectedByFocusTest, InvalidationSetFocusUpdate) |
| +{ |
| + // Check that when focussing the outer div in the document below, you get a |
| + // style recalc for the outer div and the class=a div only. |
| + |
| + setHtmlInnerHTML("<style>:focus .a { border: 1px solid lime; }</style>" |
| + "<div id=d tabIndex=1>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div class='a'></div>" |
| + "</div>"); |
| + |
| + document().view()->updateLayoutAndStyleIfNeededRecursive(); |
| + |
| + unsigned startCount = document().styleEngine()->resolverAccessCount(); |
| + |
| + document().getElementById("d")->focus(); |
| + document().view()->updateLayoutAndStyleIfNeededRecursive(); |
| + |
| + unsigned accessCount = document().styleEngine()->resolverAccessCount() - startCount; |
| + |
| + ASSERT_EQ(2U, accessCount); |
| +} |
| + |
| +TEST_F(AffectedByFocusTest, NoInvalidationSetFocusUpdate) |
| +{ |
| + // Check that when focussing the outer div in the document below, you get a |
| + // style recalc for the outer div only. The invalidation set for :focus will |
| + // include 'a', but the id=d div should be affectedByFocus, not childrenAffectedByFocus. |
| + |
| + setHtmlInnerHTML("<style>#nomatch:focus .a { border: 1px solid lime; }</style>" |
| + "<div id=d tabIndex=1>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
|
esprehn
2014/04/04 22:48:27
Can we just write the normal layout tests like we'
rune
2014/04/10 12:42:12
Style update for focus still happens synchronously
|
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div></div>" |
| + "<div class='a'></div>" |
| + "</div>"); |
| + |
| + document().view()->updateLayoutAndStyleIfNeededRecursive(); |
| + |
| + unsigned startCount = document().styleEngine()->resolverAccessCount(); |
| + |
| + document().getElementById("d")->focus(); |
| + document().view()->updateLayoutAndStyleIfNeededRecursive(); |
| + |
| + unsigned accessCount = document().styleEngine()->resolverAccessCount() - startCount; |
| + |
| + ASSERT_EQ(1U, accessCount); |
| +} |
| + |
| } // namespace |