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

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

Issue 2401573002: Allow active sheets to have nullptr for RuleSet. (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fd0bdc6acf4aaed4bb341d710ea8872a6b9b93e8..b703cebec826fe40941e7d0962e5b9ba41550689 100644
--- a/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp
+++ b/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp
@@ -193,4 +193,82 @@ TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_InsertedAndRemoved) {
EXPECT_EQ(&sheet3->contents()->ruleSet(), changedRuleSets[1]);
}
+TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddNullRuleSet) {
+ ActiveStyleSheetVector oldSheets;
+ ActiveStyleSheetVector newSheets;
+ HeapVector<Member<RuleSet>> changedRuleSets;
+
+ CSSStyleSheet* sheet1 = createSheet();
+ CSSStyleSheet* sheet2 = createSheet();
+
+ oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
+
+ newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
+ newSheets.append(std::make_pair(sheet2, nullptr));
+
+ EXPECT_EQ(NoActiveSheetsChanged,
+ compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
+ EXPECT_EQ(0u, changedRuleSets.size());
+}
+
+TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_RemoveNullRuleSet) {
+ ActiveStyleSheetVector oldSheets;
+ ActiveStyleSheetVector newSheets;
+ HeapVector<Member<RuleSet>> changedRuleSets;
+
+ CSSStyleSheet* sheet1 = createSheet();
+ CSSStyleSheet* sheet2 = createSheet();
+
+ oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
+ oldSheets.append(std::make_pair(sheet2, nullptr));
+
+ newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
+
+ EXPECT_EQ(NoActiveSheetsChanged,
+ compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
+ EXPECT_EQ(0u, changedRuleSets.size());
+}
+
+TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddRemoveNullRuleSet) {
+ ActiveStyleSheetVector oldSheets;
+ ActiveStyleSheetVector newSheets;
+ HeapVector<Member<RuleSet>> changedRuleSets;
+
+ CSSStyleSheet* sheet1 = createSheet();
+ CSSStyleSheet* sheet2 = createSheet();
+ CSSStyleSheet* sheet3 = createSheet();
+
+ oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
+ oldSheets.append(std::make_pair(sheet2, nullptr));
+
+ newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
+ newSheets.append(std::make_pair(sheet3, nullptr));
+
+ EXPECT_EQ(NoActiveSheetsChanged,
+ compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
+ EXPECT_EQ(0u, changedRuleSets.size());
+}
+
+TEST_F(ActiveStyleSheetsTest,
+ CompareActiveStyleSheets_RemoveNullRuleSetAndAppend) {
+ ActiveStyleSheetVector oldSheets;
+ ActiveStyleSheetVector newSheets;
+ HeapVector<Member<RuleSet>> changedRuleSets;
+
+ CSSStyleSheet* sheet1 = createSheet();
+ CSSStyleSheet* sheet2 = createSheet();
+ CSSStyleSheet* sheet3 = createSheet();
+
+ oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
+ oldSheets.append(std::make_pair(sheet2, nullptr));
+
+ newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
+ newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
+
+ EXPECT_EQ(ActiveSheetsChanged,
+ compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
+ ASSERT_EQ(1u, changedRuleSets.size());
+ EXPECT_EQ(&sheet3->contents()->ruleSet(), changedRuleSets[0]);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698