Commit 91d7b62f authored by Ryan Sturm's avatar Ryan Sturm Committed by Commit Bot

NoStatePrefetch should prefetch WebFonts

Currently, NoStatePrefetch only fetches HTML + CSS + Sync JS.We should
experiment with also prefetching WebFonts since WebFonts are render
blocking on fast connections. This CL adds a finch parameter to LWNSP
experiment.

Bug: 1021749
Change-Id: I9bbf3c629d620df89aa6ae54d3352d7ba1fb6952
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901590Reviewed-by: default avatarRobert Ogden <robertogden@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714918}
parent 5da724a1
...@@ -482,6 +482,43 @@ IN_PROC_BROWSER_TEST_F(HTMLCSSSyncScriptNoStatePrefetchBrowserTest, ...@@ -482,6 +482,43 @@ IN_PROC_BROWSER_TEST_F(HTMLCSSSyncScriptNoStatePrefetchBrowserTest,
WaitForRequestCount(src_server()->GetURL(kPrefetchFont), 0); WaitForRequestCount(src_server()->GetURL(kPrefetchFont), 0);
} }
// Test and Test Class for lightweight prefetch under the
// HTML+CSS+SyncScript+Font configuration.
class HTMLCSSSyncScriptFontNoStatePrefetchBrowserTest
: public NoStatePrefetchBrowserTest {
public:
void SetUp() override {
std::map<std::string, std::string> parameters;
parameters["skip_other"] = "true";
parameters["skip_async_script"] = "true";
parameters["skip_font"] = "false";
feature_list_.InitWithFeaturesAndParameters(
{{blink::features::kLightweightNoStatePrefetch, parameters}}, {});
NoStatePrefetchBrowserTest::SetUp();
}
private:
base::test::ScopedFeatureList feature_list_;
};
// Checks that the expected resource types are fetched via NoState Prefetch.
IN_PROC_BROWSER_TEST_F(HTMLCSSSyncScriptFontNoStatePrefetchBrowserTest,
PrefetchHTMLCSSSyncScript) {
std::unique_ptr<TestPrerender> test_prerender =
PrefetchFromFile(kPrefetchPageMultipleResourceTypes,
FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
// Verify that the page load did not happen.
test_prerender->WaitForLoads(0);
WaitForRequestCount(src_server()->GetURL(kPrefetchPageMultipleResourceTypes),
1);
WaitForRequestCount(src_server()->GetURL(kPrefetchScript), 1);
WaitForRequestCount(src_server()->GetURL(kPrefetchScript2), 0);
WaitForRequestCount(src_server()->GetURL(kPrefetchPng), 0);
WaitForRequestCount(src_server()->GetURL(kPrefetchCss), 1);
WaitForRequestCount(src_server()->GetURL(kPrefetchFont), 1);
}
// Test and Test Class for lightweight prefetch under the HTML+CSS+Script // Test and Test Class for lightweight prefetch under the HTML+CSS+Script
// configuration. // configuration.
class HTMLCSSScriptNoStatePrefetchBrowserTest class HTMLCSSScriptNoStatePrefetchBrowserTest
......
...@@ -106,7 +106,6 @@ bool HTMLResourcePreloader::AllowPreloadRequest(PreloadRequest* preload) const { ...@@ -106,7 +106,6 @@ bool HTMLResourcePreloader::AllowPreloadRequest(PreloadRequest* preload) const {
// resources are either classified into CSS (always fetched when not in the // resources are either classified into CSS (always fetched when not in the
// HTML only arm), JS (skip_script param), or other. // HTML only arm), JS (skip_script param), or other.
switch (preload->GetResourceType()) { switch (preload->GetResourceType()) {
case ResourceType::kFont:
case ResourceType::kRaw: case ResourceType::kRaw:
case ResourceType::kSVGDocument: case ResourceType::kSVGDocument:
case ResourceType::kXSLStyleSheet: case ResourceType::kXSLStyleSheet:
...@@ -123,6 +122,9 @@ bool HTMLResourcePreloader::AllowPreloadRequest(PreloadRequest* preload) const { ...@@ -123,6 +122,9 @@ bool HTMLResourcePreloader::AllowPreloadRequest(PreloadRequest* preload) const {
return false; return false;
case ResourceType::kCSSStyleSheet: case ResourceType::kCSSStyleSheet:
return true; return true;
case ResourceType::kFont:
return !GetFieldTrialParamByFeatureAsBool(
features::kLightweightNoStatePrefetch, "skip_font", true);
case ResourceType::kScript: case ResourceType::kScript:
// We might skip all script. // We might skip all script.
if (GetFieldTrialParamByFeatureAsBool( if (GetFieldTrialParamByFeatureAsBool(
......
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