Commit 174a1b45 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Prepare DocumentLoadingRenderingTests for parser blocking.

Test extensively testing HaveRenderBlockingResourcesLoaded is always run
with the BlockHTMLParserOnStyleSheets disabled since it always true with
that flag enabled.

Various tests required us to test::RunPendingTasks() to do the work
after unblocking the parser.

There is one test still not passing because xml-stylesheet processing
instructions are not blocking parsing with the runtime flag enabled.
Will address that separately.

Bug: 891767
Change-Id: If237faca49ba965114e51b02763307f56039d8f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1936256Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719238}
parent b9b24e93
......@@ -14,6 +14,7 @@
#include "third_party/blink/renderer/core/testing/sim/sim_compositor.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
namespace blink {
......@@ -60,10 +61,12 @@ TEST_F(DocumentLoadingRenderingTest,
// Sheet finished, but no body yet, so don't resume.
css_resource.Finish();
test::RunPendingTasks();
EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
// Body inserted and sheet is loaded so resume commits.
main_resource.Write("<body>");
test::RunPendingTasks();
EXPECT_FALSE(Compositor().DeferMainFrameUpdate());
// Finish the load, should stay resumed.
......@@ -93,6 +96,7 @@ TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterSheetsLoaded) {
// Sheet finished and there's a body so resume.
css_resource.Finish();
test::RunPendingTasks();
EXPECT_FALSE(Compositor().DeferMainFrameUpdate());
// Finish the load, should stay resumed.
......@@ -198,6 +202,7 @@ TEST_F(DocumentLoadingRenderingTest, ShouldScheduleFrameAfterSheetsLoaded) {
first_css_resource.Write("body { color: red; }");
main_resource.Write("<body>");
first_css_resource.Finish();
test::RunPendingTasks();
// Sheet finished and there's a body so resume.
EXPECT_FALSE(Compositor().DeferMainFrameUpdate());
......@@ -251,24 +256,24 @@ TEST_F(DocumentLoadingRenderingTest,
</div>
)HTML");
// Trigger a layout with pending sheets. For example a page could trigger
// this by doing offsetTop in a setTimeout, or by a parent frame executing
// script that touched offsetTop in the child frame.
// Trigger a layout with a blocking sheet. For example, a parent frame
// executing a script that reads offsetTop in the child frame could do this.
auto* child_frame =
To<HTMLIFrameElement>(GetDocument().getElementById("frame"));
child_frame->contentDocument()->UpdateStyleAndLayout();
auto frame2 = Compositor().BeginFrame();
// The child frame still has pending sheets, so we should not paint it.
// The child frame still has a sheet blocking in head, so nothing is painted.
// Still only paint the main frame.
EXPECT_EQ(2u, frame2.DrawCount());
EXPECT_TRUE(frame2.Contains(SimCanvas::kText, "black"));
EXPECT_TRUE(frame2.Contains(SimCanvas::kRect, "white"));
// Finish loading the sheets in the child frame. After it should issue a
// paint invalidation for every layer when the frame becomes unthrottled.
// Finish loading the sheets in the child frame. After it we should continue
// parsing and paint the frame contents.
css_resource.Complete();
test::RunPendingTasks();
// First frame where all frames are loaded, should paint the text in the
// child frame.
......@@ -337,6 +342,7 @@ TEST_F(DocumentLoadingRenderingTest,
// Finish loading the sheets in the child frame. Should enable lifecycle
// updates and raf callbacks.
css_resource.Complete();
test::RunPendingTasks();
// Frame with all lifecycle updates enabled.
auto* frame2_callback = MakeGarbageCollected<CheckRafCallback>();
......@@ -350,6 +356,11 @@ TEST_F(DocumentLoadingRenderingTest,
TEST_F(DocumentLoadingRenderingTest,
ShouldContinuePaintingWhenSheetsStartedAfterBody) {
// HaveRenderBlockingResourcesLoaded being tested here is always true with
// ScopedBlockHTMLParserOnStyleSheets enabled. Remove this test when the flag
// is removed.
ScopedBlockHTMLParserOnStyleSheetsForTest scoped_feature(false);
SimRequest main_resource("https://example.com/test.html", "text/html");
SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
"text/css");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment