Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Unified Diff: third_party/WebKit/Source/core/css/resolver/SharedStyleFinderTest.cpp

Issue 2824853004: Scopeless matching of :host rules for style sharing. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/resolver/SharedStyleFinderTest.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/SharedStyleFinderTest.cpp b/third_party/WebKit/Source/core/css/resolver/SharedStyleFinderTest.cpp
index bc00bec9e17cb5b108490dda808261e3cee54e31..3b06f1d43f5cefd8d61b64b9643bda2815e78b89 100644
--- a/third_party/WebKit/Source/core/css/resolver/SharedStyleFinderTest.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/SharedStyleFinderTest.cpp
@@ -234,4 +234,87 @@ TEST_F(SharedStyleFinderTest, SlottedPseudoWithAttribute) {
EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*b));
}
+TEST_F(SharedStyleFinderTest, HostWithAttribute) {
+ SetBodyContent("<div id=host attr></div>");
+ Element* host = GetDocument().GetElementById("host");
+ ShadowRoot& root = AttachShadow(*host);
+ root.setInnerHTML("<slot></slot>");
+ GetDocument().UpdateDistribution();
+
+ AddSelector(":host([attr])");
+ FinishAddingSelectors();
+
+ EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*host));
+}
+
+TEST_F(SharedStyleFinderTest, HostAncestorWithAttribute) {
+ SetBodyContent("<div id=host attr></div>");
+ Element* host = GetDocument().GetElementById("host");
+ ShadowRoot& root = AttachShadow(*host);
+ root.setInnerHTML("<div id=inner></div>");
+ Element* inner = root.getElementById("inner");
+ GetDocument().UpdateDistribution();
+
+ AddSelector(":host([attr]) div");
+ FinishAddingSelectors();
+
+ EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*inner));
+}
+
+TEST_F(SharedStyleFinderTest, HostContextAncestorWithAttribute) {
+ SetBodyContent("<div id=host attr></div>");
+ Element* host = GetDocument().GetElementById("host");
+ ShadowRoot& root = AttachShadow(*host);
+ root.setInnerHTML("<div id=inner></div>");
+ Element* inner = root.getElementById("inner");
+ GetDocument().UpdateDistribution();
+
+ AddSelector(":host-context([attr]) div");
+ FinishAddingSelectors();
+
+ EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*inner));
+}
+
+TEST_F(SharedStyleFinderTest, HostParentWithAttribute) {
+ SetBodyContent("<div id=host attr></div>");
+ Element* host = GetDocument().GetElementById("host");
+ ShadowRoot& root = AttachShadow(*host);
+ root.setInnerHTML("<div id=inner></div>");
+ Element* inner = root.getElementById("inner");
+ GetDocument().UpdateDistribution();
+
+ AddSelector(":host([attr]) > div");
+ FinishAddingSelectors();
+
+ EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*inner));
+}
+
+TEST_F(SharedStyleFinderTest, HostContextParentWithAttribute) {
+ SetBodyContent("<div id=host attr></div>");
+ Element* host = GetDocument().GetElementById("host");
+ ShadowRoot& root = AttachShadow(*host);
+ root.setInnerHTML("<div id=inner></div>");
+ Element* inner = root.getElementById("inner");
+ GetDocument().UpdateDistribution();
+
+ AddSelector(":host-context([attr]) > div");
+ FinishAddingSelectors();
+
+ EXPECT_TRUE(MatchesUncommonAttributeRuleSet(*inner));
+}
+
+TEST_F(SharedStyleFinderTest, AncestorWithAttributeInParentScope) {
+ SetBodyContent("<div id=host attr></div>");
+ Element* host = GetDocument().GetElementById("host");
+ ShadowRoot& root = AttachShadow(*host);
+ root.setInnerHTML("<div id=inner></div>");
+ Element* inner = root.getElementById("inner");
+ GetDocument().UpdateDistribution();
+
+ AddSelector("div[attr] div");
+ FinishAddingSelectors();
+
+ EXPECT_FALSE(MatchesUncommonAttributeRuleSet(*inner));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698