Index: third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp |
diff --git a/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp b/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp |
index af1c54ca2cb7169d13f6ce2498d84bc0a5f02b6a..1187aa3c1af7f84e9026ac4bbd29b085640a0264 100644 |
--- a/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp |
+++ b/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp |
@@ -10,6 +10,7 @@ |
#include "core/css/StyleSheetContents.h" |
#include "core/css/StyleSheetList.h" |
#include "core/css/parser/CSSParserContext.h" |
+#include "core/css/parser/MediaQueryParser.h" |
#include "core/dom/StyleEngine.h" |
#include "core/dom/shadow/ShadowRoot.h" |
#include "core/dom/shadow/ShadowRootInit.h" |
@@ -409,6 +410,35 @@ TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_DisableAndAppend) { |
EXPECT_EQ(2u, changed_rule_sets.size()); |
} |
+TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddRemoveNonMatchingMQ) { |
+ ActiveStyleSheetVector old_sheets; |
+ ActiveStyleSheetVector new_sheets; |
+ HeapHashSet<Member<RuleSet>> changed_rule_sets; |
+ |
+ EXPECT_EQ( |
+ kNoActiveSheetsChanged, |
+ CompareActiveStyleSheets(old_sheets, new_sheets, changed_rule_sets)); |
+ EXPECT_EQ(0u, changed_rule_sets.size()); |
+ |
+ CSSStyleSheet* sheet1 = CreateSheet(); |
+ MediaQuerySet* mq = |
+ MediaQueryParser::ParseMediaQuerySet("(min-width: 9000px)"); |
+ sheet1->SetMediaQueries(mq); |
+ sheet1->MatchesMediaQueries(MediaQueryEvaluator()); |
+ |
+ new_sheets.push_back(std::make_pair(sheet1, nullptr)); |
+ |
+ EXPECT_EQ( |
+ kActiveSheetsAppended, |
+ CompareActiveStyleSheets(old_sheets, new_sheets, changed_rule_sets)); |
+ EXPECT_EQ(0u, changed_rule_sets.size()); |
+ |
+ EXPECT_EQ( |
+ kActiveSheetsChanged, |
+ CompareActiveStyleSheets(new_sheets, old_sheets, changed_rule_sets)); |
+ EXPECT_EQ(0u, changed_rule_sets.size()); |
+} |
+ |
TEST_F(ApplyRulesetsTest, AddUniversalRuleToDocument) { |
GetDocument().View()->UpdateAllLifecyclePhases(); |