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

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

Issue 1762443004: Avoid nuking everything when injecting stylesheet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/dom/StyleEngine.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/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
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698