Commit b67d11ca authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Strip the query part when fetching the favicon.ico

This CL changes the creation of the URL used to get the favicon at the
root of the WebSite (www.website.com/favicon.ico), which is used to get
a favicon if non is provided in the html of the page.
It strips the query part of the URL, to avoid re-downloading a new
favicon everytime the query part of the URL changes.

Bug: 804077
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I1d6224af357065ab749031ca3533d5f5a5d092ff
Reviewed-on: https://chromium-review.googlesource.com/889739
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532900}
parent 95546919
...@@ -161,6 +161,24 @@ TEST_F(FaviconCallbackTest, NoFavicon) { ...@@ -161,6 +161,24 @@ TEST_F(FaviconCallbackTest, NoFavicon) {
ASSERT_TRUE(favicons[0].icon_sizes.empty()); ASSERT_TRUE(favicons[0].icon_sizes.empty());
}; };
// Tests page without favicon link but with a query and a ref in the URL.
TEST_F(FaviconCallbackTest, NoFaviconWithQuery) {
ASSERT_TRUE(observer()->favicon_url_candidates().empty());
LoadHtml(@"<html></html>",
GURL("https://chromium.test/test/test.html?q1#h1"));
WaitForCondition(^{
return observer()->favicon_url_updated();
});
const std::vector<FaviconURL>& favicons =
observer()->favicon_url_candidates();
ASSERT_EQ(1U, favicons.size());
EXPECT_EQ(GURL("https://chromium.test/favicon.ico"), favicons[0].icon_url);
EXPECT_EQ(FaviconURL::IconType::kFavicon, favicons[0].icon_type);
ASSERT_TRUE(favicons[0].icon_sizes.empty());
};
// Tests page with multiple favicon links. // Tests page with multiple favicon links.
TEST_F(FaviconCallbackTest, MultipleFavicons) { TEST_F(FaviconCallbackTest, MultipleFavicons) {
ASSERT_TRUE(observer()->favicon_url_candidates().empty()); ASSERT_TRUE(observer()->favicon_url_candidates().empty());
......
...@@ -2458,6 +2458,8 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -2458,6 +2458,8 @@ registerLoadRequestForURL:(const GURL&)requestURL
if (originGURL.is_valid() && originGURL.SchemeIsHTTPOrHTTPS()) { if (originGURL.is_valid() && originGURL.SchemeIsHTTPOrHTTPS()) {
GURL::Replacements replacements; GURL::Replacements replacements;
replacements.SetPathStr("/favicon.ico"); replacements.SetPathStr("/favicon.ico");
replacements.ClearQuery();
replacements.ClearRef();
urls.push_back(web::FaviconURL( urls.push_back(web::FaviconURL(
originGURL.ReplaceComponents(replacements), originGURL.ReplaceComponents(replacements),
web::FaviconURL::IconType::kFavicon, std::vector<gfx::Size>())); web::FaviconURL::IconType::kFavicon, std::vector<gfx::Size>()));
......
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