Skip to content

Commit

Permalink
[M103] speculation rules: Put prefetch_with_subresources behind a sep…
Browse files Browse the repository at this point in the history
…arate runtime flag.

It's not slated to ship but since prefetch is, it needs a separate runtime
flag (until/unless we decide to remove it altogether).

(cherry picked from commit 4ecf6d3)

Bug: 1325177
Change-Id: Ib76f4be3a16747913e564ab27899b091db89fe2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3645705
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1003783}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3652636
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Auto-Submit: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/branch-heads/5060@{#61}
Cr-Branched-From: b83393d-refs/heads/main@{#1002911}
  • Loading branch information
jeremyroman authored and Chromium LUCI CQ committed May 17, 2022
1 parent 2aa3e11 commit 6a43cc1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class NoStatePrefetchBrowserTest
command_line->AppendSwitchASCII(embedder_support::kOriginTrialPublicKey,
kOriginTrialPublicKeyForTesting);
command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
"SpeculationRulesPrefetchProxy");
"SpeculationRulesPrefetchWithSubresources");
}

void SetUpOnMainThread() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ class PrefetchProxyBrowserTest
cmd->AppendSwitchASCII("isolated-prerender-tunnel-proxy",
GetProxyURL().spec());
cmd->AppendSwitchASCII(switches::kEnableBlinkFeatures,
"SpeculationRulesPrefetchProxy");
"SpeculationRulesPrefetchProxy,"
"SpeculationRulesPrefetchWithSubresources");
}

content::WebContents* GetWebContents() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ void DocumentSpeculationRules::UpdateSpeculationCandidates() {
execution_context)) {
push_candidates(mojom::blink::SpeculationAction::kPrefetch,
rule_set->prefetch_rules());
}

// Ditto for SpeculationRulesPrefetchWithSubresources.
if (RuntimeEnabledFeatures::SpeculationRulesPrefetchWithSubresourcesEnabled(
execution_context)) {
push_candidates(
mojom::blink::SpeculationAction::kPrefetchWithSubresources,
rule_set->prefetch_with_subresources_rules());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ TEST_F(SpeculationRuleSetTest, PropagatesAllRulesToBrowser) {
DummyPageHolder page_holder;
StubSpeculationHost speculation_host;
const String speculation_script =
R"({"prefetch_with_subresources": [
R"({"prefetch": [
{"source": "list",
"urls": ["https://example.com/foo", "https://example.com/bar"],
"requires": ["anonymous-client-ip-when-cross-origin"]}
Expand All @@ -348,15 +348,13 @@ TEST_F(SpeculationRuleSetTest, PropagatesAllRulesToBrowser) {
ASSERT_EQ(candidates.size(), 3u);
{
const auto& candidate = candidates[0];
EXPECT_EQ(candidate->action,
mojom::blink::SpeculationAction::kPrefetchWithSubresources);
EXPECT_EQ(candidate->action, mojom::blink::SpeculationAction::kPrefetch);
EXPECT_EQ(candidate->url, "https://example.com/foo");
EXPECT_TRUE(candidate->requires_anonymous_client_ip_when_cross_origin);
}
{
const auto& candidate = candidates[1];
EXPECT_EQ(candidate->action,
mojom::blink::SpeculationAction::kPrefetchWithSubresources);
EXPECT_EQ(candidate->action, mojom::blink::SpeculationAction::kPrefetch);
EXPECT_EQ(candidate->url, "https://example.com/bar");
EXPECT_TRUE(candidate->requires_anonymous_client_ip_when_cross_origin);
}
Expand Down Expand Up @@ -404,7 +402,7 @@ TEST_F(SpeculationRuleSetTest, PrefetchIgnorePrerenderRules) {
DummyPageHolder page_holder;
StubSpeculationHost speculation_host;
const String speculation_script =
R"({"prefetch_with_subresources": [
R"({"prefetch": [
{"source": "list",
"urls": ["https://example.com/foo", "https://example.com/bar"],
"requires": ["anonymous-client-ip-when-cross-origin"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@
// was enabled.
{
name: "SpeculationRules",
implied_by: ["SpeculationRulesPrefetchProxy", "Prerender2"],
implied_by: ["SpeculationRulesPrefetchProxy", "SpeculationRulesPrefetchWithSubresources", "Prerender2"],
origin_trial_feature_name: "SpeculationRules__DONOTUSE",
},
// Origin trial to enable Speculation Rules for access to the prefetch proxy.
Expand All @@ -2195,6 +2195,9 @@
name: "SpeculationRulesPrefetchProxy",
origin_trial_feature_name: "SpeculationRulesPrefetch",
},
{
"name": "SpeculationRulesPrefetchWithSubresources",
},
{
name: "SrcsetMaxDensity",
},
Expand Down

0 comments on commit 6a43cc1

Please sign in to comment.