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 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2182 // used to compare with PrerenderClearHistory test. | 2182 // used to compare with PrerenderClearHistory test. |
2183 EXPECT_EQ(1, GetHistoryLength()); | 2183 EXPECT_EQ(1, GetHistoryLength()); |
2184 } | 2184 } |
2185 | 2185 |
2186 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { | 2186 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { |
2187 PrerenderTestURL("files/prerender/prerender_page.html", | 2187 PrerenderTestURL("files/prerender/prerender_page.html", |
2188 FINAL_STATUS_CANCELLED, | 2188 FINAL_STATUS_CANCELLED, |
2189 1); | 2189 1); |
2190 // Post a task to cancel all the prerenders. | 2190 // Post a task to cancel all the prerenders. |
2191 MessageLoop::current()->PostTask( | 2191 MessageLoop::current()->PostTask( |
2192 FROM_HERE, | 2192 FROM_HERE, base::Bind(&CancelAllPrerenders, GetPrerenderManager())); |
2193 base::Bind(&CancelAllPrerenders, GetPrerenderManager())); | |
2194 content::RunMessageLoop(); | 2193 content::RunMessageLoop(); |
2195 EXPECT_TRUE(GetPrerenderContents() == NULL); | 2194 EXPECT_TRUE(GetPrerenderContents() == NULL); |
2196 } | 2195 } |
2197 | 2196 |
| 2197 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderEvents) { |
| 2198 PrerenderTestURL("files/prerender/prerender_page.html", |
| 2199 FINAL_STATUS_CANCELLED, 1); |
| 2200 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
| 2201 bool received_prerender_started = false; |
| 2202 bool received_prerender_stopped = false; |
| 2203 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 2204 web_contents->GetRenderViewHost(), L"", |
| 2205 L"window.domAutomationController.send(receivedPrerenderStartedEvent)", |
| 2206 &received_prerender_started)); |
| 2207 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 2208 web_contents->GetRenderViewHost(), L"", |
| 2209 L"window.domAutomationController.send(receivedPrerenderStoppedEvent)", |
| 2210 &received_prerender_stopped)); |
| 2211 ASSERT_TRUE(received_prerender_started); |
| 2212 ASSERT_FALSE(received_prerender_stopped); |
| 2213 |
| 2214 MessageLoop::current()->PostTask( |
| 2215 FROM_HERE, base::Bind(&CancelAllPrerenders, GetPrerenderManager())); |
| 2216 content::RunMessageLoop(); |
| 2217 |
| 2218 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 2219 web_contents->GetRenderViewHost(), L"", |
| 2220 L"window.domAutomationController.send(receivedPrerenderStartedEvent)", |
| 2221 &received_prerender_started)); |
| 2222 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 2223 web_contents->GetRenderViewHost(), L"", |
| 2224 L"window.domAutomationController.send(receivedPrerenderStoppedEvent)", |
| 2225 &received_prerender_stopped)); |
| 2226 ASSERT_TRUE(received_prerender_started); |
| 2227 ASSERT_TRUE(received_prerender_stopped); |
| 2228 } |
| 2229 |
2198 // Prerendering and history tests. | 2230 // Prerendering and history tests. |
2199 // The prerendered page is navigated to in several ways [navigate via | 2231 // The prerendered page is navigated to in several ways [navigate via |
2200 // omnibox, click on link, key-modified click to open in background tab, etc], | 2232 // omnibox, click on link, key-modified click to open in background tab, etc], |
2201 // followed by a navigation to another page from the prerendered page, followed | 2233 // followed by a navigation to another page from the prerendered page, followed |
2202 // by a back navigation. | 2234 // by a back navigation. |
2203 | 2235 |
2204 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNavigateClickGoBack) { | 2236 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNavigateClickGoBack) { |
2205 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 2237 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
2206 FINAL_STATUS_USED, | 2238 FINAL_STATUS_USED, |
2207 1); | 2239 1); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2419 ResultCatcher catcher; | 2451 ResultCatcher catcher; |
2420 | 2452 |
2421 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 2453 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
2422 NavigateToDestURL(); | 2454 NavigateToDestURL(); |
2423 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); | 2455 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
2424 | 2456 |
2425 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 2457 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
2426 } | 2458 } |
2427 | 2459 |
2428 } // namespace prerender | 2460 } // namespace prerender |
OLD | NEW |