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

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

Issue 2614663004: Pause HTML parser for external stylesheets in the body (Closed)
Patch Set: merge to trunk Created 3 years, 11 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
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 9fdbe5e6c2bef7918ffc9de0700aec46f5e943f8..22c224e30dddd78625146ee9fdfe0d9ecd03aa83 100644
--- a/third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp
+++ b/third_party/WebKit/Source/web/tests/DocumentLoadingRenderingTest.cpp
@@ -7,6 +7,7 @@
#include "core/html/HTMLIFrameElement.h"
#include "core/layout/api/LayoutViewItem.h"
#include "core/paint/PaintLayer.h"
+#include "platform/testing/UnitTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "web/tests/sim/SimCompositor.h"
#include "web/tests/sim/SimDisplayItemList.h"
@@ -380,4 +381,42 @@ TEST_F(DocumentLoadingRenderingTest,
EXPECT_TRUE(document().isRenderingReady());
}
+TEST_F(DocumentLoadingRenderingTest,
+ ShouldPauseParsingForExternalStylesheetsInBody) {
+ SimRequest mainResource("https://example.com/test.html", "text/html");
+ SimRequest cssHeadResource("https://example.com/testHead.css", "text/css");
+ SimRequest cssBodyResource("https://example.com/testBody.css", "text/css");
+
+ loadURL("https://example.com/test.html");
+
+ mainResource.complete(
+ "<!DOCTYPE html>"
+ "<html><head>"
+ "<link rel=stylesheet href=testHead.css>"
+ "</head><body>"
+ "<div id=\"before\"></div>"
+ "<link rel=stylesheet href=testBody.css>"
+ "<div id=\"after\"></div>"
+ "</body></html>");
+
+ // Head and body css are pending. The "before" div should exist on the DOM but
+ // "after" should not get created until the body css loads. That way with
+ // rendering unblocked for body css the content that may depend on the
+ // css will not flash with an incorrect style before the css loads.
+ EXPECT_TRUE(document().getElementById("before"));
+ EXPECT_FALSE(document().getElementById("after"));
+
+ // Completing the head css shouldn't change anything
+ cssHeadResource.complete("");
+ EXPECT_TRUE(document().getElementById("before"));
+ EXPECT_FALSE(document().getElementById("after"));
+
+ // Completing the body resource and pumping the tasks should continue creating
+ // the dom and create the "after" div.
+ cssBodyResource.complete("");
+ testing::runPendingTasks();
+ EXPECT_TRUE(document().getElementById("before"));
+ EXPECT_TRUE(document().getElementById("after"));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698