Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 10918189: Add PrerenderStatusEvent on Prerenders (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase to trunk, remove some unrelated fixes... Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 // used to compare with PrerenderClearHistory test. 2278 // used to compare with PrerenderClearHistory test.
2279 EXPECT_EQ(1, GetHistoryLength()); 2279 EXPECT_EQ(1, GetHistoryLength());
2280 } 2280 }
2281 2281
2282 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { 2282 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) {
2283 PrerenderTestURL("files/prerender/prerender_page.html", 2283 PrerenderTestURL("files/prerender/prerender_page.html",
2284 FINAL_STATUS_CANCELLED, 2284 FINAL_STATUS_CANCELLED,
2285 1); 2285 1);
2286 // Post a task to cancel all the prerenders. 2286 // Post a task to cancel all the prerenders.
2287 MessageLoop::current()->PostTask( 2287 MessageLoop::current()->PostTask(
2288 FROM_HERE, 2288 FROM_HERE, base::Bind(&CancelAllPrerenders, GetPrerenderManager()));
2289 base::Bind(&CancelAllPrerenders, GetPrerenderManager()));
2290 content::RunMessageLoop(); 2289 content::RunMessageLoop();
2291 EXPECT_TRUE(GetPrerenderContents() == NULL); 2290 EXPECT_TRUE(GetPrerenderContents() == NULL);
2292 } 2291 }
2293 2292
2293 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderEvents) {
2294 PrerenderTestURL("files/prerender/prerender_page.html",
2295 FINAL_STATUS_CANCELLED, 1);
2296 WebContents* web_contents = chrome::GetActiveWebContents(browser());
2297 bool received_prerender_started = false;
2298 bool received_prerender_stopped = false;
2299 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
2300 web_contents->GetRenderViewHost(), L"",
2301 L"window.domAutomationController.send(receivedPrerenderStartEvent)",
2302 &received_prerender_started));
2303 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
2304 web_contents->GetRenderViewHost(), L"",
2305 L"window.domAutomationController.send(receivedPrerenderStopEvent)",
2306 &received_prerender_stopped));
2307 ASSERT_TRUE(received_prerender_started);
2308 ASSERT_FALSE(received_prerender_stopped);
2309
2310 MessageLoop::current()->PostTask(
2311 FROM_HERE, base::Bind(&CancelAllPrerenders, GetPrerenderManager()));
2312 content::RunMessageLoop();
2313
2314 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
2315 web_contents->GetRenderViewHost(), L"",
2316 L"window.domAutomationController.send(receivedPrerenderStartEvent)",
2317 &received_prerender_started));
2318 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
2319 web_contents->GetRenderViewHost(), L"",
2320 L"window.domAutomationController.send(receivedPrerenderStopEvent)",
2321 &received_prerender_stopped));
2322 ASSERT_TRUE(received_prerender_started);
2323 ASSERT_TRUE(received_prerender_stopped);
2324 }
2325
2294 // Prerendering and history tests. 2326 // Prerendering and history tests.
2295 // The prerendered page is navigated to in several ways [navigate via 2327 // The prerendered page is navigated to in several ways [navigate via
2296 // omnibox, click on link, key-modified click to open in background tab, etc], 2328 // omnibox, click on link, key-modified click to open in background tab, etc],
2297 // followed by a navigation to another page from the prerendered page, followed 2329 // followed by a navigation to another page from the prerendered page, followed
2298 // by a back navigation. 2330 // by a back navigation.
2299 2331
2300 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNavigateClickGoBack) { 2332 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderNavigateClickGoBack) {
2301 PrerenderTestURL("files/prerender/prerender_page_with_link.html", 2333 PrerenderTestURL("files/prerender/prerender_page_with_link.html",
2302 FINAL_STATUS_USED, 2334 FINAL_STATUS_USED,
2303 1); 2335 1);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 channel_close_watcher.WatchChannel( 2552 channel_close_watcher.WatchChannel(
2521 chrome::GetActiveWebContents(browser())->GetRenderProcessHost()); 2553 chrome::GetActiveWebContents(browser())->GetRenderProcessHost());
2522 NavigateToDestURL(); 2554 NavigateToDestURL();
2523 channel_close_watcher.WaitForChannelClose(); 2555 channel_close_watcher.WaitForChannelClose();
2524 2556
2525 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); 2557 ASSERT_TRUE(IsEmptyPrerenderLinkManager());
2526 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 2558 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
2527 } 2559 }
2528 2560
2529 } // namespace prerender 2561 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698