Index: third_party/WebKit/LayoutTests/fast/css/invalidation/sheet-ruleset-invalidation.html |
diff --git a/third_party/WebKit/LayoutTests/fast/css/invalidation/sheet-ruleset-invalidation.html b/third_party/WebKit/LayoutTests/fast/css/invalidation/sheet-ruleset-invalidation.html |
index e8a7c780b3a0342601fd4fb64d166c0e87864d34..d513ff27d29d9da3dd2c5aa4918d3c1c7578b5b8 100644 |
--- a/third_party/WebKit/LayoutTests/fast/css/invalidation/sheet-ruleset-invalidation.html |
+++ b/third_party/WebKit/LayoutTests/fast/css/invalidation/sheet-ruleset-invalidation.html |
@@ -8,13 +8,39 @@ |
<div></div> |
<div></div> |
<div></div> |
+ <div id="found"> |
+ <div></div> |
+ </div> |
<span></span> |
</div> |
<script> |
test(() => { |
- assert_true(!!window.internals, "Test requires window.internals."); |
+ assert_true(!!window.internals, "Tests require window.internals."); |
+ }, "Test for prerequisites."); |
+ |
+ function applyRuleAndReturnAffectedElementCount(ruleString) { |
document.body.offsetTop; |
- document.styleSheets[0].insertRule("span{background:green}", 0); |
- assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 1, "Check that only the span is affected."); |
- }, "Inserting a style rule with a type selector should only invalidate elements with that type."); |
+ document.styleSheets[0].insertRule(ruleString, 0); |
+ var recalcCount = internals.updateStyleAndReturnAffectedElementCount(); |
+ document.styleSheets[0].removeRule(); |
+ return recalcCount; |
+ } |
+ |
+ test(() => { |
+ assert_equals(applyRuleAndReturnAffectedElementCount( |
+ "span { background: green }"), 1, |
+ "Check that only the span is affected."); |
+ }, "A style rule with a type selector should only invalidate elements with that type."); |
+ |
+ test(() => { |
+ assert_equals(applyRuleAndReturnAffectedElementCount( |
+ "#notfound div { background: red }"), 0, |
+ "Check that none of divs are recalculated."); |
+ }, "A type selector scoped in an unknown id should not invalidate any elements."); |
+ |
+ test(() => { |
+ assert_equals(applyRuleAndReturnAffectedElementCount( |
+ "#found div { background: red }"), 1, |
+ "Check that only one of the divs is recalculated."); |
+ }, "A type selector scoped by a known id should only invalidate descendants of the element with that id."); |
</script> |