| 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/location.h" | 7 #include "base/location.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 chrome::ExecuteCommand(browser(), IDC_RELOAD_BYPASSING_CACHE); | 255 chrome::ExecuteCommand(browser(), IDC_RELOAD_BYPASSING_CACHE); |
| 256 waiter.Wait(); | 256 waiter.Wait(); |
| 257 } | 257 } |
| 258 ASSERT_TRUE(delegate->was_requested()); | 258 ASSERT_TRUE(delegate->was_requested()); |
| 259 EXPECT_TRUE(delegate->bypassed_cache()); | 259 EXPECT_TRUE(delegate->bypassed_cache()); |
| 260 } | 260 } |
| 261 | 261 |
| 262 // Test that loading a page that contains icons only in the Web Manifest causes | 262 // Test that loading a page that contains icons only in the Web Manifest causes |
| 263 // those icons to be used. | 263 // those icons to be used. |
| 264 IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest, LoadIconFromWebManifest) { | 264 IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest, LoadIconFromWebManifest) { |
| 265 base::test::ScopedFeatureList override_features; | |
| 266 override_features.InitAndEnableFeature(favicon::kFaviconsFromWebManifest); | |
| 267 | |
| 268 ASSERT_TRUE(embedded_test_server()->Start()); | 265 ASSERT_TRUE(embedded_test_server()->Start()); |
| 269 GURL url = embedded_test_server()->GetURL("/favicon/page_with_manifest.html"); | 266 GURL url = embedded_test_server()->GetURL("/favicon/page_with_manifest.html"); |
| 270 GURL icon_url = embedded_test_server()->GetURL("/favicon/icon.png"); | 267 GURL icon_url = embedded_test_server()->GetURL("/favicon/icon.png"); |
| 271 | 268 |
| 272 std::unique_ptr<TestResourceDispatcherHostDelegate> delegate( | 269 std::unique_ptr<TestResourceDispatcherHostDelegate> delegate( |
| 273 new TestResourceDispatcherHostDelegate(icon_url)); | 270 new TestResourceDispatcherHostDelegate(icon_url)); |
| 274 content::ResourceDispatcherHost::Get()->SetDelegate(delegate.get()); | 271 content::ResourceDispatcherHost::Get()->SetDelegate(delegate.get()); |
| 275 | 272 |
| 276 PendingTaskWaiter waiter(web_contents(), this); | 273 PendingTaskWaiter waiter(web_contents(), this); |
| 277 ui_test_utils::NavigateToURLWithDisposition( | 274 ui_test_utils::NavigateToURLWithDisposition( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 289 // Test that loading a page that contains a Web Manifest without icons and a | 286 // Test that loading a page that contains a Web Manifest without icons and a |
| 290 // regular favicon in the HTML reports the icon. The regular icon is initially | 287 // regular favicon in the HTML reports the icon. The regular icon is initially |
| 291 // cached in the Favicon database. | 288 // cached in the Favicon database. |
| 292 IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest, | 289 IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest, |
| 293 LoadRegularIconDespiteWebManifestWithoutIcons) { | 290 LoadRegularIconDespiteWebManifestWithoutIcons) { |
| 294 ASSERT_TRUE(embedded_test_server()->Start()); | 291 ASSERT_TRUE(embedded_test_server()->Start()); |
| 295 GURL url = embedded_test_server()->GetURL( | 292 GURL url = embedded_test_server()->GetURL( |
| 296 "/favicon/page_with_manifest_without_icons.html"); | 293 "/favicon/page_with_manifest_without_icons.html"); |
| 297 GURL icon_url = embedded_test_server()->GetURL("/favicon/icon.png"); | 294 GURL icon_url = embedded_test_server()->GetURL("/favicon/icon.png"); |
| 298 | 295 |
| 299 // Initial visit with the feature still disabled, to populate the cache. | 296 // Initial visit with the feature disabled, to populate the cache. |
| 300 { | 297 { |
| 298 base::test::ScopedFeatureList override_features; |
| 299 override_features.InitAndDisableFeature(favicon::kFaviconsFromWebManifest); |
| 300 |
| 301 PendingTaskWaiter waiter(web_contents(), this); | 301 PendingTaskWaiter waiter(web_contents(), this); |
| 302 ui_test_utils::NavigateToURLWithDisposition( | 302 ui_test_utils::NavigateToURLWithDisposition( |
| 303 browser(), url, WindowOpenDisposition::CURRENT_TAB, | 303 browser(), url, WindowOpenDisposition::CURRENT_TAB, |
| 304 ui_test_utils::BROWSER_TEST_NONE); | 304 ui_test_utils::BROWSER_TEST_NONE); |
| 305 waiter.Wait(); | 305 waiter.Wait(); |
| 306 } | 306 } |
| 307 ASSERT_NE(nullptr, GetFaviconForPageURL(url).bitmap_data); | 307 ASSERT_NE(nullptr, GetFaviconForPageURL(url).bitmap_data); |
| 308 | 308 |
| 309 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 309 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 310 | 310 |
| 311 // Enable the feature and visit the page again. | 311 // Visit the page again now that the feature is enabled (default). |
| 312 base::test::ScopedFeatureList override_features; | |
| 313 override_features.InitAndEnableFeature(favicon::kFaviconsFromWebManifest); | |
| 314 | |
| 315 { | 312 { |
| 316 PendingTaskWaiter waiter(web_contents(), this); | 313 PendingTaskWaiter waiter(web_contents(), this); |
| 317 ui_test_utils::NavigateToURLWithDisposition( | 314 ui_test_utils::NavigateToURLWithDisposition( |
| 318 browser(), url, WindowOpenDisposition::CURRENT_TAB, | 315 browser(), url, WindowOpenDisposition::CURRENT_TAB, |
| 319 ui_test_utils::BROWSER_TEST_NONE); | 316 ui_test_utils::BROWSER_TEST_NONE); |
| 320 waiter.Wait(); | 317 waiter.Wait(); |
| 321 } | 318 } |
| 322 | 319 |
| 323 EXPECT_NE(nullptr, GetFaviconForPageURL(url).bitmap_data); | 320 EXPECT_NE(nullptr, GetFaviconForPageURL(url).bitmap_data); |
| 324 } | 321 } |
| OLD | NEW |