Commit 678e8ff8 authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[Prerender] LinkRelNext continues despite opt out.

Currently, the network prediction user preference allows link
rel="prerender" to continue because disabling it doesn't really prevent
web developers from fetching these resources by other means, like a
regular fetch.

The same argument should apply to link rel="next", which is what this CL
does. This also affects the handling of the WebLayer network prediction
setting in the same way.

Bug: 1122563
Change-Id: I54517c9f12ae11f56f43a0e6c42f586492d89579
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379890Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802367}
parent df295c8f
......@@ -509,12 +509,14 @@ bool PrerenderManager::IsLowEndDevice() const {
bool PrerenderManager::IsPredictionEnabled(Origin origin) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// <link rel=prerender> origins ignore the network state and the privacy
// <link rel=prerender> and <link rel=next> origins ignore the network state
// and the privacy
// settings. Web developers should be able prefetch with all possible privacy
// settings. This would avoid web devs coming up with creative ways to
// prefetch in cases they are not allowed to do so.
if (origin == ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN ||
origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN) {
origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN ||
origin == ORIGIN_LINK_REL_NEXT) {
return true;
}
......
......@@ -81,9 +81,6 @@ class NoStatePrefetchBrowserTest : public WebLayerBrowserTest {
if (request.GetURL().path().find("prefetch_meta.js") != std::string::npos) {
script_executed_ = true;
}
if (request.GetURL().path().find("alert.html") != std::string::npos) {
link_rel_next_started_ = true;
}
// The default handlers will take care of this request.
return nullptr;
......@@ -106,7 +103,6 @@ class NoStatePrefetchBrowserTest : public WebLayerBrowserTest {
std::unique_ptr<base::RunLoop> prerendered_page_fetched_;
std::unique_ptr<base::RunLoop> script_resource_fetched_;
bool link_rel_next_started_ = false;
bool script_fetched_ = false;
bool script_executed_ = false;
std::string purpose_header_value_;
......@@ -199,14 +195,14 @@ IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest,
prerendered_page_fetched_->Run();
}
// link-rel="next" doesn't happen when NoStatePrefetch has been disabled.
// link-rel="next" happens even when NoStatePrefetch has been disabled.
IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, LinkRelNextWithNSPDisabled) {
GetProfile()->SetBooleanSetting(SettingType::NETWORK_PREDICTION_ENABLED,
false);
NavigateToPageAndWaitForTitleChange(
GURL(https_server_->GetURL("/parent_page.html")),
base::ASCIIToUTF16("Parent Page"));
EXPECT_FALSE(link_rel_next_started_);
NavigateAndWaitForCompletion(
GURL(https_server_->GetURL("/link_rel_next_parent.html")), shell());
prerendered_page_fetched_->Run();
}
} // namespace weblayer
\ No newline at end of file
<html>
<body>
This page will prerender something.
<link rel="next" href="/prerendered_page.html">
</body>
<!-- Order is important for tests. -->
<head><title>Parent Page</title></head>
</html>
......@@ -2,7 +2,6 @@
<body>
This page will prerender something.
<link rel="prerender" href="/prerendered_page.html">
<link rel="next" href="/alert.html">
</body>
<!-- Order is important for tests. -->
......
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