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

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

Issue 7491096: Fix regression with back-button not working on prerendered and instant pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test page Created 9 years, 4 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 &click_prerendered_link_result)); 466 &click_prerendered_link_result));
467 EXPECT_TRUE(click_prerendered_link_result); 467 EXPECT_TRUE(click_prerendered_link_result);
468 468
469 // If the prerender contents has not been destroyed, run message loop. 469 // If the prerender contents has not been destroyed, run message loop.
470 if (GetPrerenderContents() != NULL) { 470 if (GetPrerenderContents() != NULL) {
471 prerender_contents->set_quit_message_loop_on_destruction(true); 471 prerender_contents->set_quit_message_loop_on_destruction(true);
472 ui_test_utils::RunMessageLoop(); 472 ui_test_utils::RunMessageLoop();
473 } 473 }
474 } 474 }
475 475
476 void OpenDestUrlViaClick() const {
477 // Make sure in navigating we have a URL to use in the PrerenderManager.
478 TestPrerenderContents* prerender_contents = GetPrerenderContents();
479 ASSERT_TRUE(prerender_contents != NULL);
480 prerender_contents->set_quit_message_loop_on_destruction(false);
481
482 bool click_prerendered_link_result = false;
483 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
484 browser()->GetSelectedTabContents()->render_view_host(), L"",
485 L"window.domAutomationController.send(ClickOpenLink())",
486 &click_prerendered_link_result));
487 EXPECT_TRUE(click_prerendered_link_result);
488
489 // If the prerender contents has not been destroyed, run message loop.
490 if (GetPrerenderContents() != NULL) {
491 prerender_contents->set_quit_message_loop_on_destruction(true);
492 ui_test_utils::RunMessageLoop();
493 }
494 }
495
476 // Should be const but test_server()->GetURL(...) is not const. 496 // Should be const but test_server()->GetURL(...) is not const.
477 void NavigateToURL(const std::string& dest_html_file) { 497 void NavigateToURL(const std::string& dest_html_file) {
478 GURL dest_url = test_server()->GetURL(dest_html_file); 498 GURL dest_url = test_server()->GetURL(dest_html_file);
479 NavigateToURLImpl(dest_url, CURRENT_TAB); 499 NavigateToURLImpl(dest_url, CURRENT_TAB);
480 } 500 }
481 501
482 bool UrlIsInPrerenderManager(const std::string& html_file) { 502 bool UrlIsInPrerenderManager(const std::string& html_file) {
483 GURL dest_url = test_server()->GetURL(html_file); 503 GURL dest_url = test_server()->GetURL(html_file);
484 return (prerender_manager()->FindEntry(dest_url) != NULL); 504 return (prerender_manager()->FindEntry(dest_url) != NULL);
485 } 505 }
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 FINAL_STATUS_CANCELLED, 1625 FINAL_STATUS_CANCELLED,
1606 1); 1626 1);
1607 // Post a task to cancel all the prerenders. 1627 // Post a task to cancel all the prerenders.
1608 MessageLoop::current()->PostTask(FROM_HERE, 1628 MessageLoop::current()->PostTask(FROM_HERE,
1609 NewRunnableFunction(CancelAllPrerenders, 1629 NewRunnableFunction(CancelAllPrerenders,
1610 prerender_manager())); 1630 prerender_manager()));
1611 ui_test_utils::RunMessageLoop(); 1631 ui_test_utils::RunMessageLoop();
1612 EXPECT_TRUE(GetPrerenderContents() == NULL); 1632 EXPECT_TRUE(GetPrerenderContents() == NULL);
1613 } 1633 }
1614 1634
1635 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, BackToPrerenderedPage) {
1636 PrerenderTestURL("files/prerender/prerender_page_with_link.html",
1637 FINAL_STATUS_USED,
1638 1);
1639
1640 OpenDestUrlViaClick();
1641
1642 // Click on the link in the page and wait for it to commit
1643 {
1644 ui_test_utils::WindowedNotificationObserver new_page_observer(
1645 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1646 NotificationService::AllSources());
1647 bool click_link_result = false;
1648 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1649 browser()->GetSelectedTabContents()->render_view_host(), L"",
1650 L"window.domAutomationController.send(ClickOpenLink())",
1651 &click_link_result));
1652 EXPECT_TRUE(click_link_result);
1653 new_page_observer.Wait();
1654 }
1655
1656 // Now, go back to the prerendered page.
1657 {
1658 ui_test_utils::WindowedNotificationObserver back_nav_observer(
1659 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1660 NotificationService::AllSources());
1661 browser()->GoBack(CURRENT_TAB);
1662 back_nav_observer.Wait();
mmenke 2011/08/09 14:54:03 Maybe run a script here or something, to make sure
cbentzel 2011/08/09 15:42:39 Perhaps. I tried using a title watcher but that hu
mmenke 2011/08/09 15:48:37 I was thinking of calling Javascript, but the titl
mmenke 2011/08/09 15:49:35 Oops...No they don't. That is odd.
1663 }
1664 }
1665
1615 } // namespace prerender 1666 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/prerender/prerender_loader.html » ('j') | chrome/test/data/prerender/prerender_loader.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698