| OLD | NEW |
| 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/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 PrerenderManager::kNoExperiment), | 120 PrerenderManager::kNoExperiment), |
| 121 number_of_loads_(0), | 121 number_of_loads_(0), |
| 122 expected_number_of_loads_(expected_number_of_loads), | 122 expected_number_of_loads_(expected_number_of_loads), |
| 123 expected_final_status_(expected_final_status), | 123 expected_final_status_(expected_final_status), |
| 124 new_render_view_host_(NULL), | 124 new_render_view_host_(NULL), |
| 125 was_hidden_(false), | 125 was_hidden_(false), |
| 126 was_shown_(false), | 126 was_shown_(false), |
| 127 should_be_shown_(expected_final_status == FINAL_STATUS_USED), | 127 should_be_shown_(expected_final_status == FINAL_STATUS_USED), |
| 128 quit_message_loop_on_destruction_( | 128 quit_message_loop_on_destruction_( |
| 129 expected_final_status != FINAL_STATUS_EVICTED && | 129 expected_final_status != FINAL_STATUS_EVICTED && |
| 130 expected_final_status != FINAL_STATUS_APP_TERMINATING && | 130 expected_final_status != FINAL_STATUS_APP_TERMINATING), |
| 131 expected_final_status != FINAL_STATUS_MATCH_COMPLETE_DUMMY), | |
| 132 expected_pending_prerenders_(0) { | 131 expected_pending_prerenders_(0) { |
| 133 if (expected_number_of_loads == 0) | 132 if (expected_number_of_loads == 0) |
| 134 MessageLoopForUI::current()->Quit(); | 133 MessageLoopForUI::current()->Quit(); |
| 135 } | 134 } |
| 136 | 135 |
| 137 virtual ~TestPrerenderContents() { | 136 virtual ~TestPrerenderContents() { |
| 138 EXPECT_EQ(expected_final_status_, final_status()) << | 137 EXPECT_EQ(expected_final_status_, final_status()) << |
| 139 " when testing URL " << prerender_url().path() << | 138 " when testing URL " << prerender_url().path() << |
| 140 " (Expected: " << NameFromFinalStatus(expected_final_status_) << | 139 " (Expected: " << NameFromFinalStatus(expected_final_status_) << |
| 141 ", Actual: " << NameFromFinalStatus(final_status()) << ")"; | 140 ", Actual: " << NameFromFinalStatus(final_status()) << ")"; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 } | 296 } |
| 298 | 297 |
| 299 virtual PrerenderContents* CreatePrerenderContents( | 298 virtual PrerenderContents* CreatePrerenderContents( |
| 300 PrerenderManager* prerender_manager, | 299 PrerenderManager* prerender_manager, |
| 301 PrerenderTracker* prerender_tracker, | 300 PrerenderTracker* prerender_tracker, |
| 302 Profile* profile, | 301 Profile* profile, |
| 303 const GURL& url, | 302 const GURL& url, |
| 304 const GURL& referrer, | 303 const GURL& referrer, |
| 305 Origin origin, | 304 Origin origin, |
| 306 uint8 experiment_id) OVERRIDE { | 305 uint8 experiment_id) OVERRIDE { |
| 307 FinalStatus expected_final_status = FINAL_STATUS_MATCH_COMPLETE_DUMMY; | 306 CHECK(!expected_final_status_queue_.empty()) << |
| 308 if (!expected_final_status_queue_.empty()) { | 307 "Creating prerender contents for " << url.path() << |
| 309 expected_final_status = expected_final_status_queue_.front(); | 308 " with no expected final status"; |
| 310 expected_final_status_queue_.pop_front(); | 309 FinalStatus expected_final_status = expected_final_status_queue_.front(); |
| 311 } | 310 expected_final_status_queue_.pop_front(); |
| 312 VLOG(1) << "Creating prerender contents for " << url.path() << | 311 VLOG(1) << "Creating prerender contents for " << url.path() << |
| 313 " with expected final status " << expected_final_status; | 312 " with expected final status " << expected_final_status; |
| 314 VLOG(1) << expected_final_status_queue_.size() << " left in the queue."; | 313 VLOG(1) << expected_final_status_queue_.size() << " left in the queue."; |
| 315 return new TestPrerenderContents(prerender_manager, prerender_tracker, | 314 return new TestPrerenderContents(prerender_manager, prerender_tracker, |
| 316 profile, url, | 315 profile, url, |
| 317 referrer, expected_number_of_loads_, | 316 referrer, expected_number_of_loads_, |
| 318 expected_final_status); | 317 expected_final_status); |
| 319 } | 318 } |
| 320 | 319 |
| 321 private: | 320 private: |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 // Check if page behaves as expected while in prerendered state. | 716 // Check if page behaves as expected while in prerendered state. |
| 718 bool prerender_test_result = false; | 717 bool prerender_test_result = false; |
| 719 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 718 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 720 prerender_contents->render_view_host_mutable(), L"", | 719 prerender_contents->render_view_host_mutable(), L"", |
| 721 L"window.domAutomationController.send(DidPrerenderPass())", | 720 L"window.domAutomationController.send(DidPrerenderPass())", |
| 722 &prerender_test_result)); | 721 &prerender_test_result)); |
| 723 EXPECT_TRUE(prerender_test_result); | 722 EXPECT_TRUE(prerender_test_result); |
| 724 } | 723 } |
| 725 } else { | 724 } else { |
| 726 // In the failure case, we should have removed |dest_url_| from the | 725 // In the failure case, we should have removed |dest_url_| from the |
| 727 // prerender_manager. We ignore dummy PrerenderContents (as indicated | 726 // prerender_manager. |
| 728 // by not having started). | 727 EXPECT_TRUE(prerender_contents == NULL); |
| 729 EXPECT_TRUE(prerender_contents == NULL || | |
| 730 !prerender_contents->prerendering_has_started()); | |
| 731 } | 728 } |
| 732 } | 729 } |
| 733 | 730 |
| 734 void NavigateToURLImpl(const GURL& dest_url, | 731 void NavigateToURLImpl(const GURL& dest_url, |
| 735 WindowOpenDisposition disposition) const { | 732 WindowOpenDisposition disposition) const { |
| 736 // Make sure in navigating we have a URL to use in the PrerenderManager. | 733 // Make sure in navigating we have a URL to use in the PrerenderManager. |
| 737 ASSERT_TRUE(GetPrerenderContents() != NULL); | 734 ASSERT_TRUE(GetPrerenderContents() != NULL); |
| 738 | 735 |
| 739 // If opening the page in a background tab, it won't be shown when swapped | 736 // If opening the page in a background tab, it won't be shown when swapped |
| 740 // in. | 737 // in. |
| (...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1833 DevToolsManager* manager = DevToolsManager::GetInstance(); | 1830 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 1834 FakeDevToolsClientHost client_host; | 1831 FakeDevToolsClientHost client_host; |
| 1835 manager->RegisterDevToolsClientHostFor(inspected_rvh, &client_host); | 1832 manager->RegisterDevToolsClientHostFor(inspected_rvh, &client_host); |
| 1836 const char* url = "files/prerender/prerender_page.html"; | 1833 const char* url = "files/prerender/prerender_page.html"; |
| 1837 PrerenderTestURL(url, FINAL_STATUS_DEVTOOLS_ATTACHED, 1); | 1834 PrerenderTestURL(url, FINAL_STATUS_DEVTOOLS_ATTACHED, 1); |
| 1838 NavigateToURL(url); | 1835 NavigateToURL(url); |
| 1839 } | 1836 } |
| 1840 | 1837 |
| 1841 // Validate that the sessionStorage namespace remains the same when swapping | 1838 // Validate that the sessionStorage namespace remains the same when swapping |
| 1842 // in a prerendered page. | 1839 // in a prerendered page. |
| 1843 // http://crbug.com/103563 | 1840 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSessionStorage) { |
| 1844 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderSessionStorage) { | |
| 1845 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); | 1841 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); |
| 1846 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), | 1842 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), |
| 1847 FINAL_STATUS_USED, | 1843 FINAL_STATUS_USED, |
| 1848 1); | 1844 1); |
| 1849 NavigateToDestURL(); | 1845 NavigateToDestURL(); |
| 1850 GoBackToPageBeforePrerender(browser()); | 1846 GoBackToPageBeforePrerender(browser()); |
| 1851 } | 1847 } |
| 1852 | 1848 |
| 1853 } // namespace prerender | 1849 } // namespace prerender |
| OLD | NEW |