OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/favicon/content/content_favicon_driver.h" | 5 #include "components/favicon/content/content_favicon_driver.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "components/favicon/core/favicon_client.h" | 8 #include "components/favicon/core/favicon_client.h" |
9 #include "components/favicon/core/favicon_handler.h" | 9 #include "components/favicon/core/favicon_handler.h" |
10 #include "components/favicon/core/favicon_service.h" | 10 #include "components/favicon/core/favicon_service.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 EXPECT_NE(0, download_id); | 99 EXPECT_NE(0, download_id); |
100 // Report download success with HTTP 200 status. | 100 // Report download success with HTTP 200 status. |
101 content_favicon_driver->DidDownloadFavicon(download_id, 200, missing_icon_url, | 101 content_favicon_driver->DidDownloadFavicon(download_id, 200, missing_icon_url, |
102 empty_icons, empty_icon_sizes); | 102 empty_icons, empty_icon_sizes); |
103 // Icon is not marked as UnableToDownload as HTTP status is not 404. | 103 // Icon is not marked as UnableToDownload as HTTP status is not 404. |
104 EXPECT_FALSE(favicon_service()->WasUnableToDownloadFavicon(missing_icon_url)); | 104 EXPECT_FALSE(favicon_service()->WasUnableToDownloadFavicon(missing_icon_url)); |
105 | 105 |
106 favicon_service()->Shutdown(); | 106 favicon_service()->Shutdown(); |
107 } | 107 } |
108 | 108 |
109 // Test that ContentFaviconDriver ignores updated favicon URLs if there is no | 109 // Test that ContentFaviconDriver handles updated favicon URLs for the initial |
110 // last committed entry. This occurs when script is injected in about:blank. | 110 // navigation. This occurs when script is injected in about:blank. |
111 // See crbug.com/520759 for more details | 111 // See crbug.com/520759 for more details. |
112 TEST_F(ContentFaviconDriverTest, FaviconUpdateNoLastCommittedEntry) { | 112 TEST_F(ContentFaviconDriverTest, FaviconUpdateForInitialNavigation) { |
113 ASSERT_EQ(nullptr, web_contents()->GetController().GetLastCommittedEntry()); | 113 ASSERT_TRUE(web_contents()->GetController().IsInitialNavigation()); |
114 | 114 |
115 std::vector<content::FaviconURL> favicon_urls; | 115 std::vector<content::FaviconURL> favicon_urls; |
116 favicon_urls.push_back(content::FaviconURL( | 116 favicon_urls.push_back(content::FaviconURL( |
117 GURL("http://www.google.ca/favicon.ico"), content::FaviconURL::FAVICON, | 117 GURL("http://www.google.ca/favicon.ico"), content::FaviconURL::FAVICON, |
118 std::vector<gfx::Size>())); | 118 std::vector<gfx::Size>())); |
119 favicon::ContentFaviconDriver* driver = | 119 favicon::ContentFaviconDriver* driver = |
120 favicon::ContentFaviconDriver::FromWebContents(web_contents()); | 120 favicon::ContentFaviconDriver::FromWebContents(web_contents()); |
121 static_cast<content::WebContentsObserver*>(driver) | 121 static_cast<content::WebContentsObserver*>(driver) |
122 ->DidUpdateFaviconURL(favicon_urls); | 122 ->DidUpdateFaviconURL(favicon_urls); |
123 | 123 |
124 // Test that ContentFaviconDriver ignored the favicon url update. | 124 // Test that ContentFaviconDriver ignored the favicon url update. |
125 EXPECT_TRUE(driver->favicon_urls().empty()); | 125 EXPECT_FALSE(driver->favicon_urls().empty()); |
126 } | 126 } |
127 | 127 |
128 } // namespace | 128 } // namespace |
129 } // namespace favicon | 129 } // namespace favicon |
OLD | NEW |