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

Unified Diff: third_party/WebKit/Source/core/dom/StyleEngineTest.cpp

Issue 2554193002: Make sure media query results are re-collected. (Closed)
Patch Set: Rebased Created 4 years 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/dom/StyleEngineTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp b/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
index d3c222399630eb1914a0b2905e793c6653c14809..fcac598f633f1aace508d038e37520358419e042 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
@@ -320,4 +320,58 @@ TEST_F(StyleEngineTest, HasViewportDependentMediaQueries) {
EXPECT_FALSE(document().styleEngine().hasViewportDependentMediaQueries());
}
+TEST_F(StyleEngineTest, StyleMediaAttributeStyleChange) {
+ document().body()->setInnerHTML(
+ "<style id='s1' media='(max-width: 1px)'>#t1 { color: green }</style>"
+ "<div id='t1'>Green</div><div></div>");
+ document().view()->updateAllLifecyclePhases();
+
+ Element* t1 = document().getElementById("t1");
+ ASSERT_TRUE(t1);
+ ASSERT_TRUE(t1->computedStyle());
+ EXPECT_EQ(makeRGB(0, 0, 0),
+ t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
+
+ unsigned beforeCount = styleEngine().styleForElementCount();
+
+ Element* s1 = document().getElementById("s1");
+ s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)");
+ document().view()->updateAllLifecyclePhases();
+
+ unsigned afterCount = styleEngine().styleForElementCount();
+ // TODO(rune@opera.com): Should be 1u for ruleset based invalidations.
+ EXPECT_EQ(8u, afterCount - beforeCount);
+
+ ASSERT_TRUE(t1->computedStyle());
+ EXPECT_EQ(makeRGB(0, 128, 0),
+ t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
+}
+
+TEST_F(StyleEngineTest, StyleMediaAttributeNoStyleChange) {
+ document().body()->setInnerHTML(
+ "<style id='s1' media='(max-width: 1000px)'>#t1 { color: green }</style>"
+ "<div id='t1'>Green</div><div></div>");
+ document().view()->updateAllLifecyclePhases();
+
+ Element* t1 = document().getElementById("t1");
+ ASSERT_TRUE(t1);
+ ASSERT_TRUE(t1->computedStyle());
+ EXPECT_EQ(makeRGB(0, 128, 0),
+ t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
+
+ unsigned beforeCount = styleEngine().styleForElementCount();
+
+ Element* s1 = document().getElementById("s1");
+ s1->setAttribute(blink::HTMLNames::mediaAttr, "(max-width: 2000px)");
+ document().view()->updateAllLifecyclePhases();
+
+ unsigned afterCount = styleEngine().styleForElementCount();
+ // TODO(rune@opera.com): Should be 0 for ruleset based invalidations.
+ EXPECT_EQ(8u, afterCount - beforeCount);
+
+ ASSERT_TRUE(t1->computedStyle());
+ EXPECT_EQ(makeRGB(0, 128, 0),
+ t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | third_party/WebKit/Source/core/html/HTMLStyleElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698