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 59348fd59c0160ffdbb484604c97221173f0f0e0..1708917c5ee5b559f11bb81804c2a8de6e405f72 100644 |
--- a/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp |
+++ b/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp |
@@ -6,7 +6,9 @@ |
#include "core/css/StyleSheetContents.h" |
#include "core/dom/Document.h" |
+#include "core/dom/NodeComputedStyle.h" |
#include "core/frame/FrameView.h" |
+#include "core/html/HTMLElement.h" |
#include "core/testing/DummyPageHolder.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -40,4 +42,28 @@ TEST_F(StyleEngineTest, DocumentDirtyAfterInject) |
EXPECT_TRUE(isDocumentStyleSheetCollectionClean()); |
} |
+TEST_F(StyleEngineTest, AnalyzedInject) |
+{ |
+ document().body()->setInnerHTML("<style>div { color: red }</style><div id='t1'>Green</div><div></div>", ASSERT_NO_EXCEPTION); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ Element* t1 = document().getElementById("t1"); |
+ ASSERT_TRUE(t1); |
+ ASSERT_TRUE(t1->computedStyle()); |
+ EXPECT_EQ(makeRGB(255, 0, 0), t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); |
+ |
+ unsigned beforeCount = styleEngine().styleForElementCount(); |
+ |
+ RefPtrWillBeRawPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(CSSParserContext(document(), nullptr)); |
+ parsedSheet->parseString("#t1 { color: green }"); |
+ styleEngine().injectAuthorSheet(parsedSheet); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ unsigned afterCount = styleEngine().styleForElementCount(); |
+ EXPECT_EQ(1u, afterCount - beforeCount); |
+ |
+ ASSERT_TRUE(t1->computedStyle()); |
+ EXPECT_EQ(makeRGB(0, 128, 0), t1->computedStyle()->visitedDependentColor(CSSPropertyColor)); |
+} |
+ |
} // namespace blink |