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

Side by Side Diff: third_party/WebKit/Source/core/css/StyleSheetContentsTest.cpp

Issue 2081893003: Mark stylesheet as having media queries at consume time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Back to marking at consume time Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/StyleSheetContents.h" 5 #include "core/css/StyleSheetContents.h"
6 6
7 #include "core/css/CSSTestHelper.h" 7 #include "core/css/CSSTestHelper.h"
8 #include "core/css/parser/CSSParser.h" 8 #include "core/css/parser/CSSParser.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 TEST(StyleSheetContentsTest, InsertMediaRule) 13 TEST(StyleSheetContentsTest, InsertMediaRule)
14 { 14 {
15 CSSParserContext context(HTMLStandardMode, nullptr); 15 CSSParserContext context(HTMLStandardMode, nullptr);
16 16
17 StyleSheetContents* styleSheet = StyleSheetContents::create(context); 17 StyleSheetContents* styleSheet = StyleSheetContents::create(context);
18 styleSheet->parseString("@namespace ns url(test);"); 18 styleSheet->parseString("@namespace ns url(test);");
19 EXPECT_EQ(1U, styleSheet->ruleCount()); 19 EXPECT_EQ(1U, styleSheet->ruleCount());
20 20
21 styleSheet->setMutable(); 21 styleSheet->setMutable();
22 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet, "@me dia all { div { color: pink } }"), 0); 22 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet, "@me dia all { div { color: pink } }"), 0);
23 EXPECT_EQ(1U, styleSheet->ruleCount()); 23 EXPECT_EQ(1U, styleSheet->ruleCount());
24 EXPECT_FALSE(styleSheet->hasMediaQueries()); 24 EXPECT_TRUE(styleSheet->hasMediaQueries());
25 25
26 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet, "@me dia all { div { color: green } }"), 1); 26 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet, "@me dia all { div { color: green } }"), 1);
27 EXPECT_EQ(2U, styleSheet->ruleCount()); 27 EXPECT_EQ(2U, styleSheet->ruleCount());
28 EXPECT_TRUE(styleSheet->hasMediaQueries()); 28 EXPECT_TRUE(styleSheet->hasMediaQueries());
29 } 29 }
30 30
31 TEST(StyleSheetContentsTest, InsertFontFaceRule)
32 {
33 CSSParserContext context(HTMLStandardMode, nullptr);
34
35 StyleSheetContents* styleSheet = StyleSheetContents::create(context);
36 styleSheet->parseString("@namespace ns url(test);");
37 EXPECT_EQ(1U, styleSheet->ruleCount());
38
39 styleSheet->setMutable();
40 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet, "@fo nt-face { font-family: a }"), 0);
41 EXPECT_EQ(1U, styleSheet->ruleCount());
42 EXPECT_TRUE(styleSheet->hasFontFaceRule());
43
44 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet, "@fo nt-face { font-family: b }"), 1);
45 EXPECT_EQ(2U, styleSheet->ruleCount());
46 EXPECT_TRUE(styleSheet->hasFontFaceRule());
47 }
48
31 } // namespace blink 49 } // namespace blink
OLDNEW
« 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