Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp b/third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp |
| index 93985d777527a6f5c7da37e7252dbad3e535a4e9..519996bfb4d225d47137a94c9fc389aaeb810f9a 100644 |
| --- a/third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp |
| @@ -341,5 +341,87 @@ TEST_F(DocumentLoadingRenderingTest, ShouldContinuePaintingWhenSheetsStartedAfte |
| EXPECT_TRUE(document().isRenderingReady()); |
| } |
| +// Regression test for crbug.com/646323 |
| +TEST_F(DocumentLoadingRenderingTest, ShouldNotPerformRepeatedLayoutWithPendingImport) |
| +{ |
| + SimRequest mainResource("https://example.com/test.html", "text/html"); |
| + SimRequest cssResource("https://example.com/test.css", "text/css"); |
| + |
| + loadURL("https://example.com/test.html"); |
| + |
| + mainResource.start(); |
| + mainResource.write("<!DOCTYPE html><div>foo bar.</div>"); |
| + compositor().beginFrame(); |
| + |
| + // Insert a pending sheet with @import. |
| + mainResource.write("<style>@import url('test.css')</style>"); |
| + |
| + // Do a layout with pending sheet. |
| + document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| + |
| + // HTML import is required. |
| + mainResource.write("<link rel=import>"); |
| + |
| + // updateStyleAndLayoutIgnorePendingStylesheets should not have nodes left |
| + // with placeholder style, even there are pending imports. |
| + document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| + EXPECT_FALSE(document().hasNodesWithPlaceholderStyle()); |
| + |
| + { |
| + DocumentLifecycle::DisallowTransitionScope disallowTransition(document().lifecycle()); |
| + |
| + // The test crashes if updateStyleAndLayoutIgnorePendingStylesheets |
| + // performs an extra layout, which happens if the last call left some |
| + // nodes with placeholder style. |
|
rune
2016/09/15 10:48:26
Not sure if I understood completely, but you mean
Xiaocheng
2016/09/15 11:28:30
Sorry for the confusion. I just want to check if t
rune
2016/09/15 12:37:54
Compare StyleEngine::styleForElementCount() before
|
| + document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| + } |
| + |
| + // The content of the pending sheet doesn't matter. |
| + cssResource.complete(""); |
| + mainResource.finish(); |
| +} |
| + |
| +// Regression test for a wrong fix to crbug.com/646323, which simply stops |
| +// updateStyleAndLayoutIgnorePendingStylesheets from forcing layout when there |
| +// are nodes with placeholder style. |
| +TEST_F(DocumentLoadingRenderingTest, ShouldClearPlaceholderStyleWhenIgnoringPendingStylesheet) |
| +{ |
| + SimRequest mainResource("https://example.com/test.html", "text/html"); |
| + SimRequest cssResource("https://example.com/test.css", "text/css"); |
| + |
| + loadURL("https://example.com/test.html"); |
| + |
| + mainResource.start(); |
| + mainResource.write("<!DOCTYPE html>"); |
| + |
| + // Insert a render blocking pending stylesheet. Do not let it finish. |
| + mainResource.write("<link rel=stylesheet href=test.css>"); |
| + |
| + // Insert a non-empty body. |
| + mainResource.write("foo"); |
| + |
| + // Do a layout with the pending sheet ignored, so that <body> does not get a |
| + // placeholder style. |
| + document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| + EXPECT_FALSE(document().hasNodesWithPlaceholderStyle()); |
| + |
| + // Insert a <div>, which should get a placeholder style later. |
| + mainResource.write("<div>bar</div>"); |
| + EXPECT_TRUE(document().needsLayoutTreeUpdate()); |
| + |
| + // <div> gets a placeholder style if the pending sheet is not ignored. |
| + document().updateStyleAndLayout(); |
| + EXPECT_TRUE(document().hasNodesWithPlaceholderStyle()); |
| + EXPECT_FALSE(document().needsLayoutTreeUpdate()); |
| + |
| + // updateStyleAndLayoutIgnorePendingStylesheets should clear the placeholder |
| + // style and redo layout, even if we have just finished one. |
| + document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| + EXPECT_FALSE(document().hasNodesWithPlaceholderStyle()); |
| + |
| + // The content of the pending sheet doesn't matter. |
| + cssResource.complete(""); |
| + mainResource.finish(); |
| +} |
| } // namespace blink |