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 <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2269 // used to compare with PrerenderClearHistory test. | 2269 // used to compare with PrerenderClearHistory test. |
| 2270 EXPECT_EQ(1, GetHistoryLength()); | 2270 EXPECT_EQ(1, GetHistoryLength()); |
| 2271 } | 2271 } |
| 2272 | 2272 |
| 2273 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { | 2273 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { |
| 2274 PrerenderTestURL("files/prerender/prerender_page.html", | 2274 PrerenderTestURL("files/prerender/prerender_page.html", |
| 2275 FINAL_STATUS_CANCELLED, | 2275 FINAL_STATUS_CANCELLED, |
| 2276 1); | 2276 1); |
| 2277 // Post a task to cancel all the prerenders. | 2277 // Post a task to cancel all the prerenders. |
| 2278 MessageLoop::current()->PostTask( | 2278 MessageLoop::current()->PostTask( |
| 2279 FROM_HERE, | 2279 FROM_HERE, base::Bind(&CancelAllPrerenders, GetPrerenderManager())); |
| 2280 base::Bind(&CancelAllPrerenders, GetPrerenderManager())); | |
| 2281 content::RunMessageLoop(); | 2280 content::RunMessageLoop(); |
| 2282 EXPECT_TRUE(GetPrerenderContents() == NULL); | 2281 EXPECT_TRUE(GetPrerenderContents() == NULL); |
| 2283 } | 2282 } |
| 2284 | 2283 |
| 2284 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderEvents) { | |
|
mmenke
2012/12/07 17:11:48
Suggest a test where the page itself cancels the p
mmenke
2012/12/07 19:12:47
That test could actually just be added to the corr
gavinp
2012/12/14 21:48:52
Done.
| |
| 2285 PrerenderTestURL("files/prerender/prerender_page.html", | |
| 2286 FINAL_STATUS_CANCELLED, 1); | |
| 2287 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | |
| 2288 bool received_prerender_started = false; | |
| 2289 bool received_prerender_stopped = false; | |
| 2290 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | |
| 2291 web_contents->GetRenderViewHost(), L"", | |
| 2292 L"window.domAutomationController.send(receivedPrerenderStartEvent)", | |
| 2293 &received_prerender_started)); | |
| 2294 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | |
| 2295 web_contents->GetRenderViewHost(), L"", | |
| 2296 L"window.domAutomationController.send(receivedPrerenderStopEvent)", | |
| 2297 &received_prerender_stopped)); | |
| 2298 ASSERT_TRUE(received_prerender_started); | |
| 2299 ASSERT_FALSE(received_prerender_stopped); | |
| 2300 | |
| 2301 MessageLoop::current()->PostTask( | |
| 2302 FROM_HERE, base::Bind(&CancelAllPrerenders, GetPrerenderManager())); | |
| 2303 content::RunMessageLoop(); | |
| 2304 | |
| 2305 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | |
| 2306 web_contents->GetRenderViewHost(), L"", | |
| 2307 L"window.domAutomationController.send(receivedPrerenderStartEvent)", | |
| 2308 &received_prerender_started)); | |
|
mmenke
2012/12/07 17:11:48
Is there a reason for this? I don't object to it,
gavinp
2012/12/14 21:48:52
Nope, none. I think some of these ASSERTs should b
| |
| 2309 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | |
| 2310 web_contents->GetRenderViewHost(), L"", | |
| 2311 L"window.domAutomationController.send(receivedPrerenderStopEvent)", | |
| 2312 &received_prerender_stopped)); | |
| 2313 ASSERT_TRUE(received_prerender_started); | |
| 2314 ASSERT_TRUE(received_prerender_stopped); | |
| 2315 } | |
| 2316 | |
| 2285 // Prerendering and history tests. | 2317 // Prerendering and history tests. |
| 2286 // The prerendered page is navigated to in several ways [navigate via | 2318 // The prerendered page is navigated to in several ways [navigate via |
| 2287 // omnibox, click on link, key-modified click to open in background tab, etc], | 2319 // omnibox, click on link, key-modified click to open in background tab, etc], |
| 2288 // followed by a navigation to another page from the prerendered page, followed | 2320 // followed by a navigation to another page from the prerendered page, followed |
| 2289 // by a back navigation. | 2321 // by a back navigation. |
| 2290 | 2322 |
| 2291 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNavigateClickGoBack) { | 2323 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNavigateClickGoBack) { |
| 2292 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 2324 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
| 2293 FINAL_STATUS_USED, | 2325 FINAL_STATUS_USED, |
| 2294 1); | 2326 1); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2517 channel_close_watcher.WatchChannel( | 2549 channel_close_watcher.WatchChannel( |
| 2518 chrome::GetActiveWebContents(browser())->GetRenderProcessHost()); | 2550 chrome::GetActiveWebContents(browser())->GetRenderProcessHost()); |
| 2519 NavigateToDestURL(); | 2551 NavigateToDestURL(); |
| 2520 channel_close_watcher.WaitForChannelClose(); | 2552 channel_close_watcher.WaitForChannelClose(); |
| 2521 | 2553 |
| 2522 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); | 2554 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
| 2523 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 2555 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 2524 } | 2556 } |
| 2525 | 2557 |
| 2526 } // namespace prerender | 2558 } // namespace prerender |
| OLD | NEW |