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

Use SimSubrequestRequest for font resources in SimTests

SimRequest is for navigation, while other resource requests should use
SimSubresourceRequest. This patch revises a few font-related SimTests
to follow the design.

Change-Id: I5939d5499539f253012b4cae55ac9edc78b94608
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343848Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796215}
parent 83c4ec9e
...@@ -60,7 +60,8 @@ class FontDisplayAutoLCPAlignFailureModeTest ...@@ -60,7 +60,8 @@ class FontDisplayAutoLCPAlignFailureModeTest
TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFinishesBeforeLCPLimit) { TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFinishesBeforeLCPLimit) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -93,7 +94,8 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFinishesBeforeLCPLimit) { ...@@ -93,7 +94,8 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFinishesBeforeLCPLimit) {
TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFinishesAfterLCPLimit) { TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFinishesAfterLCPLimit) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -137,7 +139,8 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFinishesAfterLCPLimit) { ...@@ -137,7 +139,8 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFinishesAfterLCPLimit) {
TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFaceAddedAfterLCPLimit) { TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFaceAddedAfterLCPLimit) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write("<!doctype html>"); main_resource.Write("<!doctype html>");
...@@ -172,7 +175,8 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFaceAddedAfterLCPLimit) { ...@@ -172,7 +175,8 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, FontFaceAddedAfterLCPLimit) {
TEST_F(FontDisplayAutoLCPAlignFailureModeTest, TEST_F(FontDisplayAutoLCPAlignFailureModeTest,
FontFaceInMemoryCacheAddedAfterLCPLimit) { FontFaceInMemoryCacheAddedAfterLCPLimit) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
...@@ -212,7 +216,8 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, ...@@ -212,7 +216,8 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest,
TEST_F(FontDisplayAutoLCPAlignFailureModeTest, TEST_F(FontDisplayAutoLCPAlignFailureModeTest,
TimeoutFiredAfterDocumentShutdown) { TimeoutFiredAfterDocumentShutdown) {
SimRequest main_resource("https://example.com/", "text/html"); SimRequest main_resource("https://example.com/", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -229,7 +234,7 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, ...@@ -229,7 +234,7 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest,
<span id=target style="position:relative">0123456789</span> <span id=target style="position:relative">0123456789</span>
)HTML"); )HTML");
font_resource.Finish(); font_resource.Complete();
SimRequest next_page_resource("https://example2.com/", "text/html"); SimRequest next_page_resource("https://example2.com/", "text/html");
LoadURL("https://example2.com/"); LoadURL("https://example2.com/");
...@@ -244,10 +249,10 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest, ...@@ -244,10 +249,10 @@ TEST_F(FontDisplayAutoLCPAlignFailureModeTest,
TEST_F(FontDisplayAutoLCPAlignFailureModeTest, IconAndNonIconFonts) { TEST_F(FontDisplayAutoLCPAlignFailureModeTest, IconAndNonIconFonts) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest icon_font_resource( SimSubresourceRequest icon_font_resource(
"https://example.com/MaterialIcons-Regular.woff2", "font/woff2"); "https://example.com/MaterialIcons-Regular.woff2", "font/woff2");
SimRequest non_icon_font_resource("https://example.com/Ahem.woff2", SimSubresourceRequest non_icon_font_resource("https://example.com/Ahem.woff2",
"font/woff2"); "font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -317,7 +322,8 @@ class FontDisplayAutoLCPAlignSwapModeTest ...@@ -317,7 +322,8 @@ class FontDisplayAutoLCPAlignSwapModeTest
TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFinishesBeforeLCPLimit) { TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFinishesBeforeLCPLimit) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -350,7 +356,8 @@ TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFinishesBeforeLCPLimit) { ...@@ -350,7 +356,8 @@ TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFinishesBeforeLCPLimit) {
TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFinishesAfterLCPLimit) { TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFinishesAfterLCPLimit) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -393,7 +400,8 @@ TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFinishesAfterLCPLimit) { ...@@ -393,7 +400,8 @@ TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFinishesAfterLCPLimit) {
TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFaceAddedAfterLCPLimit) { TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFaceAddedAfterLCPLimit) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write("<!doctype html>"); main_resource.Write("<!doctype html>");
...@@ -426,7 +434,8 @@ TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFaceAddedAfterLCPLimit) { ...@@ -426,7 +434,8 @@ TEST_F(FontDisplayAutoLCPAlignSwapModeTest, FontFaceAddedAfterLCPLimit) {
TEST_F(FontDisplayAutoLCPAlignSwapModeTest, TEST_F(FontDisplayAutoLCPAlignSwapModeTest,
FontFaceInMemoryCacheAddedAfterLCPLimit) { FontFaceInMemoryCacheAddedAfterLCPLimit) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
......
...@@ -34,7 +34,8 @@ class FontUpdateInvalidationTest ...@@ -34,7 +34,8 @@ class FontUpdateInvalidationTest
TEST_F(FontUpdateInvalidationTest, PartialLayoutInvalidationAfterFontLoading) { TEST_F(FontUpdateInvalidationTest, PartialLayoutInvalidationAfterFontLoading) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
...@@ -86,7 +87,8 @@ TEST_F(FontUpdateInvalidationTest, PartialLayoutInvalidationAfterFontLoading) { ...@@ -86,7 +87,8 @@ TEST_F(FontUpdateInvalidationTest, PartialLayoutInvalidationAfterFontLoading) {
TEST_F(FontUpdateInvalidationTest, TEST_F(FontUpdateInvalidationTest,
PartialLayoutInvalidationAfterFontFaceDeletion) { PartialLayoutInvalidationAfterFontFaceDeletion) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
...@@ -142,7 +144,8 @@ TEST_F(FontUpdateInvalidationTest, ...@@ -142,7 +144,8 @@ TEST_F(FontUpdateInvalidationTest,
// https://crbug.com/1092411 // https://crbug.com/1092411
TEST_F(FontUpdateInvalidationTest, LayoutInvalidationOnModalDialog) { TEST_F(FontUpdateInvalidationTest, LayoutInvalidationOnModalDialog) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
...@@ -184,9 +187,10 @@ TEST_F(FontUpdateInvalidationTest, LayoutInvalidationOnModalDialog) { ...@@ -184,9 +187,10 @@ TEST_F(FontUpdateInvalidationTest, LayoutInvalidationOnModalDialog) {
// https://crbug.com/1101483 // https://crbug.com/1101483
TEST_F(FontUpdateInvalidationTest, FallbackBetweenPendingAndLoadedCustomFonts) { TEST_F(FontUpdateInvalidationTest, FallbackBetweenPendingAndLoadedCustomFonts) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest slow_font_resource("https://example.com/nonexist.woff2", SimSubresourceRequest slow_font_resource("https://example.com/nonexist.woff2",
"font/woff2"); "font/woff2");
SimRequest fast_font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest fast_font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -217,7 +221,7 @@ TEST_F(FontUpdateInvalidationTest, FallbackBetweenPendingAndLoadedCustomFonts) { ...@@ -217,7 +221,7 @@ TEST_F(FontUpdateInvalidationTest, FallbackBetweenPendingAndLoadedCustomFonts) {
Element* target = GetDocument().getElementById("target"); Element* target = GetDocument().getElementById("target");
DCHECK_EQ(250, target->OffsetWidth()); DCHECK_EQ(250, target->OffsetWidth());
slow_font_resource.Finish(); slow_font_resource.Complete();
Compositor().BeginFrame(); Compositor().BeginFrame();
EXPECT_EQ(250, target->OffsetWidth()); EXPECT_EQ(250, target->OffsetWidth());
...@@ -226,7 +230,8 @@ TEST_F(FontUpdateInvalidationTest, FallbackBetweenPendingAndLoadedCustomFonts) { ...@@ -226,7 +230,8 @@ TEST_F(FontUpdateInvalidationTest, FallbackBetweenPendingAndLoadedCustomFonts) {
// https://crrev.com/1397423004 // https://crrev.com/1397423004
TEST_F(FontUpdateInvalidationTest, NoRedundantLoadingForSegmentedFont) { TEST_F(FontUpdateInvalidationTest, NoRedundantLoadingForSegmentedFont) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/font2.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/font2.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
......
...@@ -54,7 +54,8 @@ class FontPreloadManagerTest : public SimTest { ...@@ -54,7 +54,8 @@ class FontPreloadManagerTest : public SimTest {
TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) { TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/font.woff", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/font.woff",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
...@@ -72,7 +73,7 @@ TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) { ...@@ -72,7 +73,7 @@ TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) {
EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts()); EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts());
EXPECT_EQ(State::kLoading, GetState()); EXPECT_EQ(State::kLoading, GetState());
font_resource.Finish(); font_resource.Complete();
test::RunPendingTasks(); test::RunPendingTasks();
// Font preloading no longer blocks renderings. However, rendering is still // Font preloading no longer blocks renderings. However, rendering is still
...@@ -91,7 +92,8 @@ TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) { ...@@ -91,7 +92,8 @@ TEST_F(FontPreloadManagerTest, FastFontFinishBeforeBody) {
TEST_F(FontPreloadManagerTest, FastFontFinishAfterBody) { TEST_F(FontPreloadManagerTest, FastFontFinishAfterBody) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/font.woff", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/font.woff",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
...@@ -114,7 +116,7 @@ TEST_F(FontPreloadManagerTest, FastFontFinishAfterBody) { ...@@ -114,7 +116,7 @@ TEST_F(FontPreloadManagerTest, FastFontFinishAfterBody) {
EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts()); EXPECT_TRUE(GetFontPreloadManager().HasPendingRenderBlockingFonts());
EXPECT_EQ(State::kLoading, GetState()); EXPECT_EQ(State::kLoading, GetState());
font_resource.Finish(); font_resource.Complete();
test::RunPendingTasks(); test::RunPendingTasks();
// Rendering starts after font preloading has finished. // Rendering starts after font preloading has finished.
...@@ -125,7 +127,8 @@ TEST_F(FontPreloadManagerTest, FastFontFinishAfterBody) { ...@@ -125,7 +127,8 @@ TEST_F(FontPreloadManagerTest, FastFontFinishAfterBody) {
TEST_F(FontPreloadManagerTest, SlowFontTimeoutBeforeBody) { TEST_F(FontPreloadManagerTest, SlowFontTimeoutBeforeBody) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/font.woff", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/font.woff",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
...@@ -155,12 +158,13 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutBeforeBody) { ...@@ -155,12 +158,13 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutBeforeBody) {
EXPECT_FALSE(GetFontPreloadManager().HasPendingRenderBlockingFonts()); EXPECT_FALSE(GetFontPreloadManager().HasPendingRenderBlockingFonts());
EXPECT_EQ(State::kUnblocked, GetState()); EXPECT_EQ(State::kUnblocked, GetState());
font_resource.Finish(); font_resource.Complete();
} }
TEST_F(FontPreloadManagerTest, SlowFontTimeoutAfterBody) { TEST_F(FontPreloadManagerTest, SlowFontTimeoutAfterBody) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/font.woff", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/font.woff",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Write(R"HTML( main_resource.Write(R"HTML(
...@@ -189,13 +193,14 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutAfterBody) { ...@@ -189,13 +193,14 @@ TEST_F(FontPreloadManagerTest, SlowFontTimeoutAfterBody) {
EXPECT_FALSE(GetFontPreloadManager().HasPendingRenderBlockingFonts()); EXPECT_FALSE(GetFontPreloadManager().HasPendingRenderBlockingFonts());
EXPECT_EQ(State::kUnblocked, GetState()); EXPECT_EQ(State::kUnblocked, GetState());
font_resource.Finish(); font_resource.Complete();
} }
// A trivial test case to verify test setup // A trivial test case to verify test setup
TEST_F(FontPreloadManagerTest, RegularWebFont) { TEST_F(FontPreloadManagerTest, RegularWebFont) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -226,7 +231,8 @@ TEST_F(FontPreloadManagerTest, RegularWebFont) { ...@@ -226,7 +231,8 @@ TEST_F(FontPreloadManagerTest, RegularWebFont) {
TEST_F(FontPreloadManagerTest, OptionalFontWithoutPreloading) { TEST_F(FontPreloadManagerTest, OptionalFontWithoutPreloading) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -259,7 +265,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontWithoutPreloading) { ...@@ -259,7 +265,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontWithoutPreloading) {
TEST_F(FontPreloadManagerTest, OptionalFontRemoveAndReadd) { TEST_F(FontPreloadManagerTest, OptionalFontRemoveAndReadd) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -302,7 +309,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontRemoveAndReadd) { ...@@ -302,7 +309,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontRemoveAndReadd) {
TEST_F(FontPreloadManagerTest, OptionalFontSlowPreloading) { TEST_F(FontPreloadManagerTest, OptionalFontSlowPreloading) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -351,7 +359,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontSlowPreloading) { ...@@ -351,7 +359,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontSlowPreloading) {
TEST_F(FontPreloadManagerTest, OptionalFontFastPreloading) { TEST_F(FontPreloadManagerTest, OptionalFontFastPreloading) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -396,7 +405,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontFastPreloading) { ...@@ -396,7 +405,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontFastPreloading) {
TEST_F(FontPreloadManagerTest, OptionalFontSlowImperativeLoad) { TEST_F(FontPreloadManagerTest, OptionalFontSlowImperativeLoad) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -446,7 +456,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontSlowImperativeLoad) { ...@@ -446,7 +456,8 @@ TEST_F(FontPreloadManagerTest, OptionalFontSlowImperativeLoad) {
TEST_F(FontPreloadManagerTest, OptionalFontFastImperativeLoad) { TEST_F(FontPreloadManagerTest, OptionalFontFastImperativeLoad) {
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/Ahem.woff2", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/Ahem.woff2",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -544,7 +555,8 @@ TEST_P(FontPreloadBehaviorObservationTest, ObserveBehaviorWithLinkPreload) { ...@@ -544,7 +555,8 @@ TEST_P(FontPreloadBehaviorObservationTest, ObserveBehaviorWithLinkPreload) {
} }
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/font.woff", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/font.woff",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -556,7 +568,7 @@ TEST_P(FontPreloadBehaviorObservationTest, ObserveBehaviorWithLinkPreload) { ...@@ -556,7 +568,7 @@ TEST_P(FontPreloadBehaviorObservationTest, ObserveBehaviorWithLinkPreload) {
EXPECT_TRUE(ObservedBehaviors() | EXPECT_TRUE(ObservedBehaviors() |
kLoadingBehaviorFontPreloadStartedBeforeRendering); kLoadingBehaviorFontPreloadStartedBeforeRendering);
font_resource.Finish(); font_resource.Complete();
test::RunPendingTasks(); test::RunPendingTasks();
} }
...@@ -571,7 +583,8 @@ TEST_P(FontPreloadBehaviorObservationTest, ObserveBehaviorWithImperativeLoad) { ...@@ -571,7 +583,8 @@ TEST_P(FontPreloadBehaviorObservationTest, ObserveBehaviorWithImperativeLoad) {
} }
SimRequest main_resource("https://example.com", "text/html"); SimRequest main_resource("https://example.com", "text/html");
SimRequest font_resource("https://example.com/font.woff", "font/woff2"); SimSubresourceRequest font_resource("https://example.com/font.woff",
"font/woff2");
LoadURL("https://example.com"); LoadURL("https://example.com");
main_resource.Complete(R"HTML( main_resource.Complete(R"HTML(
...@@ -584,7 +597,7 @@ TEST_P(FontPreloadBehaviorObservationTest, ObserveBehaviorWithImperativeLoad) { ...@@ -584,7 +597,7 @@ TEST_P(FontPreloadBehaviorObservationTest, ObserveBehaviorWithImperativeLoad) {
EXPECT_TRUE(ObservedBehaviors() | EXPECT_TRUE(ObservedBehaviors() |
kLoadingBehaviorFontPreloadStartedBeforeRendering); kLoadingBehaviorFontPreloadStartedBeforeRendering);
font_resource.Finish(); font_resource.Complete();
test::RunPendingTasks(); test::RunPendingTasks();
} }
......
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