| 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 d6979b2c8da494b263afc2928dbcbfbce2a69cec..4e3fcb4833c19c45a63ae025227bce4a0f7f71b4 100644
|
| --- a/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
|
| @@ -87,20 +87,53 @@ TEST_F(StyleEngineTest, AnalyzedInject) {
|
| EXPECT_EQ(MakeRGB(255, 0, 0),
|
| t1->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor));
|
|
|
| - unsigned before_count = GetStyleEngine().StyleForElementCount();
|
| + const unsigned initial_count = GetStyleEngine().StyleForElementCount();
|
|
|
| - StyleSheetContents* parsed_sheet =
|
| + StyleSheetContents* green_parsed_sheet =
|
| StyleSheetContents::Create(CSSParserContext::Create(GetDocument()));
|
| - parsed_sheet->ParseString("#t1 { color: green }");
|
| - GetStyleEngine().InjectAuthorSheet(parsed_sheet);
|
| + green_parsed_sheet->ParseString("#t1 { color: green }");
|
| + WebStyleSheetId green_id =
|
| + GetStyleEngine().InjectAuthorSheet(green_parsed_sheet);
|
| + EXPECT_EQ(1u, green_id);
|
| + EXPECT_EQ(1u, GetStyleEngine().InjectedAuthorStyleSheets().size());
|
| GetDocument().View()->UpdateAllLifecyclePhases();
|
|
|
| - unsigned after_count = GetStyleEngine().StyleForElementCount();
|
| - EXPECT_EQ(1u, after_count - before_count);
|
| + EXPECT_EQ(1u, GetStyleEngine().StyleForElementCount() - initial_count);
|
|
|
| ASSERT_TRUE(t1->GetComputedStyle());
|
| EXPECT_EQ(MakeRGB(0, 128, 0),
|
| t1->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor));
|
| +
|
| + StyleSheetContents* blue_parsed_sheet =
|
| + StyleSheetContents::Create(CSSParserContext::Create(GetDocument()));
|
| + blue_parsed_sheet->ParseString("#t1 { color: blue }");
|
| + WebStyleSheetId blue_id =
|
| + GetStyleEngine().InjectAuthorSheet(blue_parsed_sheet);
|
| + EXPECT_EQ(2u, blue_id);
|
| + EXPECT_EQ(2u, GetStyleEngine().InjectedAuthorStyleSheets().size());
|
| + GetDocument().View()->UpdateAllLifecyclePhases();
|
| +
|
| + EXPECT_EQ(2u, GetStyleEngine().StyleForElementCount() - initial_count);
|
| +
|
| + ASSERT_TRUE(t1->GetComputedStyle());
|
| + EXPECT_EQ(MakeRGB(0, 0, 255),
|
| + t1->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor));
|
| +
|
| + GetStyleEngine().RemoveInjectedAuthorSheet(green_id);
|
| + EXPECT_EQ(1u, GetStyleEngine().InjectedAuthorStyleSheets().size());
|
| + GetDocument().View()->UpdateAllLifecyclePhases();
|
| + EXPECT_EQ(3u, GetStyleEngine().StyleForElementCount() - initial_count);
|
| + ASSERT_TRUE(t1->GetComputedStyle());
|
| + EXPECT_EQ(MakeRGB(0, 0, 255),
|
| + t1->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor));
|
| +
|
| + GetStyleEngine().RemoveInjectedAuthorSheet(blue_id);
|
| + EXPECT_EQ(0u, GetStyleEngine().InjectedAuthorStyleSheets().size());
|
| + GetDocument().View()->UpdateAllLifecyclePhases();
|
| + EXPECT_EQ(4u, GetStyleEngine().StyleForElementCount() - initial_count);
|
| + ASSERT_TRUE(t1->GetComputedStyle());
|
| + EXPECT_EQ(MakeRGB(255, 0, 0),
|
| + t1->GetComputedStyle()->VisitedDependentColor(CSSPropertyColor));
|
| }
|
|
|
| TEST_F(StyleEngineTest, TextToSheetCache) {
|
|
|