Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <deque> | 6 #include <deque> |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3087 favicon::FaviconDriver* favicon_driver = | 3087 favicon::FaviconDriver* favicon_driver = |
| 3088 favicon::ContentFaviconDriver::FromWebContents(GetActiveWebContents()); | 3088 favicon::ContentFaviconDriver::FromWebContents(GetActiveWebContents()); |
| 3089 if (!favicon_driver->FaviconIsValid()) { | 3089 if (!favicon_driver->FaviconIsValid()) { |
| 3090 // If the favicon has not been set yet, wait for it to be. | 3090 // If the favicon has not been set yet, wait for it to be. |
| 3091 FaviconUpdateWatcher favicon_update_watcher(GetActiveWebContents()); | 3091 FaviconUpdateWatcher favicon_update_watcher(GetActiveWebContents()); |
| 3092 favicon_update_watcher.Wait(); | 3092 favicon_update_watcher.Wait(); |
| 3093 } | 3093 } |
| 3094 EXPECT_TRUE(favicon_driver->FaviconIsValid()); | 3094 EXPECT_TRUE(favicon_driver->FaviconIsValid()); |
| 3095 } | 3095 } |
| 3096 | 3096 |
| 3097 // Checks that when prerendered page is swapped in and the referring page | |
| 3098 // neither had set an unload nor it had set a beforeunload handler, the old | |
| 3099 // WebContents would not leak. | |
|
mmenke
2016/05/04 17:54:32
nit: would - does or will
pasko
2016/05/09 13:34:59
Done.
| |
| 3100 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderOldWebContentsDeleted) { | |
| 3101 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | |
| 3102 WebContentsDestructionObserver destruction_observer(GetActiveWebContents()); | |
| 3103 NavigateToDestURL(); | |
| 3104 destruction_observer.Wait(); | |
| 3105 } | |
| 3106 | |
| 3097 // Checks that when a prerendered page is swapped in to a referring page, the | 3107 // Checks that when a prerendered page is swapped in to a referring page, the |
| 3098 // unload handlers on the referring page are executed and its WebContents is | 3108 // unload handlers on the referring page are executed and its WebContents is |
| 3099 // destroyed. | 3109 // destroyed. |
| 3100 // TODO(pasko): A similar test for BeforeUnload. See http://crbug.com/600693 | |
| 3101 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderUnload) { | 3110 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderUnload) { |
| 3102 // Matches URL in prerender_loader_with_unload.html. | 3111 // Matches URL in prerender_loader_with_unload.html. |
| 3103 const GURL unload_url("http://unload-url.test"); | 3112 const GURL unload_url("http://unload-url.test"); |
| 3104 base::FilePath empty_file = ui_test_utils::GetTestFilePath( | 3113 base::FilePath empty_file = ui_test_utils::GetTestFilePath( |
| 3105 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("empty.html"))); | 3114 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("empty.html"))); |
| 3106 RequestCounter unload_counter; | 3115 RequestCounter unload_counter; |
| 3107 BrowserThread::PostTask( | 3116 BrowserThread::PostTask( |
| 3108 BrowserThread::IO, FROM_HERE, | 3117 BrowserThread::IO, FROM_HERE, |
| 3109 base::Bind(&CreateCountingInterceptorOnIO, | 3118 base::Bind(&CreateCountingInterceptorOnIO, |
| 3110 unload_url, empty_file, unload_counter.AsWeakPtr())); | 3119 unload_url, empty_file, unload_counter.AsWeakPtr())); |
| 3111 | 3120 |
| 3112 set_loader_path("/prerender/prerender_loader_with_unload.html"); | 3121 set_loader_path("/prerender/prerender_loader_with_unload.html"); |
| 3113 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 3122 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
| 3114 WebContentsDestructionObserver destruction_observer(GetActiveWebContents()); | 3123 WebContentsDestructionObserver destruction_observer(GetActiveWebContents()); |
| 3115 NavigateToDestURL(); | 3124 NavigateToDestURL(); |
| 3116 unload_counter.WaitForCount(1); | 3125 unload_counter.WaitForCount(1); |
| 3117 destruction_observer.Wait(); | 3126 destruction_observer.Wait(); |
| 3118 } | 3127 } |
| 3119 | 3128 |
| 3129 // Checks that a beforeunload handler is executed on the referring page when a | |
| 3130 // prerendered page is swapped in. Also checks that its WebContents of the | |
|
mmenke
2016/05/04 17:54:32
nit: its -> the
pasko
2016/05/09 13:34:59
Done.
| |
| 3131 // referring page is destroyed. | |
| 3132 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderBeforeUnload) { | |
| 3133 // This URL is requested from prerender_loader_with_beforeunload.html. | |
| 3134 const GURL beforeunload_url("http://unload-url.test"); | |
| 3135 base::FilePath empty_file = ui_test_utils::GetTestFilePath( | |
| 3136 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("empty.html"))); | |
| 3137 RequestCounter request_counter; | |
| 3138 BrowserThread::PostTask( | |
| 3139 BrowserThread::IO, FROM_HERE, | |
| 3140 base::Bind(&CreateCountingInterceptorOnIO, | |
| 3141 beforeunload_url, empty_file, request_counter.AsWeakPtr())); | |
| 3142 | |
| 3143 set_loader_path("/prerender/prerender_loader_with_beforeunload.html"); | |
| 3144 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | |
| 3145 WebContentsDestructionObserver destruction_observer(GetActiveWebContents()); | |
| 3146 NavigateToDestURL(); | |
| 3147 request_counter.WaitForCount(1); | |
| 3148 destruction_observer.Wait(); | |
| 3149 } | |
| 3150 | |
| 3120 // Checks that a hanging unload on the referring page of a prerender swap does | 3151 // Checks that a hanging unload on the referring page of a prerender swap does |
| 3121 // not crash the browser on exit. | 3152 // not crash the browser on exit. |
| 3122 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHangingUnload) { | 3153 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHangingUnload) { |
| 3123 // Matches URL in prerender_loader_with_unload.html. | 3154 // Matches URL in prerender_loader_with_unload.html. |
| 3124 const GURL hang_url("http://unload-url.test"); | 3155 const GURL hang_url("http://unload-url.test"); |
| 3125 base::FilePath empty_file = ui_test_utils::GetTestFilePath( | 3156 base::FilePath empty_file = ui_test_utils::GetTestFilePath( |
| 3126 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("empty.html"))); | 3157 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("empty.html"))); |
| 3127 BrowserThread::PostTask( | 3158 BrowserThread::PostTask( |
| 3128 BrowserThread::IO, FROM_HERE, | 3159 BrowserThread::IO, FROM_HERE, |
| 3129 base::Bind(&CreateHangingFirstRequestInterceptorOnIO, | 3160 base::Bind(&CreateHangingFirstRequestInterceptorOnIO, |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4086 | 4117 |
| 4087 NavigateToDestURL(); | 4118 NavigateToDestURL(); |
| 4088 EXPECT_EQ(1U, task_manager.tasks().size()); | 4119 EXPECT_EQ(1U, task_manager.tasks().size()); |
| 4089 } | 4120 } |
| 4090 | 4121 |
| 4091 } // namespace | 4122 } // namespace |
| 4092 | 4123 |
| 4093 #endif // defined(ENABLE_TASK_MANAGER) | 4124 #endif // defined(ENABLE_TASK_MANAGER) |
| 4094 | 4125 |
| 4095 } // namespace prerender | 4126 } // namespace prerender |
| OLD | NEW |