Commit b4f12f8d authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Stop using async parsing in FontPreloadManagerTest

The unit test framework unnecessarily enables async parsing and
complicates the test cases. So this patch stops it.

Bug: 1040632
Change-Id: Iabed725367d987c4a852d35facda96678834b4bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088808Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747109}
parent 31b1ea69
...@@ -19,13 +19,6 @@ class FontPreloadManagerTest : public SimTest { ...@@ -19,13 +19,6 @@ class FontPreloadManagerTest : public SimTest {
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kFontPreloadingDelaysRendering); features::kFontPreloadingDelaysRendering);
SimTest::SetUp(); SimTest::SetUp();
// We need async parsing for link preloading.
Document::SetThreadedParsingEnabledForTesting(true);
}
void TearDown() override {
Document::SetThreadedParsingEnabledForTesting(false);
SimTest::TearDown();
} }
protected: protected:
...@@ -52,12 +45,6 @@ TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) { ...@@ -52,12 +45,6 @@ TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) {
href="https://example.com/font.woff"> href="https://example.com/font.woff">
)HTML"); )HTML");
// Set a generous timeout to make sure it doesn't fire before font loads.
GetFontPreloadManager().SetRenderDelayTimeoutForTest(base::TimeDelta::Max());
// Run async parsing, which triggers link preloading.
test::RunPendingTasks();
// Rendering is blocked due to ongoing font preloading. // Rendering is blocked due to ongoing font preloading.
EXPECT_TRUE(Compositor().DeferMainFrameUpdate()); EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts()); EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts());
...@@ -73,7 +60,6 @@ TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) { ...@@ -73,7 +60,6 @@ TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) {
EXPECT_EQ(State::kLoaded, GetState()); EXPECT_EQ(State::kLoaded, GetState());
main_resource.Complete("</head><body>some text</body>"); main_resource.Complete("</head><body>some text</body>");
test::RunPendingTasks();
// Rendering starts after BODY has arrived, as the font was loaded earlier. // Rendering starts after BODY has arrived, as the font was loaded earlier.
EXPECT_FALSE(Compositor().DeferMainFrameUpdate()); EXPECT_FALSE(Compositor().DeferMainFrameUpdate());
...@@ -93,19 +79,12 @@ TEST_F(FontPreloadManagerTest, FastFontFinishAfterBody) { ...@@ -93,19 +79,12 @@ TEST_F(FontPreloadManagerTest, FastFontFinishAfterBody) {
href="https://example.com/font.woff"> href="https://example.com/font.woff">
)HTML"); )HTML");
// Set a generous timeout to make sure it doesn't fire before font loads.
GetFontPreloadManager().SetRenderDelayTimeoutForTest(base::TimeDelta::Max());
// Run async parsing, which triggers link preloading.
test::RunPendingTasks();
// Rendering is blocked due to ongoing font preloading. // Rendering is blocked due to ongoing font preloading.
EXPECT_TRUE(Compositor().DeferMainFrameUpdate()); EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts()); EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts());
EXPECT_EQ(State::kLoading, GetState()); EXPECT_EQ(State::kLoading, GetState());
main_resource.Complete("</head><body>some text</body>"); main_resource.Complete("</head><body>some text</body>");
test::RunPendingTasks();
// Rendering is still blocked by font, even if we already have BODY, because // Rendering is still blocked by font, even if we already have BODY, because
// the font was *not* loaded earlier. // the font was *not* loaded earlier.
...@@ -134,13 +113,6 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutBeforeBody) { ...@@ -134,13 +113,6 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutBeforeBody) {
href="https://example.com/font.woff"> href="https://example.com/font.woff">
)HTML"); )HTML");
// Use a generous timeout to make sure it doesn't automatically fire. We'll
// manually fire it later.
GetFontPreloadManager().SetRenderDelayTimeoutForTest(base::TimeDelta::Max());
// Run async parsing, which triggers link preloading.
test::RunPendingTasks();
// Rendering is blocked due to ongoing font preloading. // Rendering is blocked due to ongoing font preloading.
EXPECT_TRUE(Compositor().DeferMainFrameUpdate()); EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts()); EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts());
...@@ -155,7 +127,6 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutBeforeBody) { ...@@ -155,7 +127,6 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutBeforeBody) {
EXPECT_EQ(State::kUnblocked, GetState()); EXPECT_EQ(State::kUnblocked, GetState());
main_resource.Complete("</head><body>some text</body>"); main_resource.Complete("</head><body>some text</body>");
test::RunPendingTasks();
// Rendering starts after BODY has arrived. // Rendering starts after BODY has arrived.
EXPECT_FALSE(Compositor().DeferMainFrameUpdate()); EXPECT_FALSE(Compositor().DeferMainFrameUpdate());
...@@ -177,20 +148,12 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutAfterBody) { ...@@ -177,20 +148,12 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutAfterBody) {
href="https://example.com/font.woff"> href="https://example.com/font.woff">
)HTML"); )HTML");
// Use a generous timeout to make sure it doesn't automatically fire. We'll
// manually fire it later.
GetFontPreloadManager().SetRenderDelayTimeoutForTest(base::TimeDelta::Max());
// Run async parsing, which triggers link preloading.
test::RunPendingTasks();
// Rendering is blocked due to ongoing font preloading. // Rendering is blocked due to ongoing font preloading.
EXPECT_TRUE(Compositor().DeferMainFrameUpdate()); EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts()); EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts());
EXPECT_EQ(State::kLoading, GetState()); EXPECT_EQ(State::kLoading, GetState());
main_resource.Complete("</head><body>some text</body>"); main_resource.Complete("</head><body>some text</body>");
test::RunPendingTasks();
// Rendering is still blocked by font, even if we already have BODY. // Rendering is still blocked by font, even if we already have BODY.
EXPECT_TRUE(Compositor().DeferMainFrameUpdate()); EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
......
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