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

Unified Diff: third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp

Issue 2333263002: Document::haveImportsLoaded() should return true when ignoring pending sheets (Closed)
Patch Set: Use StyleEngine::styleForElementCount Created 4 years, 3 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/Document.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/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..98a786447a27e62badccb3a117f195e44c0ad294 100644
--- a/third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp
+++ b/third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp
@@ -341,5 +341,81 @@ 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>");
+
+ // Perform two subsequent updateStyleAndLayoutIgnorePendingStylesheets().
+ // The second one should be a no-op.
+ document().updateStyleAndLayoutIgnorePendingStylesheets();
+ unsigned styleCountBeforeSecondLayout = document().styleEngine().styleForElementCount();
+
+ document().updateStyleAndLayoutIgnorePendingStylesheets();
+ EXPECT_EQ(styleCountBeforeSecondLayout, document().styleEngine().styleForElementCount());
+
+ // 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 called on clean layout tree.
+ document().updateStyleAndLayoutIgnorePendingStylesheets();
+ EXPECT_FALSE(document().hasNodesWithPlaceholderStyle());
+
+ // The content of the pending sheet doesn't matter.
+ cssResource.complete("");
+ mainResource.finish();
+}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698