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

Unified Diff: third_party/WebKit/Source/core/css/StyleSheetContentsTest.cpp

Issue 2408353003: Add hasViewportRule() flag to StyleSheetContents. (Closed)
Patch Set: CORE_EXPORT Created 4 years, 2 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/StyleSheetContentsTest.cpp
diff --git a/third_party/WebKit/Source/core/css/StyleSheetContentsTest.cpp b/third_party/WebKit/Source/core/css/StyleSheetContentsTest.cpp
index ddc13213e81cc0a8e4e2d8e0836b3003daaf1a73..232850d3fb2b92da7f50baf2cb865ca3fc7a259c 100644
--- a/third_party/WebKit/Source/core/css/StyleSheetContentsTest.cpp
+++ b/third_party/WebKit/Source/core/css/StyleSheetContentsTest.cpp
@@ -56,4 +56,46 @@ TEST(StyleSheetContentsTest, InsertFontFaceRule) {
EXPECT_TRUE(styleSheet->hasFontFaceRule());
}
+TEST(StyleSheetContentsTest, HasViewportRule) {
+ CSSParserContext context(HTMLStandardMode, nullptr);
+
+ StyleSheetContents* styleSheet = StyleSheetContents::create(context);
+ styleSheet->parseString("@viewport { width: 200px}");
+ EXPECT_EQ(1U, styleSheet->ruleCount());
+ EXPECT_TRUE(styleSheet->hasViewportRule());
+}
+
+TEST(StyleSheetContentsTest, HasViewportRuleAfterInsertion) {
+ CSSParserContext context(HTMLStandardMode, nullptr);
+
+ StyleSheetContents* styleSheet = StyleSheetContents::create(context);
+ styleSheet->parseString("body { color: pink }");
+ EXPECT_EQ(1U, styleSheet->ruleCount());
+ EXPECT_FALSE(styleSheet->hasViewportRule());
+
+ styleSheet->setMutable();
+ styleSheet->wrapperInsertRule(
+ CSSParser::parseRule(context, styleSheet, "@viewport { width: 200px }"),
+ 0);
+ EXPECT_EQ(2U, styleSheet->ruleCount());
+ EXPECT_TRUE(styleSheet->hasViewportRule());
+}
+
+TEST(StyleSheetContentsTest, HasViewportRuleAfterInsertionIntoMediaRule) {
+ CSSParserContext context(HTMLStandardMode, nullptr);
+
+ StyleSheetContents* styleSheet = StyleSheetContents::create(context);
+ styleSheet->parseString("@media {}");
+ ASSERT_EQ(1U, styleSheet->ruleCount());
+ EXPECT_FALSE(styleSheet->hasViewportRule());
+
+ StyleRuleMedia* mediaRule = toStyleRuleMedia(styleSheet->ruleAt(0));
+ styleSheet->setMutable();
+ mediaRule->wrapperInsertRule(
+ 0,
+ CSSParser::parseRule(context, styleSheet, "@viewport { width: 200px }"));
+ EXPECT_EQ(1U, mediaRule->childRules().size());
+ EXPECT_TRUE(styleSheet->hasViewportRule());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleSheetContents.cpp ('k') | third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698