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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 case FINAL_STATUS_DEVTOOLS_ATTACHED: | 150 case FINAL_STATUS_DEVTOOLS_ATTACHED: |
151 case FINAL_STATUS_PAGE_BEING_CAPTURED: | 151 case FINAL_STATUS_PAGE_BEING_CAPTURED: |
152 case FINAL_STATUS_NAVIGATION_UNCOMMITTED: | 152 case FINAL_STATUS_NAVIGATION_UNCOMMITTED: |
153 case FINAL_STATUS_WOULD_HAVE_BEEN_USED: | 153 case FINAL_STATUS_WOULD_HAVE_BEEN_USED: |
154 return false; | 154 return false; |
155 default: | 155 default: |
156 return true; | 156 return true; |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 // Convenience function to wait for a title. Handles the case when the | |
161 // WebContents already has the expected title. | |
162 void WaitForASCIITitle(WebContents* web_contents, | |
163 const char* expected_title_ascii) { | |
164 base::string16 expected_title = base::ASCIIToUTF16(expected_title_ascii); | |
165 if (web_contents->GetTitle() == expected_title) | |
166 return; | |
167 content::TitleWatcher title_watcher(web_contents, expected_title); | |
168 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | |
169 } | |
170 | |
160 // Waits for the destruction of a RenderProcessHost's IPC channel. | 171 // Waits for the destruction of a RenderProcessHost's IPC channel. |
161 // Used to make sure the PrerenderLinkManager's OnChannelClosed function has | 172 // Used to make sure the PrerenderLinkManager's OnChannelClosed function has |
162 // been called, before checking its state. | 173 // been called, before checking its state. |
163 class ChannelDestructionWatcher { | 174 class ChannelDestructionWatcher { |
164 public: | 175 public: |
165 ChannelDestructionWatcher() : channel_destroyed_(false) { | 176 ChannelDestructionWatcher() : channel_destroyed_(false) { |
166 } | 177 } |
167 | 178 |
168 ~ChannelDestructionWatcher() { | 179 ~ChannelDestructionWatcher() { |
169 } | 180 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 | 380 |
370 virtual void AddPendingPrerender( | 381 virtual void AddPendingPrerender( |
371 scoped_ptr<PendingPrerenderInfo> pending_prerender_info) OVERRIDE { | 382 scoped_ptr<PendingPrerenderInfo> pending_prerender_info) OVERRIDE { |
372 PrerenderContents::AddPendingPrerender(pending_prerender_info.Pass()); | 383 PrerenderContents::AddPendingPrerender(pending_prerender_info.Pass()); |
373 if (expected_pending_prerenders_ > 0 && | 384 if (expected_pending_prerenders_ > 0 && |
374 pending_prerender_count() == expected_pending_prerenders_) { | 385 pending_prerender_count() == expected_pending_prerenders_) { |
375 base::MessageLoop::current()->Quit(); | 386 base::MessageLoop::current()->Quit(); |
376 } | 387 } |
377 } | 388 } |
378 | 389 |
379 virtual WebContents* CreateWebContents( | |
380 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE { | |
381 WebContents* web_contents = PrerenderContents::CreateWebContents( | |
382 session_storage_namespace); | |
383 // Create a ready title watcher. (May or may not be used.) | |
384 base::string16 ready_title = base::ASCIIToUTF16(kReadyTitle); | |
385 ready_title_watcher_.reset(new content::TitleWatcher( | |
386 web_contents, ready_title)); | |
387 return web_contents; | |
388 } | |
389 | |
390 void WaitForPrerenderToHaveReadyTitle() { | |
391 base::string16 ready_title = base::ASCIIToUTF16(kReadyTitle); | |
392 ASSERT_EQ(ready_title, ready_title_watcher_->WaitAndGetTitle()); | |
393 } | |
394 | |
395 // Waits until the prerender has |expected_pending_prerenders| pending | 390 // Waits until the prerender has |expected_pending_prerenders| pending |
396 // prerenders. | 391 // prerenders. |
397 void WaitForPendingPrerenders(size_t expected_pending_prerenders) { | 392 void WaitForPendingPrerenders(size_t expected_pending_prerenders) { |
398 if (pending_prerender_count() < expected_pending_prerenders) { | 393 if (pending_prerender_count() < expected_pending_prerenders) { |
399 expected_pending_prerenders_ = expected_pending_prerenders; | 394 expected_pending_prerenders_ = expected_pending_prerenders; |
400 content::RunMessageLoop(); | 395 content::RunMessageLoop(); |
401 expected_pending_prerenders_ = 0; | 396 expected_pending_prerenders_ = 0; |
402 } | 397 } |
403 | 398 |
404 EXPECT_EQ(expected_pending_prerenders, pending_prerender_count()); | 399 EXPECT_EQ(expected_pending_prerenders, pending_prerender_count()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 // Set to true when the prerendering RenderWidget is shown, after having been | 452 // Set to true when the prerendering RenderWidget is shown, after having been |
458 // hidden. | 453 // hidden. |
459 bool was_shown_; | 454 bool was_shown_; |
460 // Expected final value of was_shown_. Defaults to true for | 455 // Expected final value of was_shown_. Defaults to true for |
461 // FINAL_STATUS_USED, and false otherwise. | 456 // FINAL_STATUS_USED, and false otherwise. |
462 bool should_be_shown_; | 457 bool should_be_shown_; |
463 | 458 |
464 // Total number of pending prerenders we're currently waiting for. Zero | 459 // Total number of pending prerenders we're currently waiting for. Zero |
465 // indicates we currently aren't waiting for any. | 460 // indicates we currently aren't waiting for any. |
466 size_t expected_pending_prerenders_; | 461 size_t expected_pending_prerenders_; |
467 | |
468 // Will wait for the title of the prerendered page to turn to "READY". | |
469 scoped_ptr<content::TitleWatcher> ready_title_watcher_; | |
470 }; | 462 }; |
471 | 463 |
472 // A handle to a TestPrerenderContents whose lifetime is under the caller's | 464 // A handle to a TestPrerenderContents whose lifetime is under the caller's |
473 // control. A PrerenderContents may be destroyed at any point. This allows | 465 // control. A PrerenderContents may be destroyed at any point. This allows |
474 // tracking the final status, etc. | 466 // tracking the final status, etc. |
475 class TestPrerender : public PrerenderContents::Observer, | 467 class TestPrerender : public PrerenderContents::Observer, |
476 public base::SupportsWeakPtr<TestPrerender> { | 468 public base::SupportsWeakPtr<TestPrerender> { |
477 public: | 469 public: |
478 TestPrerender() | 470 TestPrerender() |
479 : contents_(NULL), | 471 : contents_(NULL), |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 | 952 |
961 // Many of these tests are flaky. See http://crbug.com/249179 | 953 // Many of these tests are flaky. See http://crbug.com/249179 |
962 class PrerenderBrowserTest : virtual public InProcessBrowserTest { | 954 class PrerenderBrowserTest : virtual public InProcessBrowserTest { |
963 public: | 955 public: |
964 PrerenderBrowserTest() | 956 PrerenderBrowserTest() |
965 : autostart_test_server_(true), | 957 : autostart_test_server_(true), |
966 prerender_contents_factory_(NULL), | 958 prerender_contents_factory_(NULL), |
967 #if defined(FULL_SAFE_BROWSING) | 959 #if defined(FULL_SAFE_BROWSING) |
968 safe_browsing_factory_(new TestSafeBrowsingServiceFactory()), | 960 safe_browsing_factory_(new TestSafeBrowsingServiceFactory()), |
969 #endif | 961 #endif |
970 use_https_src_server_(false), | |
971 call_javascript_(true), | 962 call_javascript_(true), |
972 check_load_events_(true), | 963 check_load_events_(true), |
973 loader_path_("files/prerender/prerender_loader.html"), | 964 loader_path_("files/prerender/prerender_loader.html"), |
974 explicitly_set_browser_(NULL) {} | 965 explicitly_set_browser_(NULL) {} |
975 | 966 |
976 virtual ~PrerenderBrowserTest() {} | 967 virtual ~PrerenderBrowserTest() {} |
977 | 968 |
978 content::SessionStorageNamespace* GetSessionStorageNamespace() const { | 969 content::SessionStorageNamespace* GetSessionStorageNamespace() const { |
979 WebContents* web_contents = | 970 WebContents* web_contents = GetActiveWebContents(); |
980 current_browser()->tab_strip_model()->GetActiveWebContents(); | |
981 if (!web_contents) | 971 if (!web_contents) |
982 return NULL; | 972 return NULL; |
983 return web_contents->GetController().GetDefaultSessionStorageNamespace(); | 973 return web_contents->GetController().GetDefaultSessionStorageNamespace(); |
984 } | 974 } |
985 | 975 |
986 virtual void SetUp() OVERRIDE { | 976 virtual void SetUp() OVERRIDE { |
987 // TODO(danakj): The GPU Video Decoder needs real GL bindings. | 977 // TODO(danakj): The GPU Video Decoder needs real GL bindings. |
988 // crbug.com/269087 | 978 // crbug.com/269087 |
989 UseRealGLBindings(); | 979 UseRealGLBindings(); |
990 | 980 |
(...skipping 29 matching lines...) Expand all Loading... | |
1020 | 1010 |
1021 virtual void SetUpOnMainThread() OVERRIDE { | 1011 virtual void SetUpOnMainThread() OVERRIDE { |
1022 current_browser()->profile()->GetPrefs()->SetBoolean( | 1012 current_browser()->profile()->GetPrefs()->SetBoolean( |
1023 prefs::kPromptForDownload, false); | 1013 prefs::kPromptForDownload, false); |
1024 IncreasePrerenderMemory(); | 1014 IncreasePrerenderMemory(); |
1025 if (autostart_test_server_) | 1015 if (autostart_test_server_) |
1026 ASSERT_TRUE(test_server()->Start()); | 1016 ASSERT_TRUE(test_server()->Start()); |
1027 ChromeResourceDispatcherHostDelegate:: | 1017 ChromeResourceDispatcherHostDelegate:: |
1028 SetExternalProtocolHandlerDelegateForTesting( | 1018 SetExternalProtocolHandlerDelegateForTesting( |
1029 &external_protocol_handler_delegate_); | 1019 &external_protocol_handler_delegate_); |
1020 | |
1021 PrerenderManager* prerender_manager = GetPrerenderManager(); | |
1022 CHECK(prerender_manager); | |
mmenke
2014/01/21 17:16:10
optional: Think these could safely be ASSERTs, th
davidben
2014/01/21 20:17:06
Done.
| |
1023 prerender_manager->mutable_config().rate_limit_enabled = false; | |
1024 CHECK(prerender_contents_factory_ == NULL); | |
1025 prerender_contents_factory_ = new TestPrerenderContentsFactory; | |
1026 prerender_manager->SetPrerenderContentsFactory(prerender_contents_factory_); | |
1027 } | |
1028 | |
1029 // Convenience function to get the currently active WebContents in | |
1030 // current_browser(). | |
1031 WebContents* GetActiveWebContents() const { | |
1032 return current_browser()->tab_strip_model()->GetActiveWebContents(); | |
1030 } | 1033 } |
1031 | 1034 |
1032 // Overload for a single expected final status | 1035 // Overload for a single expected final status |
1033 scoped_ptr<TestPrerender> PrerenderTestURL( | 1036 scoped_ptr<TestPrerender> PrerenderTestURL( |
1034 const std::string& html_file, | 1037 const std::string& html_file, |
1035 FinalStatus expected_final_status, | 1038 FinalStatus expected_final_status, |
1036 int expected_number_of_loads) { | 1039 int expected_number_of_loads) { |
1037 return PrerenderTestURL(html_file, | 1040 GURL url = test_server()->GetURL(html_file); |
1041 return PrerenderTestURL(url, | |
1038 expected_final_status, | 1042 expected_final_status, |
1039 expected_number_of_loads, | 1043 expected_number_of_loads); |
1040 false); | |
1041 } | |
1042 | |
1043 scoped_ptr<TestPrerender> PrerenderTestURL( | |
1044 const std::string& html_file, | |
1045 FinalStatus expected_final_status, | |
1046 int expected_number_of_loads, | |
1047 bool prerender_should_wait_for_ready_title) { | |
1048 std::vector<FinalStatus> expected_final_status_queue( | |
1049 1, expected_final_status); | |
1050 std::vector<TestPrerender*> prerenders; | |
1051 PrerenderTestURL( | |
1052 html_file, | |
1053 expected_final_status_queue, | |
1054 expected_number_of_loads, | |
1055 prerender_should_wait_for_ready_title).release(&prerenders); | |
1056 CHECK_EQ(1u, prerenders.size()); | |
1057 return scoped_ptr<TestPrerender>(prerenders[0]); | |
1058 } | |
1059 | |
1060 ScopedVector<TestPrerender> PrerenderTestURL( | |
1061 const std::string& html_file, | |
1062 const std::vector<FinalStatus>& expected_final_status_queue, | |
1063 int expected_number_of_loads, | |
1064 bool prerender_should_wait_for_ready_title) { | |
1065 GURL url = test_server()->GetURL(html_file); | |
1066 return PrerenderTestURLImpl(url, url, | |
1067 expected_final_status_queue, | |
1068 expected_number_of_loads, | |
1069 prerender_should_wait_for_ready_title); | |
1070 } | 1044 } |
1071 | 1045 |
1072 ScopedVector<TestPrerender> PrerenderTestURL( | 1046 ScopedVector<TestPrerender> PrerenderTestURL( |
1073 const std::string& html_file, | 1047 const std::string& html_file, |
1074 const std::vector<FinalStatus>& expected_final_status_queue, | 1048 const std::vector<FinalStatus>& expected_final_status_queue, |
1075 int expected_number_of_loads) { | 1049 int expected_number_of_loads) { |
1076 return PrerenderTestURL(html_file, expected_final_status_queue, | 1050 GURL url = test_server()->GetURL(html_file); |
1077 expected_number_of_loads, false); | 1051 return PrerenderTestURLImpl(url, |
1052 expected_final_status_queue, | |
1053 expected_number_of_loads); | |
1078 } | 1054 } |
1079 | 1055 |
1080 scoped_ptr<TestPrerender> PrerenderTestURL( | 1056 scoped_ptr<TestPrerender> PrerenderTestURL( |
1081 const GURL& url, | 1057 const GURL& url, |
1082 FinalStatus expected_final_status, | 1058 FinalStatus expected_final_status, |
1083 int expected_number_of_loads) { | 1059 int expected_number_of_loads) { |
1084 std::vector<FinalStatus> expected_final_status_queue( | 1060 std::vector<FinalStatus> expected_final_status_queue( |
1085 1, expected_final_status); | 1061 1, expected_final_status); |
1086 std::vector<TestPrerender*> prerenders; | 1062 std::vector<TestPrerender*> prerenders; |
1087 PrerenderTestURLImpl(url, url, | 1063 PrerenderTestURLImpl(url, |
1088 expected_final_status_queue, | 1064 expected_final_status_queue, |
1089 expected_number_of_loads, | 1065 expected_number_of_loads).release(&prerenders); |
1090 false).release(&prerenders); | |
1091 CHECK_EQ(1u, prerenders.size()); | 1066 CHECK_EQ(1u, prerenders.size()); |
1092 return scoped_ptr<TestPrerender>(prerenders[0]); | 1067 return scoped_ptr<TestPrerender>(prerenders[0]); |
1093 } | 1068 } |
1094 | |
1095 scoped_ptr<TestPrerender> PrerenderTestURL( | |
1096 const GURL& prerender_url, | |
1097 const GURL& destination_url, | |
1098 FinalStatus expected_final_status, | |
1099 int expected_number_of_loads) { | |
1100 std::vector<FinalStatus> expected_final_status_queue( | |
1101 1, expected_final_status); | |
1102 std::vector<TestPrerender*> prerenders; | |
1103 PrerenderTestURLImpl(prerender_url, destination_url, | |
1104 expected_final_status_queue, | |
1105 expected_number_of_loads, | |
1106 false).release(&prerenders); | |
1107 CHECK_EQ(1u, prerenders.size()); | |
1108 return scoped_ptr<TestPrerender>(prerenders[0]); | |
1109 } | |
1110 | 1069 |
1111 void NavigateToDestURL() const { | 1070 void NavigateToDestURL() const { |
1112 NavigateToDestURLWithDisposition(CURRENT_TAB, true); | 1071 NavigateToDestURLWithDisposition(CURRENT_TAB, true); |
1113 } | 1072 } |
1114 | 1073 |
1115 // Opens the url in a new tab, with no opener. | 1074 // Opens the url in a new tab, with no opener. |
1116 void NavigateToDestURLWithDisposition( | 1075 void NavigateToDestURLWithDisposition( |
1117 WindowOpenDisposition disposition, | 1076 WindowOpenDisposition disposition, |
1118 bool expect_swap_to_succeed) const { | 1077 bool expect_swap_to_succeed) const { |
1119 NavigateToURLWithParams( | 1078 NavigateToURLWithParams( |
1120 content::OpenURLParams(dest_url_, Referrer(), disposition, | 1079 content::OpenURLParams(dest_url_, Referrer(), disposition, |
1121 content::PAGE_TRANSITION_TYPED, false), | 1080 content::PAGE_TRANSITION_TYPED, false), |
1122 expect_swap_to_succeed); | 1081 expect_swap_to_succeed); |
1123 } | 1082 } |
1124 | 1083 |
1125 void NavigateToDestUrlAndWaitForPassTitle() { | |
1126 base::string16 expected_title = base::ASCIIToUTF16(kPassTitle); | |
1127 content::TitleWatcher title_watcher( | |
1128 GetPrerenderContents()->prerender_contents(), | |
1129 expected_title); | |
1130 NavigateToDestURL(); | |
1131 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | |
1132 } | |
1133 | |
1134 void NavigateToURL(const std::string& dest_html_file) const { | 1084 void NavigateToURL(const std::string& dest_html_file) const { |
1135 NavigateToURLWithDisposition(dest_html_file, CURRENT_TAB, true); | 1085 NavigateToURLWithDisposition(dest_html_file, CURRENT_TAB, true); |
1136 } | 1086 } |
1137 | 1087 |
1138 void NavigateToURLWithDisposition(const std::string& dest_html_file, | 1088 void NavigateToURLWithDisposition(const std::string& dest_html_file, |
1139 WindowOpenDisposition disposition, | 1089 WindowOpenDisposition disposition, |
1140 bool expect_swap_to_succeed) const { | 1090 bool expect_swap_to_succeed) const { |
1141 GURL dest_url = test_server()->GetURL(dest_html_file); | 1091 GURL dest_url = test_server()->GetURL(dest_html_file); |
1142 NavigateToURLWithDisposition(dest_url, disposition, expect_swap_to_succeed); | 1092 NavigateToURLWithDisposition(dest_url, disposition, expect_swap_to_succeed); |
1143 } | 1093 } |
1144 | 1094 |
1145 void NavigateToURLWithDisposition(const GURL& dest_url, | 1095 void NavigateToURLWithDisposition(const GURL& dest_url, |
1146 WindowOpenDisposition disposition, | 1096 WindowOpenDisposition disposition, |
1147 bool expect_swap_to_succeed) const { | 1097 bool expect_swap_to_succeed) const { |
1148 NavigateToURLWithParams( | 1098 NavigateToURLWithParams( |
1149 content::OpenURLParams(dest_url, Referrer(), disposition, | 1099 content::OpenURLParams(dest_url, Referrer(), disposition, |
1150 content::PAGE_TRANSITION_TYPED, false), | 1100 content::PAGE_TRANSITION_TYPED, false), |
1151 expect_swap_to_succeed); | 1101 expect_swap_to_succeed); |
1152 } | 1102 } |
1153 | 1103 |
1154 void NavigateToURLWithParams(const content::OpenURLParams& params, | 1104 void NavigateToURLWithParams(const content::OpenURLParams& params, |
1155 bool expect_swap_to_succeed) const { | 1105 bool expect_swap_to_succeed) const { |
1156 NavigateToURLImpl(params, expect_swap_to_succeed); | 1106 NavigateToURLImpl(params, expect_swap_to_succeed); |
1157 } | 1107 } |
1158 | 1108 |
1159 void OpenDestURLViaClick() const { | 1109 void OpenDestURLViaClick() const { |
1160 OpenDestURLWithJSImpl("Click()", false); | 1110 OpenURLViaClick(dest_url_); |
1111 } | |
1112 | |
1113 void OpenURLViaClick(const GURL& url) const { | |
1114 OpenURLWithJSImpl("Click", url, false); | |
1161 } | 1115 } |
1162 | 1116 |
1163 void OpenDestURLViaClickTarget() const { | 1117 void OpenDestURLViaClickTarget() const { |
1164 OpenDestURLWithJSImpl("ClickTarget()", true); | 1118 OpenURLWithJSImpl("ClickTarget", dest_url_, true); |
1165 } | 1119 } |
1166 | 1120 |
1167 void OpenDestURLViaClickNewWindow() const { | 1121 void OpenDestURLViaClickNewWindow() const { |
1168 OpenDestURLWithJSImpl("ShiftClick()", true); | 1122 OpenURLWithJSImpl("ShiftClick", dest_url_, true); |
1169 } | 1123 } |
1170 | 1124 |
1171 void OpenDestURLViaClickNewForegroundTab() const { | 1125 void OpenDestURLViaClickNewForegroundTab() const { |
1172 #if defined(OS_MACOSX) | 1126 #if defined(OS_MACOSX) |
1173 OpenDestURLWithJSImpl("MetaShiftClick()", true); | 1127 OpenURLWithJSImpl("MetaShiftClick", dest_url_, true); |
1174 #else | 1128 #else |
1175 OpenDestURLWithJSImpl("CtrlShiftClick()", true); | 1129 OpenURLWithJSImpl("CtrlShiftClick", dest_url_, true); |
1176 #endif | 1130 #endif |
1177 } | 1131 } |
1178 | 1132 |
1179 void OpenDestURLViaClickNewBackgroundTab() const { | 1133 void OpenDestURLViaClickNewBackgroundTab() const { |
1180 TestPrerenderContents* prerender_contents = GetPrerenderContents(); | |
1181 ASSERT_TRUE(prerender_contents != NULL); | |
1182 prerender_contents->set_should_be_shown(false); | |
1183 #if defined(OS_MACOSX) | 1134 #if defined(OS_MACOSX) |
1184 OpenDestURLWithJSImpl("MetaClick()", true); | 1135 OpenURLWithJSImpl("MetaClick", dest_url_, true); |
1185 #else | 1136 #else |
1186 OpenDestURLWithJSImpl("CtrlClick()", true); | 1137 OpenURLWithJSImpl("CtrlClick", dest_url_, true); |
1187 #endif | 1138 #endif |
1188 } | 1139 } |
1189 | 1140 |
1190 void OpenDestURLViaWindowOpen() const { | 1141 void OpenDestURLViaWindowOpen() const { |
1191 OpenDestURLWithJSImpl("WindowOpen()", true); | 1142 OpenURLWithJSImpl("WindowOpen", dest_url_, true); |
1192 } | 1143 } |
1193 | 1144 |
1194 void RemoveLinkElement(int i) const { | 1145 void RemoveLinkElement(int i) const { |
1195 current_browser()->tab_strip_model()->GetActiveWebContents()-> | 1146 GetActiveWebContents()->GetRenderViewHost()->ExecuteJavascriptInWebFrame( |
1196 GetRenderViewHost()->ExecuteJavascriptInWebFrame( | |
1197 base::string16(), | 1147 base::string16(), |
1198 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); | 1148 base::ASCIIToUTF16(base::StringPrintf("RemoveLinkElement(%d)", i))); |
1199 } | 1149 } |
1200 | 1150 |
1201 void ClickToNextPageAfterPrerender() { | 1151 void ClickToNextPageAfterPrerender() { |
1202 content::WindowedNotificationObserver new_page_observer( | 1152 content::WindowedNotificationObserver new_page_observer( |
1203 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1153 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
1204 content::NotificationService::AllSources()); | 1154 content::NotificationService::AllSources()); |
1205 RenderViewHost* render_view_host = current_browser()->tab_strip_model()-> | 1155 RenderViewHost* render_view_host = |
1206 GetActiveWebContents()->GetRenderViewHost(); | 1156 GetActiveWebContents()->GetRenderViewHost(); |
1207 render_view_host->ExecuteJavascriptInWebFrame( | 1157 render_view_host->ExecuteJavascriptInWebFrame( |
1208 base::string16(), | 1158 base::string16(), |
1209 base::ASCIIToUTF16("ClickOpenLink()")); | 1159 base::ASCIIToUTF16("ClickOpenLink()")); |
1210 new_page_observer.Wait(); | 1160 new_page_observer.Wait(); |
1211 } | 1161 } |
1212 | 1162 |
1213 void NavigateToNextPageAfterPrerender() const { | 1163 void NavigateToNextPageAfterPrerender() const { |
1214 ui_test_utils::NavigateToURL( | 1164 ui_test_utils::NavigateToURL( |
1215 current_browser(), | 1165 current_browser(), |
1216 test_server()->GetURL("files/prerender/prerender_page.html")); | 1166 test_server()->GetURL("files/prerender/prerender_page.html")); |
1217 } | 1167 } |
1218 | 1168 |
1219 // Called after the prerendered page has been navigated to and then away from. | 1169 // Called after the prerendered page has been navigated to and then away from. |
1220 // Navigates back through the history to the prerendered page. | 1170 // Navigates back through the history to the prerendered page. |
1221 void GoBackToPrerender() { | 1171 void GoBackToPrerender() { |
1222 content::WindowedNotificationObserver back_nav_observer( | 1172 content::WindowedNotificationObserver back_nav_observer( |
1223 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1173 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
1224 content::NotificationService::AllSources()); | 1174 content::NotificationService::AllSources()); |
1225 chrome::GoBack(current_browser(), CURRENT_TAB); | 1175 chrome::GoBack(current_browser(), CURRENT_TAB); |
1226 back_nav_observer.Wait(); | 1176 back_nav_observer.Wait(); |
1227 bool original_prerender_page = false; | 1177 bool original_prerender_page = false; |
1228 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1178 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
1229 current_browser()->tab_strip_model()->GetActiveWebContents(), | 1179 GetActiveWebContents(), |
1230 "window.domAutomationController.send(IsOriginalPrerenderPage())", | 1180 "window.domAutomationController.send(IsOriginalPrerenderPage())", |
1231 &original_prerender_page)); | 1181 &original_prerender_page)); |
1232 EXPECT_TRUE(original_prerender_page); | 1182 EXPECT_TRUE(original_prerender_page); |
1233 } | 1183 } |
1234 | 1184 |
1235 // Goes back to the page that was active before the prerender was swapped | 1185 // Goes back to the page that was active before the prerender was swapped |
1236 // in. This must be called when the prerendered page is the current page | 1186 // in. This must be called when the prerendered page is the current page |
1237 // in the active tab. | 1187 // in the active tab. |
1238 void GoBackToPageBeforePrerender() { | 1188 void GoBackToPageBeforePrerender() { |
1239 WebContents* tab = | 1189 WebContents* tab = GetActiveWebContents(); |
1240 current_browser()->tab_strip_model()->GetActiveWebContents(); | |
1241 ASSERT_TRUE(tab); | 1190 ASSERT_TRUE(tab); |
1242 EXPECT_FALSE(tab->IsLoading()); | 1191 EXPECT_FALSE(tab->IsLoading()); |
1243 TestNavigationObserver back_nav_observer(tab); | 1192 TestNavigationObserver back_nav_observer(tab); |
1244 chrome::GoBack(current_browser(), CURRENT_TAB); | 1193 chrome::GoBack(current_browser(), CURRENT_TAB); |
1245 back_nav_observer.Wait(); | 1194 back_nav_observer.Wait(); |
1246 bool js_result; | 1195 bool js_result; |
1247 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1196 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
1248 tab, | 1197 tab, |
1249 "window.domAutomationController.send(DidBackToOriginalPagePass())", | 1198 "window.domAutomationController.send(DidBackToOriginalPagePass())", |
1250 &js_result)); | 1199 &js_result)); |
1251 EXPECT_TRUE(js_result); | 1200 EXPECT_TRUE(js_result); |
1252 } | 1201 } |
1253 | 1202 |
1254 bool UrlIsInPrerenderManager(const std::string& html_file) const { | 1203 bool UrlIsInPrerenderManager(const std::string& html_file) const { |
1255 return UrlIsInPrerenderManager(test_server()->GetURL(html_file)); | 1204 return UrlIsInPrerenderManager(test_server()->GetURL(html_file)); |
1256 } | 1205 } |
1257 | 1206 |
1258 bool UrlIsInPrerenderManager(const GURL& url) const { | 1207 bool UrlIsInPrerenderManager(const GURL& url) const { |
1259 return GetPrerenderManager()->FindPrerenderData( | 1208 return GetPrerenderManager()->FindPrerenderData( |
1260 url, GetSessionStorageNamespace()) != NULL; | 1209 url, GetSessionStorageNamespace()) != NULL; |
1261 } | 1210 } |
1262 | 1211 |
1263 void set_use_https_src(bool use_https_src_server) { | 1212 void UseHttpsSrcServer() { |
1264 use_https_src_server_ = use_https_src_server; | 1213 if (https_src_server_) |
1214 return; | |
1215 https_src_server_.reset( | |
1216 new net::SpawnedTestServer( | |
1217 net::SpawnedTestServer::TYPE_HTTPS, | |
1218 net::SpawnedTestServer::kLocalhost, | |
1219 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")))); | |
1220 CHECK(https_src_server_->Start()); | |
1265 } | 1221 } |
1266 | 1222 |
1267 void DisableJavascriptCalls() { | 1223 void DisableJavascriptCalls() { |
1268 call_javascript_ = false; | 1224 call_javascript_ = false; |
1269 } | 1225 } |
1270 | 1226 |
1271 void DisableLoadEventCheck() { | 1227 void DisableLoadEventCheck() { |
1272 check_load_events_ = false; | 1228 check_load_events_ = false; |
1273 } | 1229 } |
1274 | 1230 |
(...skipping 14 matching lines...) Expand all Loading... | |
1289 return prerender_link_manager; | 1245 return prerender_link_manager; |
1290 } | 1246 } |
1291 | 1247 |
1292 bool DidReceivePrerenderStartEventForLinkNumber(int index) const { | 1248 bool DidReceivePrerenderStartEventForLinkNumber(int index) const { |
1293 bool received_prerender_started; | 1249 bool received_prerender_started; |
1294 std::string expression = base::StringPrintf( | 1250 std::string expression = base::StringPrintf( |
1295 "window.domAutomationController.send(Boolean(" | 1251 "window.domAutomationController.send(Boolean(" |
1296 "receivedPrerenderStartEvents[%d]))", index); | 1252 "receivedPrerenderStartEvents[%d]))", index); |
1297 | 1253 |
1298 CHECK(content::ExecuteScriptAndExtractBool( | 1254 CHECK(content::ExecuteScriptAndExtractBool( |
1299 current_browser()->tab_strip_model()->GetActiveWebContents(), | 1255 GetActiveWebContents(), |
1300 expression, | 1256 expression, |
1301 &received_prerender_started)); | 1257 &received_prerender_started)); |
1302 return received_prerender_started; | 1258 return received_prerender_started; |
1303 } | 1259 } |
1304 | 1260 |
1305 int GetPrerenderLoadEventCountForLinkNumber(int index) const { | 1261 int GetPrerenderLoadEventCountForLinkNumber(int index) const { |
1306 int load_event_count; | 1262 int load_event_count; |
1307 std::string expression = base::StringPrintf( | 1263 std::string expression = base::StringPrintf( |
1308 "window.domAutomationController.send(" | 1264 "window.domAutomationController.send(" |
1309 "receivedPrerenderLoadEvents[%d] || 0)", index); | 1265 "receivedPrerenderLoadEvents[%d] || 0)", index); |
1310 | 1266 |
1311 CHECK(content::ExecuteScriptAndExtractInt( | 1267 CHECK(content::ExecuteScriptAndExtractInt( |
1312 current_browser()->tab_strip_model()->GetActiveWebContents(), | 1268 GetActiveWebContents(), |
1313 expression, | 1269 expression, |
1314 &load_event_count)); | 1270 &load_event_count)); |
1315 return load_event_count; | 1271 return load_event_count; |
1316 } | 1272 } |
1317 | 1273 |
1318 bool DidReceivePrerenderStopEventForLinkNumber(int index) const { | 1274 bool DidReceivePrerenderStopEventForLinkNumber(int index) const { |
1319 bool received_prerender_stopped; | 1275 bool received_prerender_stopped; |
1320 std::string expression = base::StringPrintf( | 1276 std::string expression = base::StringPrintf( |
1321 "window.domAutomationController.send(Boolean(" | 1277 "window.domAutomationController.send(Boolean(" |
1322 "receivedPrerenderStopEvents[%d]))", index); | 1278 "receivedPrerenderStopEvents[%d]))", index); |
1323 | 1279 |
1324 CHECK(content::ExecuteScriptAndExtractBool( | 1280 CHECK(content::ExecuteScriptAndExtractBool( |
1325 current_browser()->tab_strip_model()->GetActiveWebContents(), | 1281 GetActiveWebContents(), |
1326 expression, | 1282 expression, |
1327 &received_prerender_stopped)); | 1283 &received_prerender_stopped)); |
1328 return received_prerender_stopped; | 1284 return received_prerender_stopped; |
1329 } | 1285 } |
1330 | 1286 |
1331 bool HadPrerenderEventErrors() const { | 1287 bool HadPrerenderEventErrors() const { |
1332 bool had_prerender_event_errors; | 1288 bool had_prerender_event_errors; |
1333 CHECK(content::ExecuteScriptAndExtractBool( | 1289 CHECK(content::ExecuteScriptAndExtractBool( |
1334 current_browser()->tab_strip_model()->GetActiveWebContents(), | 1290 GetActiveWebContents(), |
1335 "window.domAutomationController.send(Boolean(" | 1291 "window.domAutomationController.send(Boolean(" |
1336 " hadPrerenderEventErrors))", | 1292 " hadPrerenderEventErrors))", |
1337 &had_prerender_event_errors)); | 1293 &had_prerender_event_errors)); |
1338 return had_prerender_event_errors; | 1294 return had_prerender_event_errors; |
1339 } | 1295 } |
1340 | 1296 |
1341 // Asserting on this can result in flaky tests. PrerenderHandles are | 1297 // Asserting on this can result in flaky tests. PrerenderHandles are |
1342 // removed from the PrerenderLinkManager when the prerender is canceled from | 1298 // removed from the PrerenderLinkManager when the prerender is canceled from |
1343 // the browser, when the prerenders are cancelled from the renderer process, | 1299 // the browser, when the prerenders are cancelled from the renderer process, |
1344 // or the channel for the renderer process is closed on the IO thread. In the | 1300 // or the channel for the renderer process is closed on the IO thread. In the |
(...skipping 24 matching lines...) Expand all Loading... | |
1369 } | 1325 } |
1370 #endif | 1326 #endif |
1371 | 1327 |
1372 TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const { | 1328 TestPrerenderContents* GetPrerenderContentsFor(const GURL& url) const { |
1373 PrerenderManager::PrerenderData* prerender_data = | 1329 PrerenderManager::PrerenderData* prerender_data = |
1374 GetPrerenderManager()->FindPrerenderData(url, NULL); | 1330 GetPrerenderManager()->FindPrerenderData(url, NULL); |
1375 return static_cast<TestPrerenderContents*>( | 1331 return static_cast<TestPrerenderContents*>( |
1376 prerender_data ? prerender_data->contents() : NULL); | 1332 prerender_data ? prerender_data->contents() : NULL); |
1377 } | 1333 } |
1378 | 1334 |
1379 TestPrerenderContents* GetPrerenderContents() const { | |
1380 return GetPrerenderContentsFor(dest_url_); | |
1381 } | |
1382 | |
1383 void set_loader_path(const std::string& path) { | 1335 void set_loader_path(const std::string& path) { |
1384 loader_path_ = path; | 1336 loader_path_ = path; |
1385 } | 1337 } |
1386 | 1338 |
1387 void set_loader_query_and_fragment(const std::string& query_and_fragment) { | 1339 void set_loader_query_and_fragment(const std::string& query_and_fragment) { |
1388 loader_query_and_fragment_ = query_and_fragment; | 1340 loader_query_and_fragment_ = query_and_fragment; |
1389 } | 1341 } |
1390 | 1342 |
1391 GURL GetCrossDomainTestUrl(const std::string& path) { | 1343 GURL GetCrossDomainTestUrl(const std::string& path) { |
1392 static const std::string secondary_domain = "www.foo.com"; | 1344 static const std::string secondary_domain = "www.foo.com"; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1436 "window.domAutomationController.send(DidDisplayPass())", | 1388 "window.domAutomationController.send(DidDisplayPass())", |
1437 &display_test_result)) | 1389 &display_test_result)) |
1438 return false; | 1390 return false; |
1439 return display_test_result; | 1391 return display_test_result; |
1440 } | 1392 } |
1441 | 1393 |
1442 protected: | 1394 protected: |
1443 bool autostart_test_server_; | 1395 bool autostart_test_server_; |
1444 | 1396 |
1445 private: | 1397 private: |
1398 // TODO(davidben): Remove this altogether so the tests don't globally assume | |
1399 // only one prerender. | |
1400 TestPrerenderContents* GetPrerenderContents() const { | |
1401 return GetPrerenderContentsFor(dest_url_); | |
1402 } | |
1403 | |
1446 ScopedVector<TestPrerender> PrerenderTestURLImpl( | 1404 ScopedVector<TestPrerender> PrerenderTestURLImpl( |
1447 const GURL& prerender_url, | 1405 const GURL& prerender_url, |
1448 const GURL& destination_url, | |
1449 const std::vector<FinalStatus>& expected_final_status_queue, | 1406 const std::vector<FinalStatus>& expected_final_status_queue, |
1450 int expected_number_of_loads, | 1407 int expected_number_of_loads) { |
1451 bool prerender_should_wait_for_ready_title) { | 1408 dest_url_ = prerender_url; |
1452 dest_url_ = destination_url; | |
1453 | 1409 |
1454 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 1410 std::vector<net::SpawnedTestServer::StringPair> replacement_text; |
1455 replacement_text.push_back( | 1411 replacement_text.push_back( |
1456 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec())); | 1412 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec())); |
1457 replacement_text.push_back( | |
1458 make_pair("REPLACE_WITH_DESTINATION_URL", destination_url.spec())); | |
1459 std::string replacement_path; | 1413 std::string replacement_path; |
1460 CHECK(net::SpawnedTestServer::GetFilePathWithReplacements( | 1414 CHECK(net::SpawnedTestServer::GetFilePathWithReplacements( |
1461 loader_path_, | 1415 loader_path_, |
1462 replacement_text, | 1416 replacement_text, |
1463 &replacement_path)); | 1417 &replacement_path)); |
1464 | 1418 |
1465 const net::SpawnedTestServer* src_server = test_server(); | 1419 const net::SpawnedTestServer* src_server = test_server(); |
1466 scoped_ptr<net::SpawnedTestServer> https_src_server; | 1420 if (https_src_server_) |
1467 if (use_https_src_server_) { | 1421 src_server = https_src_server_.get(); |
1468 https_src_server.reset( | |
1469 new net::SpawnedTestServer( | |
1470 net::SpawnedTestServer::TYPE_HTTPS, | |
1471 net::SpawnedTestServer::kLocalhost, | |
1472 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")))); | |
1473 CHECK(https_src_server->Start()); | |
1474 src_server = https_src_server.get(); | |
1475 } | |
1476 GURL loader_url = src_server->GetURL(replacement_path + | 1422 GURL loader_url = src_server->GetURL(replacement_path + |
1477 loader_query_and_fragment_); | 1423 loader_query_and_fragment_); |
1478 | 1424 |
1479 PrerenderManager* prerender_manager = GetPrerenderManager(); | |
1480 CHECK(prerender_manager); | |
1481 prerender_manager->mutable_config().rate_limit_enabled = false; | |
1482 CHECK(prerender_contents_factory_ == NULL); | |
1483 prerender_contents_factory_ = new TestPrerenderContentsFactory; | |
1484 prerender_manager->SetPrerenderContentsFactory(prerender_contents_factory_); | |
1485 | |
1486 VLOG(1) << "Running test with queue length " << | 1425 VLOG(1) << "Running test with queue length " << |
1487 expected_final_status_queue.size(); | 1426 expected_final_status_queue.size(); |
1488 CHECK(!expected_final_status_queue.empty()); | 1427 CHECK(!expected_final_status_queue.empty()); |
1489 ScopedVector<TestPrerender> prerenders; | 1428 ScopedVector<TestPrerender> prerenders; |
1490 for (size_t i = 0; i < expected_final_status_queue.size(); i++) { | 1429 for (size_t i = 0; i < expected_final_status_queue.size(); i++) { |
1491 prerenders.push_back( | 1430 prerenders.push_back( |
1492 prerender_contents_factory_->ExpectPrerenderContents( | 1431 prerender_contents_factory_->ExpectPrerenderContents( |
1493 expected_final_status_queue[i]).release()); | 1432 expected_final_status_queue[i]).release()); |
1494 } | 1433 } |
1495 | 1434 |
(...skipping 12 matching lines...) Expand all Loading... | |
1508 EXPECT_TRUE(DidReceivePrerenderStopEventForLinkNumber(0)); | 1447 EXPECT_TRUE(DidReceivePrerenderStopEventForLinkNumber(0)); |
1509 } else { | 1448 } else { |
1510 // Otherwise, check that it prerendered correctly. | 1449 // Otherwise, check that it prerendered correctly. |
1511 TestPrerenderContents* prerender_contents = prerenders[0]->contents(); | 1450 TestPrerenderContents* prerender_contents = prerenders[0]->contents(); |
1512 | 1451 |
1513 CHECK_NE(static_cast<PrerenderContents*>(NULL), prerender_contents); | 1452 CHECK_NE(static_cast<PrerenderContents*>(NULL), prerender_contents); |
1514 EXPECT_EQ(FINAL_STATUS_MAX, prerender_contents->final_status()); | 1453 EXPECT_EQ(FINAL_STATUS_MAX, prerender_contents->final_status()); |
1515 EXPECT_FALSE(DidReceivePrerenderStopEventForLinkNumber(0)); | 1454 EXPECT_FALSE(DidReceivePrerenderStopEventForLinkNumber(0)); |
1516 | 1455 |
1517 if (call_javascript_) { | 1456 if (call_javascript_) { |
1518 // Wait for the prerendered page to change title to signal it is ready | |
1519 // if required. | |
1520 if (prerender_should_wait_for_ready_title) | |
1521 prerender_contents->WaitForPrerenderToHaveReadyTitle(); | |
1522 | |
1523 // Check if page behaves as expected while in prerendered state. | 1457 // Check if page behaves as expected while in prerendered state. |
1524 EXPECT_TRUE(DidPrerenderPass(prerender_contents->prerender_contents())); | 1458 EXPECT_TRUE(DidPrerenderPass(prerender_contents->prerender_contents())); |
1525 } | 1459 } |
1526 } | 1460 } |
1527 | 1461 |
1528 // Test that the referring page received the right start and load events. | 1462 // Test that the referring page received the right start and load events. |
1529 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); | 1463 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); |
1530 if (check_load_events_) { | 1464 if (check_load_events_) { |
1531 EXPECT_EQ(expected_number_of_loads, prerenders[0]->number_of_loads()); | 1465 EXPECT_EQ(expected_number_of_loads, prerenders[0]->number_of_loads()); |
1532 EXPECT_EQ(expected_number_of_loads, | 1466 EXPECT_EQ(expected_number_of_loads, |
1533 GetPrerenderLoadEventCountForLinkNumber(0)); | 1467 GetPrerenderLoadEventCountForLinkNumber(0)); |
1534 } | 1468 } |
1535 EXPECT_FALSE(HadPrerenderEventErrors()); | 1469 EXPECT_FALSE(HadPrerenderEventErrors()); |
1536 | 1470 |
1537 return prerenders.Pass(); | 1471 return prerenders.Pass(); |
1538 } | 1472 } |
1539 | 1473 |
1540 void NavigateToURLImpl(const content::OpenURLParams& params, | 1474 void NavigateToURLImpl(const content::OpenURLParams& params, |
1541 bool expect_swap_to_succeed) const { | 1475 bool expect_swap_to_succeed) const { |
1542 ASSERT_NE(static_cast<PrerenderManager*>(NULL), GetPrerenderManager()); | 1476 ASSERT_NE(static_cast<PrerenderManager*>(NULL), GetPrerenderManager()); |
1543 // Make sure in navigating we have a URL to use in the PrerenderManager. | 1477 // Make sure in navigating we have a URL to use in the PrerenderManager. |
1544 ASSERT_NE(static_cast<PrerenderContents*>(NULL), GetPrerenderContents()); | 1478 ASSERT_NE(static_cast<PrerenderContents*>(NULL), GetPrerenderContents()); |
1545 | 1479 |
1546 // If opening the page in a background tab, it won't be shown when swapped | |
1547 // in. | |
1548 if (params.disposition == NEW_BACKGROUND_TAB) | |
1549 GetPrerenderContents()->set_should_be_shown(false); | |
1550 | |
1551 WebContents* web_contents = GetPrerenderContents()->prerender_contents(); | 1480 WebContents* web_contents = GetPrerenderContents()->prerender_contents(); |
1552 | 1481 |
1553 // Navigate and wait for either the load to finish normally or for a swap to | 1482 // Navigate and wait for either the load to finish normally or for a swap to |
1554 // occur. | 1483 // occur. |
1555 // TODO(davidben): The only handles CURRENT_TAB navigations, which is the | 1484 // TODO(davidben): The only handles CURRENT_TAB navigations, which is the |
1556 // only case tested or prerendered right now. | 1485 // only case tested or prerendered right now. |
1557 CHECK_EQ(CURRENT_TAB, params.disposition); | 1486 CHECK_EQ(CURRENT_TAB, params.disposition); |
1558 NavigationOrSwapObserver swap_observer( | 1487 NavigationOrSwapObserver swap_observer(current_browser()->tab_strip_model(), |
1559 current_browser()->tab_strip_model(), | 1488 GetActiveWebContents()); |
1560 current_browser()->tab_strip_model()->GetActiveWebContents()); | |
1561 WebContents* target_web_contents = current_browser()->OpenURL(params); | 1489 WebContents* target_web_contents = current_browser()->OpenURL(params); |
1562 swap_observer.Wait(); | 1490 swap_observer.Wait(); |
1563 | 1491 |
1564 if (web_contents && expect_swap_to_succeed) { | 1492 if (web_contents && expect_swap_to_succeed) { |
1565 EXPECT_EQ(web_contents, target_web_contents); | 1493 EXPECT_EQ(web_contents, target_web_contents); |
1566 if (call_javascript_) | 1494 if (call_javascript_) |
1567 EXPECT_TRUE(DidDisplayPass(web_contents)); | 1495 EXPECT_TRUE(DidDisplayPass(web_contents)); |
1568 } | 1496 } |
1569 } | 1497 } |
1570 | 1498 |
1571 // Opens the prerendered page using javascript functions in the loader | 1499 // Opens the prerendered page using javascript functions in the loader |
1572 // page. |javascript_function_name| should be a 0 argument function which is | 1500 // page. |javascript_function_name| should be a 0 argument function which is |
1573 // invoked. |new_web_contents| is true if the navigation is expected to | 1501 // invoked. |new_web_contents| is true if the navigation is expected to |
1574 // happen in a new WebContents via OpenURL. | 1502 // happen in a new WebContents via OpenURL. |
1575 void OpenDestURLWithJSImpl(const std::string& javascript_function_name, | 1503 void OpenURLWithJSImpl(const std::string& javascript_function_name, |
1576 bool new_web_contents) const { | 1504 const GURL& url, |
1577 TestPrerenderContents* prerender_contents = GetPrerenderContents(); | 1505 bool new_web_contents) const { |
1578 ASSERT_NE(static_cast<PrerenderContents*>(NULL), prerender_contents); | 1506 WebContents* web_contents = GetActiveWebContents(); |
1579 | 1507 RenderViewHost* render_view_host = |
1580 WebContents* web_contents = current_browser()->tab_strip_model()-> | 1508 GetActiveWebContents()->GetRenderViewHost(); |
1581 GetActiveWebContents(); | 1509 std::string javascript = base::StringPrintf( |
1582 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 1510 "%s('%s')", javascript_function_name.c_str(), url.spec().c_str()); |
1583 | 1511 |
1584 if (new_web_contents) { | 1512 if (new_web_contents) { |
1585 NewTabNavigationOrSwapObserver observer; | 1513 NewTabNavigationOrSwapObserver observer; |
1586 render_view_host->ExecuteJavascriptInWebFrame( | 1514 render_view_host->ExecuteJavascriptInWebFrame( |
1587 base::string16(), base::ASCIIToUTF16(javascript_function_name)); | 1515 base::string16(), base::ASCIIToUTF16(javascript)); |
1588 observer.Wait(); | 1516 observer.Wait(); |
1589 } else { | 1517 } else { |
1590 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(), | 1518 NavigationOrSwapObserver observer(current_browser()->tab_strip_model(), |
1591 web_contents); | 1519 web_contents); |
1592 render_view_host->ExecuteJavascriptInWebFrame( | 1520 render_view_host->ExecuteJavascriptInWebFrame( |
1593 base::string16(), base::ASCIIToUTF16(javascript_function_name)); | 1521 base::string16(), base::ASCIIToUTF16(javascript)); |
1594 observer.Wait(); | 1522 observer.Wait(); |
1595 } | 1523 } |
1596 } | 1524 } |
1597 | 1525 |
1598 TestPrerenderContentsFactory* prerender_contents_factory_; | 1526 TestPrerenderContentsFactory* prerender_contents_factory_; |
1599 #if defined(FULL_SAFE_BROWSING) | 1527 #if defined(FULL_SAFE_BROWSING) |
1600 scoped_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_; | 1528 scoped_ptr<TestSafeBrowsingServiceFactory> safe_browsing_factory_; |
1601 #endif | 1529 #endif |
1602 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_; | 1530 NeverRunsExternalProtocolHandlerDelegate external_protocol_handler_delegate_; |
1603 GURL dest_url_; | 1531 GURL dest_url_; |
1604 bool use_https_src_server_; | 1532 scoped_ptr<net::SpawnedTestServer> https_src_server_; |
1605 bool call_javascript_; | 1533 bool call_javascript_; |
1606 bool check_load_events_; | 1534 bool check_load_events_; |
1607 std::string loader_path_; | 1535 std::string loader_path_; |
1608 std::string loader_query_and_fragment_; | 1536 std::string loader_query_and_fragment_; |
1609 Browser* explicitly_set_browser_; | 1537 Browser* explicitly_set_browser_; |
1610 }; | 1538 }; |
1611 | 1539 |
1612 // Checks that a page is correctly prerendered in the case of a | 1540 // Checks that a page is correctly prerendered in the case of a |
1613 // <link rel=prerender> tag and then loaded into a tab in response to a | 1541 // <link rel=prerender> tag and then loaded into a tab in response to a |
1614 // navigation. | 1542 // navigation. |
1615 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { | 1543 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { |
1616 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 1544 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
1617 | 1545 |
1618 ChannelDestructionWatcher channel_close_watcher; | 1546 ChannelDestructionWatcher channel_close_watcher; |
1619 channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> | 1547 channel_close_watcher.WatchChannel( |
1620 GetActiveWebContents()->GetRenderProcessHost()); | 1548 GetActiveWebContents()->GetRenderProcessHost()); |
1621 NavigateToDestURL(); | 1549 NavigateToDestURL(); |
1622 channel_close_watcher.WaitForChannelClose(); | 1550 channel_close_watcher.WaitForChannelClose(); |
1623 | 1551 |
1624 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); | 1552 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
1625 } | 1553 } |
1626 | 1554 |
1627 // Checks that pending prerenders launch and receive proper event treatment. | 1555 // Checks that pending prerenders launch and receive proper event treatment. |
1628 // Disabled due to http://crbug.com/167792 | 1556 // Disabled due to http://crbug.com/167792 |
1629 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderPagePending) { | 1557 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderPagePending) { |
1630 std::vector<FinalStatus> expected_final_status_queue; | 1558 std::vector<FinalStatus> expected_final_status_queue; |
1631 expected_final_status_queue.push_back(FINAL_STATUS_USED); | 1559 expected_final_status_queue.push_back(FINAL_STATUS_USED); |
1632 expected_final_status_queue.push_back(FINAL_STATUS_USED); | 1560 expected_final_status_queue.push_back(FINAL_STATUS_USED); |
1633 PrerenderTestURL("files/prerender/prerender_page_pending.html", | 1561 PrerenderTestURL("files/prerender/prerender_page_pending.html", |
1634 expected_final_status_queue, 1); | 1562 expected_final_status_queue, 1); |
1635 | 1563 |
1636 ChannelDestructionWatcher first_channel_close_watcher; | 1564 ChannelDestructionWatcher first_channel_close_watcher; |
1637 | 1565 |
1638 first_channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> | 1566 first_channel_close_watcher.WatchChannel( |
1639 GetActiveWebContents()->GetRenderProcessHost()); | 1567 GetActiveWebContents()->GetRenderProcessHost()); |
1640 NavigateToDestURL(); | 1568 NavigateToDestURL(); |
1641 // NavigateToDestURL doesn't run a message loop. Normally that's fine, but in | 1569 // NavigateToDestURL doesn't run a message loop. Normally that's fine, but in |
1642 // this case, we need the pending prerenders to start. | 1570 // this case, we need the pending prerenders to start. |
1643 content::RunMessageLoop(); | 1571 content::RunMessageLoop(); |
1644 first_channel_close_watcher.WaitForChannelClose(); | 1572 first_channel_close_watcher.WaitForChannelClose(); |
1645 | 1573 |
1646 const GURL prerender_page_url = | 1574 const GURL prerender_page_url = |
1647 test_server()->GetURL("files/prerender/prerender_page.html"); | 1575 test_server()->GetURL("files/prerender/prerender_page.html"); |
1648 EXPECT_FALSE(IsEmptyPrerenderLinkManager()); | 1576 EXPECT_FALSE(IsEmptyPrerenderLinkManager()); |
1649 EXPECT_NE(static_cast<TestPrerenderContents*>(NULL), | 1577 EXPECT_NE(static_cast<TestPrerenderContents*>(NULL), |
1650 GetPrerenderContentsFor(prerender_page_url)); | 1578 GetPrerenderContentsFor(prerender_page_url)); |
1651 | 1579 |
1652 // Now navigate to our target page. | 1580 // Now navigate to our target page. |
1653 ChannelDestructionWatcher second_channel_close_watcher; | 1581 ChannelDestructionWatcher second_channel_close_watcher; |
1654 second_channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> | 1582 second_channel_close_watcher.WatchChannel( |
1655 GetActiveWebContents()->GetRenderProcessHost()); | 1583 GetActiveWebContents()->GetRenderProcessHost()); |
1656 ui_test_utils::NavigateToURLWithDisposition( | 1584 ui_test_utils::NavigateToURLWithDisposition( |
1657 current_browser(), prerender_page_url, CURRENT_TAB, | 1585 current_browser(), prerender_page_url, CURRENT_TAB, |
1658 ui_test_utils::BROWSER_TEST_NONE); | 1586 ui_test_utils::BROWSER_TEST_NONE); |
1659 second_channel_close_watcher.WaitForChannelClose(); | 1587 second_channel_close_watcher.WaitForChannelClose(); |
1660 | 1588 |
1661 EXPECT_TRUE(IsEmptyPrerenderLinkManager()); | 1589 EXPECT_TRUE(IsEmptyPrerenderLinkManager()); |
1662 } | 1590 } |
1663 | 1591 |
1664 // Checks that pending prerenders which are canceled before they are launched | 1592 // Checks that pending prerenders which are canceled before they are launched |
1665 // never get started. | 1593 // never get started. |
1666 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageRemovesPending) { | 1594 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageRemovesPending) { |
1667 PrerenderTestURL("files/prerender/prerender_page_removes_pending.html", | 1595 PrerenderTestURL("files/prerender/prerender_page_removes_pending.html", |
1668 FINAL_STATUS_USED, 1); | 1596 FINAL_STATUS_USED, 1); |
1669 | 1597 |
1670 ChannelDestructionWatcher channel_close_watcher; | 1598 ChannelDestructionWatcher channel_close_watcher; |
1671 channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> | 1599 channel_close_watcher.WatchChannel( |
1672 GetActiveWebContents()->GetRenderProcessHost()); | 1600 GetActiveWebContents()->GetRenderProcessHost()); |
1673 NavigateToDestURL(); | 1601 NavigateToDestURL(); |
1674 channel_close_watcher.WaitForChannelClose(); | 1602 channel_close_watcher.WaitForChannelClose(); |
1675 | 1603 |
1676 EXPECT_FALSE(DidReceivePrerenderStartEventForLinkNumber(1)); | 1604 EXPECT_FALSE(DidReceivePrerenderStartEventForLinkNumber(1)); |
1677 EXPECT_FALSE(DidReceivePrerenderStopEventForLinkNumber(1)); | 1605 EXPECT_FALSE(DidReceivePrerenderStopEventForLinkNumber(1)); |
1678 EXPECT_FALSE(HadPrerenderEventErrors()); | 1606 EXPECT_FALSE(HadPrerenderEventErrors()); |
1679 // IsEmptyPrerenderLinkManager() is not racy because the earlier DidReceive* | 1607 // IsEmptyPrerenderLinkManager() is not racy because the earlier DidReceive* |
1680 // calls did a thread/process hop to the renderer which insured pending | 1608 // calls did a thread/process hop to the renderer which insured pending |
1681 // renderer events have arrived. | 1609 // renderer events have arrived. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1758 EXPECT_FALSE(DidReceivePrerenderStopEventForLinkNumber(0)); | 1686 EXPECT_FALSE(DidReceivePrerenderStopEventForLinkNumber(0)); |
1759 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(1)); | 1687 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(1)); |
1760 EXPECT_FALSE(DidReceivePrerenderStopEventForLinkNumber(1)); | 1688 EXPECT_FALSE(DidReceivePrerenderStopEventForLinkNumber(1)); |
1761 EXPECT_FALSE(HadPrerenderEventErrors()); | 1689 EXPECT_FALSE(HadPrerenderEventErrors()); |
1762 // IsEmptyPrerenderLinkManager() is not racy because the earlier DidReceive* | 1690 // IsEmptyPrerenderLinkManager() is not racy because the earlier DidReceive* |
1763 // calls did a thread/process hop to the renderer which insured pending | 1691 // calls did a thread/process hop to the renderer which insured pending |
1764 // renderer events have arrived. | 1692 // renderer events have arrived. |
1765 EXPECT_FALSE(IsEmptyPrerenderLinkManager()); | 1693 EXPECT_FALSE(IsEmptyPrerenderLinkManager()); |
1766 | 1694 |
1767 ChannelDestructionWatcher channel_close_watcher; | 1695 ChannelDestructionWatcher channel_close_watcher; |
1768 channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> | 1696 channel_close_watcher.WatchChannel( |
1769 GetActiveWebContents()->GetRenderProcessHost()); | 1697 GetActiveWebContents()->GetRenderProcessHost()); |
1770 NavigateToDestURL(); | 1698 NavigateToDestURL(); |
1771 channel_close_watcher.WaitForChannelClose(); | 1699 channel_close_watcher.WaitForChannelClose(); |
1772 | 1700 |
1773 EXPECT_TRUE(IsEmptyPrerenderLinkManager()); | 1701 EXPECT_TRUE(IsEmptyPrerenderLinkManager()); |
1774 } | 1702 } |
1775 | 1703 |
1776 // Checks that prerendering works in incognito mode. | |
1777 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderIncognito) { | |
1778 Profile* normal_profile = current_browser()->profile(); | |
1779 set_browser( | |
1780 ui_test_utils::OpenURLOffTheRecord(normal_profile, GURL("about:blank"))); | |
1781 // Increase memory expectations on the incognito PrerenderManager. | |
1782 IncreasePrerenderMemory(); | |
1783 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | |
1784 NavigateToDestURL(); | |
1785 } | |
1786 | |
1787 // Checks that the visibility API works. | 1704 // Checks that the visibility API works. |
1788 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1705 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
1789 DISABLED_PrerenderVisibility) { | 1706 DISABLED_PrerenderVisibility) { |
1790 PrerenderTestURL("files/prerender/prerender_visibility.html", | 1707 PrerenderTestURL("files/prerender/prerender_visibility.html", |
1791 FINAL_STATUS_USED, | 1708 FINAL_STATUS_USED, |
1792 1); | 1709 1); |
1793 NavigateToDestURL(); | 1710 NavigateToDestURL(); |
1794 } | 1711 } |
1795 | 1712 |
1796 // Checks that the prerendering of a page is canceled correctly if we try to | 1713 // Checks that the prerendering of a page is canceled correctly if we try to |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1901 NavigateToDestURL(); | 1818 NavigateToDestURL(); |
1902 | 1819 |
1903 | 1820 |
1904 // Run this check again. When we try to load aa ppapi plugin, the | 1821 // Run this check again. When we try to load aa ppapi plugin, the |
1905 // "loadstart" event is asynchronously posted to a message loop. | 1822 // "loadstart" event is asynchronously posted to a message loop. |
1906 // It's possible that earlier call could have been run before the | 1823 // It's possible that earlier call could have been run before the |
1907 // the "loadstart" event was posted. | 1824 // the "loadstart" event was posted. |
1908 // TODO(mmenke): While this should reliably fail on regressions, the | 1825 // TODO(mmenke): While this should reliably fail on regressions, the |
1909 // reliability depends on the specifics of ppapi plugin | 1826 // reliability depends on the specifics of ppapi plugin |
1910 // loading. It would be great if we could avoid that. | 1827 // loading. It would be great if we could avoid that. |
1911 WebContents* web_contents = | 1828 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); |
1912 browser()->tab_strip_model()->GetActiveWebContents(); | |
1913 EXPECT_TRUE(DidDisplayPass(web_contents)); | |
1914 } | 1829 } |
1915 | 1830 |
1916 // Checks that plugins in an iframe are not loaded while a page is | 1831 // Checks that plugins in an iframe are not loaded while a page is |
1917 // being preloaded, but are loaded when the page is displayed. | 1832 // being preloaded, but are loaded when the page is displayed. |
1918 #if defined(USE_AURA) && !defined(OS_WIN) | 1833 #if defined(USE_AURA) && !defined(OS_WIN) |
1919 // http://crbug.com/103496 | 1834 // http://crbug.com/103496 |
1920 #define MAYBE_PrerenderIframeDelayLoadPlugin \ | 1835 #define MAYBE_PrerenderIframeDelayLoadPlugin \ |
1921 DISABLED_PrerenderIframeDelayLoadPlugin | 1836 DISABLED_PrerenderIframeDelayLoadPlugin |
1922 #elif defined(OS_MACOSX) | 1837 #elif defined(OS_MACOSX) |
1923 // http://crbug.com/100514 | 1838 // http://crbug.com/100514 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1991 | 1906 |
1992 // Checks that client-issued redirects work with prerendering. | 1907 // Checks that client-issued redirects work with prerendering. |
1993 // This version navigates to the final destination page, rather than the | 1908 // This version navigates to the final destination page, rather than the |
1994 // page which does the redirection via a mouse click. | 1909 // page which does the redirection via a mouse click. |
1995 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 1910 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
1996 DISABLED_PrerenderClientRedirectNavigateToSecondViaClick) { | 1911 DISABLED_PrerenderClientRedirectNavigateToSecondViaClick) { |
1997 GURL prerender_url = test_server()->GetURL( | 1912 GURL prerender_url = test_server()->GetURL( |
1998 CreateClientRedirect("files/prerender/prerender_page.html")); | 1913 CreateClientRedirect("files/prerender/prerender_page.html")); |
1999 GURL destination_url = test_server()->GetURL( | 1914 GURL destination_url = test_server()->GetURL( |
2000 "files/prerender/prerender_page.html"); | 1915 "files/prerender/prerender_page.html"); |
2001 PrerenderTestURL(prerender_url, destination_url, FINAL_STATUS_USED, 2); | 1916 PrerenderTestURL(prerender_url, FINAL_STATUS_USED, 2); |
2002 OpenDestURLViaClick(); | 1917 OpenURLViaClick(destination_url); |
2003 } | 1918 } |
2004 | 1919 |
2005 // Checks that a prerender for an https will prevent a prerender from happening. | 1920 // Checks that a prerender for an https will prevent a prerender from happening. |
2006 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHttps) { | 1921 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHttps) { |
2007 net::SpawnedTestServer https_server( | 1922 net::SpawnedTestServer https_server( |
2008 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, | 1923 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, |
2009 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 1924 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
2010 ASSERT_TRUE(https_server.Start()); | 1925 ASSERT_TRUE(https_server.Start()); |
2011 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html"); | 1926 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html"); |
2012 PrerenderTestURL(https_url, | 1927 PrerenderTestURL(https_url, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2097 | 2012 |
2098 // Checks that server-issued redirects work with prerendering. | 2013 // Checks that server-issued redirects work with prerendering. |
2099 // This version navigates to the final destination page, rather than the | 2014 // This version navigates to the final destination page, rather than the |
2100 // page which does the redirection via a mouse click. | 2015 // page which does the redirection via a mouse click. |
2101 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2016 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2102 PrerenderServerRedirectNavigateToSecondViaClick) { | 2017 PrerenderServerRedirectNavigateToSecondViaClick) { |
2103 GURL prerender_url = test_server()->GetURL( | 2018 GURL prerender_url = test_server()->GetURL( |
2104 CreateServerRedirect("files/prerender/prerender_page.html")); | 2019 CreateServerRedirect("files/prerender/prerender_page.html")); |
2105 GURL destination_url = test_server()->GetURL( | 2020 GURL destination_url = test_server()->GetURL( |
2106 "files/prerender/prerender_page.html"); | 2021 "files/prerender/prerender_page.html"); |
2107 PrerenderTestURL(prerender_url, destination_url, FINAL_STATUS_USED, 1); | 2022 PrerenderTestURL(prerender_url, FINAL_STATUS_USED, 1); |
2108 OpenDestURLViaClick(); | 2023 OpenURLViaClick(destination_url); |
2109 } | 2024 } |
2110 | 2025 |
2111 // Checks that server-issued redirects from an http to an https | 2026 // Checks that server-issued redirects from an http to an https |
2112 // location will cancel prerendering. | 2027 // location will cancel prerendering. |
2113 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2028 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2114 PrerenderServerRedirectToHttps) { | 2029 PrerenderServerRedirectToHttps) { |
2115 net::SpawnedTestServer https_server( | 2030 net::SpawnedTestServer https_server( |
2116 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, | 2031 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, |
2117 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 2032 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
2118 ASSERT_TRUE(https_server.Start()); | 2033 ASSERT_TRUE(https_server.Start()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2196 PrerenderTestURL("files/prerender/prerender_referrer.html", | 2111 PrerenderTestURL("files/prerender/prerender_referrer.html", |
2197 FINAL_STATUS_USED, | 2112 FINAL_STATUS_USED, |
2198 1); | 2113 1); |
2199 NavigateToDestURL(); | 2114 NavigateToDestURL(); |
2200 } | 2115 } |
2201 | 2116 |
2202 // Checks that the referrer is not set when prerendering and the source page is | 2117 // Checks that the referrer is not set when prerendering and the source page is |
2203 // HTTPS. | 2118 // HTTPS. |
2204 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2119 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2205 PrerenderNoSSLReferrer) { | 2120 PrerenderNoSSLReferrer) { |
2206 set_use_https_src(true); | 2121 UseHttpsSrcServer(); |
2207 PrerenderTestURL("files/prerender/prerender_no_referrer.html", | 2122 PrerenderTestURL("files/prerender/prerender_no_referrer.html", |
2208 FINAL_STATUS_USED, | 2123 FINAL_STATUS_USED, |
2209 1); | 2124 1); |
2210 NavigateToDestURL(); | 2125 NavigateToDestURL(); |
2211 } | 2126 } |
2212 | 2127 |
2213 // Checks that the referrer is set when prerendering is cancelled. | 2128 // Checks that the referrer is set when prerendering is cancelled. |
2214 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelReferrer) { | 2129 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelReferrer) { |
2215 scoped_ptr<TestContentBrowserClient> test_content_browser_client( | 2130 scoped_ptr<TestContentBrowserClient> test_content_browser_client( |
2216 new TestContentBrowserClient); | 2131 new TestContentBrowserClient); |
2217 content::ContentBrowserClient* original_browser_client = | 2132 content::ContentBrowserClient* original_browser_client = |
2218 content::SetBrowserClientForTesting(test_content_browser_client.get()); | 2133 content::SetBrowserClientForTesting(test_content_browser_client.get()); |
2219 | 2134 |
2220 PrerenderTestURL("files/prerender/prerender_referrer.html", | 2135 PrerenderTestURL("files/prerender/prerender_referrer.html", |
2221 FINAL_STATUS_CANCELLED, | 2136 FINAL_STATUS_CANCELLED, |
2222 1); | 2137 1); |
2223 OpenDestURLViaClick(); | 2138 OpenDestURLViaClick(); |
2224 | 2139 |
2225 bool display_test_result = false; | 2140 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); |
2226 WebContents* web_contents = | |
2227 browser()->tab_strip_model()->GetActiveWebContents(); | |
2228 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
2229 web_contents, | |
2230 "window.domAutomationController.send(DidDisplayPass())", | |
2231 &display_test_result)); | |
2232 EXPECT_TRUE(display_test_result); | |
2233 | 2141 |
2234 content::SetBrowserClientForTesting(original_browser_client); | 2142 content::SetBrowserClientForTesting(original_browser_client); |
2235 } | 2143 } |
2236 | 2144 |
2237 // Checks that popups on a prerendered page cause cancellation. | 2145 // Checks that popups on a prerendered page cause cancellation. |
2238 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { | 2146 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPopup) { |
2239 PrerenderTestURL("files/prerender/prerender_popup.html", | 2147 PrerenderTestURL("files/prerender/prerender_popup.html", |
2240 FINAL_STATUS_CREATE_NEW_WINDOW, | 2148 FINAL_STATUS_CREATE_NEW_WINDOW, |
2241 0); | 2149 0); |
2242 } | 2150 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2274 // TODO(gavinp,sreeram): Fix http://crbug.com/145248 and deflake this test. | 2182 // TODO(gavinp,sreeram): Fix http://crbug.com/145248 and deflake this test. |
2275 // Checks that we don't prerender in an infinite loop. | 2183 // Checks that we don't prerender in an infinite loop. |
2276 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderInfiniteLoop) { | 2184 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderInfiniteLoop) { |
2277 const char* const kHtmlFileA = "files/prerender/prerender_infinite_a.html"; | 2185 const char* const kHtmlFileA = "files/prerender/prerender_infinite_a.html"; |
2278 const char* const kHtmlFileB = "files/prerender/prerender_infinite_b.html"; | 2186 const char* const kHtmlFileB = "files/prerender/prerender_infinite_b.html"; |
2279 | 2187 |
2280 std::vector<FinalStatus> expected_final_status_queue; | 2188 std::vector<FinalStatus> expected_final_status_queue; |
2281 expected_final_status_queue.push_back(FINAL_STATUS_USED); | 2189 expected_final_status_queue.push_back(FINAL_STATUS_USED); |
2282 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); | 2190 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); |
2283 | 2191 |
2284 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); | 2192 ScopedVector<TestPrerender> prerenders = |
2285 ASSERT_TRUE(GetPrerenderContents()); | 2193 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); |
2286 GetPrerenderContents()->WaitForPendingPrerenders(1u); | 2194 ASSERT_TRUE(prerenders[0]->contents()); |
2195 prerenders[0]->contents()->WaitForPendingPrerenders(1u); | |
2287 | 2196 |
2288 // Next url should be in pending list but not an active entry. | 2197 // Next url should be in pending list but not an active entry. |
2289 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); | 2198 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); |
2290 | 2199 |
2291 NavigateToDestURL(); | 2200 NavigateToDestURL(); |
2292 | 2201 |
2293 // Make sure the PrerenderContents for the next url is now in the manager | 2202 // Make sure the PrerenderContents for the next url is now in the manager |
2294 // and not pending. | 2203 // and not pending. |
2295 EXPECT_TRUE(UrlIsInPrerenderManager(kHtmlFileB)); | 2204 EXPECT_TRUE(UrlIsInPrerenderManager(kHtmlFileB)); |
2296 } | 2205 } |
(...skipping 13 matching lines...) Expand all Loading... | |
2310 // This test is conceptually simplest if concurrency is at two, since we | 2219 // This test is conceptually simplest if concurrency is at two, since we |
2311 // don't have to worry about which of kHtmlFileB or kHtmlFileC gets evicted. | 2220 // don't have to worry about which of kHtmlFileB or kHtmlFileC gets evicted. |
2312 GetPrerenderManager()->mutable_config().max_link_concurrency = 2; | 2221 GetPrerenderManager()->mutable_config().max_link_concurrency = 2; |
2313 GetPrerenderManager()->mutable_config().max_link_concurrency_per_launcher = 2; | 2222 GetPrerenderManager()->mutable_config().max_link_concurrency_per_launcher = 2; |
2314 | 2223 |
2315 std::vector<FinalStatus> expected_final_status_queue; | 2224 std::vector<FinalStatus> expected_final_status_queue; |
2316 expected_final_status_queue.push_back(FINAL_STATUS_USED); | 2225 expected_final_status_queue.push_back(FINAL_STATUS_USED); |
2317 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); | 2226 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); |
2318 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); | 2227 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); |
2319 | 2228 |
2320 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); | 2229 ScopedVector<TestPrerender> prerenders = |
2321 ASSERT_TRUE(GetPrerenderContents()); | 2230 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); |
2322 GetPrerenderContents()->WaitForPendingPrerenders(2u); | 2231 ASSERT_TRUE(prerenders[0]->contents()); |
2232 prerenders[0]->contents()->WaitForPendingPrerenders(2u); | |
2323 | 2233 |
2324 // Next url should be in pending list but not an active entry. | 2234 // Next url should be in pending list but not an active entry. |
2325 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); | 2235 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); |
2326 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileC)); | 2236 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileC)); |
2327 | 2237 |
2328 NavigateToDestURL(); | 2238 NavigateToDestURL(); |
2329 | 2239 |
2330 // Make sure the PrerenderContents for the next urls are now in the manager | 2240 // Make sure the PrerenderContents for the next urls are now in the manager |
2331 // and not pending. One and only one of the URLs (the last seen) should be the | 2241 // and not pending. One and only one of the URLs (the last seen) should be the |
2332 // active entry. | 2242 // active entry. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2397 // We may have deleted the prerender tab, but the swapped in tab should be | 2307 // We may have deleted the prerender tab, but the swapped in tab should be |
2398 // active. | 2308 // active. |
2399 EXPECT_GE(num_tabs_with_prerender_page_title, 1); | 2309 EXPECT_GE(num_tabs_with_prerender_page_title, 1); |
2400 EXPECT_LE(num_tabs_with_prerender_page_title, 2); | 2310 EXPECT_LE(num_tabs_with_prerender_page_title, 2); |
2401 } | 2311 } |
2402 | 2312 |
2403 // Checks that audio loads are deferred on prerendering. | 2313 // Checks that audio loads are deferred on prerendering. |
2404 // Times out under AddressSanitizer, see http://crbug.com/108402 | 2314 // Times out under AddressSanitizer, see http://crbug.com/108402 |
2405 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderHTML5Audio) { | 2315 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderHTML5Audio) { |
2406 PrerenderTestURL("files/prerender/prerender_html5_audio.html", | 2316 PrerenderTestURL("files/prerender/prerender_html5_audio.html", |
2407 FINAL_STATUS_USED, | 2317 FINAL_STATUS_USED, |
2408 1); | 2318 1); |
2409 NavigateToDestUrlAndWaitForPassTitle(); | 2319 NavigateToDestURL(); |
2320 WaitForASCIITitle(GetActiveWebContents(), kPassTitle); | |
2410 } | 2321 } |
2411 | 2322 |
2412 // Checks that audio loads are deferred on prerendering and played back when | 2323 // Checks that audio loads are deferred on prerendering and played back when |
2413 // the prerender is swapped in if autoplay is set. | 2324 // the prerender is swapped in if autoplay is set. |
2414 // Periodically fails on chrome-os. See http://crbug.com/145263 | 2325 // Periodically fails on chrome-os. See http://crbug.com/145263 |
2415 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2326 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2416 DISABLED_PrerenderHTML5AudioAutoplay) { | 2327 DISABLED_PrerenderHTML5AudioAutoplay) { |
2417 PrerenderTestURL("files/prerender/prerender_html5_audio_autoplay.html", | 2328 PrerenderTestURL("files/prerender/prerender_html5_audio_autoplay.html", |
2418 FINAL_STATUS_USED, | 2329 FINAL_STATUS_USED, |
2419 1); | 2330 1); |
2420 NavigateToDestUrlAndWaitForPassTitle(); | 2331 NavigateToDestURL(); |
2332 WaitForASCIITitle(GetActiveWebContents(), kPassTitle); | |
2421 } | 2333 } |
2422 | 2334 |
2423 // Checks that audio loads are deferred on prerendering and played back when | 2335 // Checks that audio loads are deferred on prerendering and played back when |
2424 // the prerender is swapped in if js starts playing. | 2336 // the prerender is swapped in if js starts playing. |
2425 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2337 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2426 DISABLED_PrerenderHTML5AudioJsplay) { | 2338 DISABLED_PrerenderHTML5AudioJsplay) { |
2427 PrerenderTestURL("files/prerender/prerender_html5_audio_jsplay.html", | 2339 PrerenderTestURL("files/prerender/prerender_html5_audio_jsplay.html", |
2428 FINAL_STATUS_USED, | 2340 FINAL_STATUS_USED, |
2429 1); | 2341 1); |
2430 NavigateToDestUrlAndWaitForPassTitle(); | 2342 NavigateToDestURL(); |
2343 WaitForASCIITitle(GetActiveWebContents(), kPassTitle); | |
2431 } | 2344 } |
2432 | 2345 |
2433 // Checks that video loads are deferred on prerendering. | 2346 // Checks that video loads are deferred on prerendering. |
2434 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderHTML5Video) { | 2347 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderHTML5Video) { |
2435 PrerenderTestURL("files/prerender/prerender_html5_video.html", | 2348 PrerenderTestURL("files/prerender/prerender_html5_video.html", |
2436 FINAL_STATUS_USED, | 2349 FINAL_STATUS_USED, |
2437 1); | 2350 1); |
2438 NavigateToDestUrlAndWaitForPassTitle(); | 2351 NavigateToDestURL(); |
2352 WaitForASCIITitle(GetActiveWebContents(), kPassTitle); | |
2439 } | 2353 } |
2440 | 2354 |
2441 // Checks that video tags inserted by javascript are deferred and played | 2355 // Checks that video tags inserted by javascript are deferred and played |
2442 // correctly on swap in. | 2356 // correctly on swap in. |
2443 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2357 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2444 DISABLED_PrerenderHTML5VideoJs) { | 2358 DISABLED_PrerenderHTML5VideoJs) { |
2445 PrerenderTestURL("files/prerender/prerender_html5_video_script.html", | 2359 PrerenderTestURL("files/prerender/prerender_html5_video_script.html", |
2446 FINAL_STATUS_USED, | 2360 FINAL_STATUS_USED, |
2447 1); | 2361 1); |
2448 NavigateToDestUrlAndWaitForPassTitle(); | 2362 NavigateToDestURL(); |
2363 WaitForASCIITitle(GetActiveWebContents(), kPassTitle); | |
2449 } | 2364 } |
2450 | 2365 |
2451 // Checks for correct network events by using a busy sleep the javascript. | 2366 // Checks for correct network events by using a busy sleep the javascript. |
2452 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2367 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2453 DISABLED_PrerenderHTML5VideoNetwork) { | 2368 DISABLED_PrerenderHTML5VideoNetwork) { |
2454 PrerenderTestURL("files/prerender/prerender_html5_video_network.html", | 2369 DisableJavascriptCalls(); |
2455 FINAL_STATUS_USED, | 2370 scoped_ptr<TestPrerender> prerender = |
2456 1, | 2371 PrerenderTestURL("files/prerender/prerender_html5_video_network.html", |
2457 true); | 2372 FINAL_STATUS_USED, |
2458 NavigateToDestUrlAndWaitForPassTitle(); | 2373 1); |
2374 WaitForASCIITitle(prerender->contents()->prerender_contents(), kReadyTitle); | |
2375 EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents())); | |
2376 NavigateToDestURL(); | |
2377 WaitForASCIITitle(GetActiveWebContents(), kPassTitle); | |
2459 } | 2378 } |
2460 | 2379 |
2461 // Checks that scripts can retrieve the correct window size while prerendering. | 2380 // Checks that scripts can retrieve the correct window size while prerendering. |
2462 #if defined(TOOLKIT_VIEWS) | 2381 #if defined(TOOLKIT_VIEWS) |
2463 // TODO(beng): Widget hierarchy split causes this to fail http://crbug.com/82363 | 2382 // TODO(beng): Widget hierarchy split causes this to fail http://crbug.com/82363 |
2464 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderWindowSize) { | 2383 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderWindowSize) { |
2465 #else | 2384 #else |
2466 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowSize) { | 2385 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowSize) { |
2467 #endif | 2386 #endif |
2468 PrerenderTestURL("files/prerender/prerender_size.html", | 2387 PrerenderTestURL("files/prerender/prerender_size.html", |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2946 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) { | 2865 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) { |
2947 PrerenderTestURL("files/prerender/prerender_localstorage_write.html", | 2866 PrerenderTestURL("files/prerender/prerender_localstorage_write.html", |
2948 FINAL_STATUS_USED, | 2867 FINAL_STATUS_USED, |
2949 1); | 2868 1); |
2950 NavigateToDestURL(); | 2869 NavigateToDestURL(); |
2951 } | 2870 } |
2952 | 2871 |
2953 // Checks that the favicon is properly loaded on prerender. | 2872 // Checks that the favicon is properly loaded on prerender. |
2954 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2873 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
2955 DISABLED_PrerenderFavicon) { | 2874 DISABLED_PrerenderFavicon) { |
2956 PrerenderTestURL("files/prerender/prerender_favicon.html", | 2875 scoped_ptr<TestPrerender> prerender = |
2957 FINAL_STATUS_USED, | 2876 PrerenderTestURL("files/prerender/prerender_favicon.html", |
2958 1); | 2877 FINAL_STATUS_USED, |
2959 TestPrerenderContents* prerender_contents = GetPrerenderContents(); | 2878 1); |
2960 ASSERT_TRUE(prerender_contents != NULL); | 2879 ASSERT_TRUE(prerender->contents()); |
2961 content::WindowedNotificationObserver favicon_update_watcher( | 2880 content::WindowedNotificationObserver favicon_update_watcher( |
2962 chrome::NOTIFICATION_FAVICON_UPDATED, | 2881 chrome::NOTIFICATION_FAVICON_UPDATED, |
2963 content::Source<WebContents>(prerender_contents->prerender_contents())); | 2882 content::Source<WebContents>( |
2883 prerender->contents()->prerender_contents())); | |
2964 NavigateToDestURL(); | 2884 NavigateToDestURL(); |
2965 favicon_update_watcher.Wait(); | 2885 favicon_update_watcher.Wait(); |
2966 } | 2886 } |
2967 | 2887 |
2968 // Checks that when a prerendered page is swapped in to a referring page, the | 2888 // Checks that when a prerendered page is swapped in to a referring page, the |
2969 // unload handlers on the referring page are executed. | 2889 // unload handlers on the referring page are executed. |
2970 // Fails about 50% on CrOS, 5-10% on linux, win, mac. http://crbug.com/128986 | 2890 // Fails about 50% on CrOS, 5-10% on linux, win, mac. http://crbug.com/128986 |
2971 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderUnload) { | 2891 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderUnload) { |
2972 set_loader_path("files/prerender/prerender_loader_with_unload.html"); | 2892 set_loader_path("files/prerender/prerender_loader_with_unload.html"); |
2973 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 2893 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3018 | 2938 |
3019 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { | 2939 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelAll) { |
3020 scoped_ptr<TestPrerender> prerender = | 2940 scoped_ptr<TestPrerender> prerender = |
3021 PrerenderTestURL("files/prerender/prerender_page.html", | 2941 PrerenderTestURL("files/prerender/prerender_page.html", |
3022 FINAL_STATUS_CANCELLED, | 2942 FINAL_STATUS_CANCELLED, |
3023 1); | 2943 1); |
3024 | 2944 |
3025 GetPrerenderManager()->CancelAllPrerenders(); | 2945 GetPrerenderManager()->CancelAllPrerenders(); |
3026 prerender->WaitForStop(); | 2946 prerender->WaitForStop(); |
3027 | 2947 |
3028 EXPECT_TRUE(GetPrerenderContents() == NULL); | 2948 EXPECT_FALSE(prerender->contents()); |
3029 } | 2949 } |
3030 | 2950 |
3031 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderEvents) { | 2951 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderEvents) { |
3032 scoped_ptr<TestPrerender> prerender = | 2952 scoped_ptr<TestPrerender> prerender = |
3033 PrerenderTestURL("files/prerender/prerender_page.html", | 2953 PrerenderTestURL("files/prerender/prerender_page.html", |
3034 FINAL_STATUS_CANCELLED, 1); | 2954 FINAL_STATUS_CANCELLED, 1); |
3035 | 2955 |
3036 GetPrerenderManager()->CancelAllPrerenders(); | 2956 GetPrerenderManager()->CancelAllPrerenders(); |
3037 prerender->WaitForStop(); | 2957 prerender->WaitForStop(); |
3038 | 2958 |
3039 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); | 2959 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); |
3040 EXPECT_TRUE(DidReceivePrerenderStopEventForLinkNumber(0)); | 2960 EXPECT_TRUE(DidReceivePrerenderStopEventForLinkNumber(0)); |
3041 EXPECT_FALSE(HadPrerenderEventErrors()); | 2961 EXPECT_FALSE(HadPrerenderEventErrors()); |
3042 } | 2962 } |
3043 | 2963 |
3044 // Cancels the prerender of a page with its own prerender. The second prerender | 2964 // Cancels the prerender of a page with its own prerender. The second prerender |
3045 // should never be started. | 2965 // should never be started. |
3046 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2966 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3047 PrerenderCancelPrerenderWithPrerender) { | 2967 PrerenderCancelPrerenderWithPrerender) { |
3048 scoped_ptr<TestPrerender> prerender = | 2968 scoped_ptr<TestPrerender> prerender = |
3049 PrerenderTestURL("files/prerender/prerender_infinite_a.html", | 2969 PrerenderTestURL("files/prerender/prerender_infinite_a.html", |
3050 FINAL_STATUS_CANCELLED, | 2970 FINAL_STATUS_CANCELLED, |
3051 1); | 2971 1); |
3052 | 2972 |
3053 GetPrerenderManager()->CancelAllPrerenders(); | 2973 GetPrerenderManager()->CancelAllPrerenders(); |
3054 prerender->WaitForStop(); | 2974 prerender->WaitForStop(); |
3055 | 2975 |
3056 EXPECT_TRUE(GetPrerenderContents() == NULL); | 2976 EXPECT_FALSE(prerender->contents()); |
3057 } | 2977 } |
3058 | 2978 |
3059 // Prerendering and history tests. | 2979 // Prerendering and history tests. |
3060 // The prerendered page is navigated to in several ways [navigate via | 2980 // The prerendered page is navigated to in several ways [navigate via |
3061 // omnibox, click on link, key-modified click to open in background tab, etc], | 2981 // omnibox, click on link, key-modified click to open in background tab, etc], |
3062 // followed by a navigation to another page from the prerendered page, followed | 2982 // followed by a navigation to another page from the prerendered page, followed |
3063 // by a back navigation. | 2983 // by a back navigation. |
3064 | 2984 |
3065 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 2985 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3066 DISABLED_PrerenderNavigateClickGoBack) { | 2986 DISABLED_PrerenderNavigateClickGoBack) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3115 | 3035 |
3116 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClickNewForegroundTab) { | 3036 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderClickNewForegroundTab) { |
3117 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 3037 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
3118 FINAL_STATUS_WINDOW_OPENER, | 3038 FINAL_STATUS_WINDOW_OPENER, |
3119 1); | 3039 1); |
3120 OpenDestURLViaClickNewForegroundTab(); | 3040 OpenDestURLViaClickNewForegroundTab(); |
3121 } | 3041 } |
3122 | 3042 |
3123 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3043 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3124 DISABLED_PrerenderClickNewBackgroundTab) { | 3044 DISABLED_PrerenderClickNewBackgroundTab) { |
3125 PrerenderTestURL("files/prerender/prerender_page_with_link.html", | 3045 scoped_ptr<TestPrerender> prerender = |
3126 FINAL_STATUS_APP_TERMINATING, | 3046 PrerenderTestURL("files/prerender/prerender_page_with_link.html", |
3127 1); | 3047 FINAL_STATUS_APP_TERMINATING, |
3048 1); | |
3049 ASSERT_TRUE(prerender->contents()); | |
3050 prerender->contents()->set_should_be_shown(false); | |
3128 OpenDestURLViaClickNewBackgroundTab(); | 3051 OpenDestURLViaClickNewBackgroundTab(); |
3129 } | 3052 } |
3130 | 3053 |
3131 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3054 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3132 NavigateToPrerenderedPageWhenDevToolsAttached) { | 3055 NavigateToPrerenderedPageWhenDevToolsAttached) { |
3133 DisableJavascriptCalls(); | 3056 DisableJavascriptCalls(); |
3134 WebContents* web_contents = | 3057 WebContents* web_contents = |
3135 current_browser()->tab_strip_model()->GetActiveWebContents(); | 3058 current_browser()->tab_strip_model()->GetActiveWebContents(); |
3136 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetOrCreateFor( | 3059 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetOrCreateFor( |
3137 web_contents->GetRenderViewHost())); | 3060 web_contents->GetRenderViewHost())); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3222 set_loader_path("files/prerender/prerender_loader_with_referrer_policy.html"); | 3145 set_loader_path("files/prerender/prerender_loader_with_referrer_policy.html"); |
3223 PrerenderTestURL("files/prerender/prerender_referrer_policy.html", | 3146 PrerenderTestURL("files/prerender/prerender_referrer_policy.html", |
3224 FINAL_STATUS_USED, | 3147 FINAL_STATUS_USED, |
3225 1); | 3148 1); |
3226 NavigateToDestURL(); | 3149 NavigateToDestURL(); |
3227 } | 3150 } |
3228 | 3151 |
3229 // Checks that the referrer policy is used when prerendering on HTTPS. | 3152 // Checks that the referrer policy is used when prerendering on HTTPS. |
3230 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3153 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3231 PrerenderSSLReferrerPolicy) { | 3154 PrerenderSSLReferrerPolicy) { |
3232 set_use_https_src(true); | 3155 UseHttpsSrcServer(); |
3233 set_loader_path("files/prerender/prerender_loader_with_referrer_policy.html"); | 3156 set_loader_path("files/prerender/prerender_loader_with_referrer_policy.html"); |
3234 PrerenderTestURL("files/prerender/prerender_referrer_policy.html", | 3157 PrerenderTestURL("files/prerender/prerender_referrer_policy.html", |
3235 FINAL_STATUS_USED, | 3158 FINAL_STATUS_USED, |
3236 1); | 3159 1); |
3237 NavigateToDestURL(); | 3160 NavigateToDestURL(); |
3238 } | 3161 } |
3239 | 3162 |
3240 // Checks that the referrer policy is used when prerendering is cancelled. | 3163 // Checks that the referrer policy is used when prerendering is cancelled. |
3241 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelReferrerPolicy) { | 3164 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCancelReferrerPolicy) { |
3242 scoped_ptr<TestContentBrowserClient> test_content_browser_client( | 3165 scoped_ptr<TestContentBrowserClient> test_content_browser_client( |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3438 GURL url = test_server()->GetURL( | 3361 GURL url = test_server()->GetURL( |
3439 CreateServerRedirect("invalidscheme://www.google.com/test.html")); | 3362 CreateServerRedirect("invalidscheme://www.google.com/test.html")); |
3440 PrerenderTestURL(url, FINAL_STATUS_UNSUPPORTED_SCHEME, 0); | 3363 PrerenderTestURL(url, FINAL_STATUS_UNSUPPORTED_SCHEME, 0); |
3441 } | 3364 } |
3442 | 3365 |
3443 // Checks that media source video loads are deferred on prerendering. | 3366 // Checks that media source video loads are deferred on prerendering. |
3444 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5MediaSourceVideo) { | 3367 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHTML5MediaSourceVideo) { |
3445 PrerenderTestURL("files/prerender/prerender_html5_video_media_source.html", | 3368 PrerenderTestURL("files/prerender/prerender_html5_video_media_source.html", |
3446 FINAL_STATUS_USED, | 3369 FINAL_STATUS_USED, |
3447 1); | 3370 1); |
3448 NavigateToDestUrlAndWaitForPassTitle(); | 3371 NavigateToDestURL(); |
3372 WaitForASCIITitle(GetActiveWebContents(), kPassTitle); | |
3449 } | 3373 } |
3450 | 3374 |
3451 // Checks that a prerender that creates an audio stream (via a WebAudioDevice) | 3375 // Checks that a prerender that creates an audio stream (via a WebAudioDevice) |
3452 // is cancelled. | 3376 // is cancelled. |
3453 // http://crbug.com/261489 | 3377 // http://crbug.com/261489 |
3454 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderWebAudioDevice) { | 3378 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderWebAudioDevice) { |
3455 PrerenderTestURL("files/prerender/prerender_web_audio_device.html", | 3379 PrerenderTestURL("files/prerender/prerender_web_audio_device.html", |
3456 FINAL_STATUS_CREATING_AUDIO_STREAM, 1); | 3380 FINAL_STATUS_CREATING_AUDIO_STREAM, 1); |
3457 } | 3381 } |
3458 | 3382 |
3459 // Checks that prerenders do not swap in to WebContents being captured. | 3383 // Checks that prerenders do not swap in to WebContents being captured. |
3460 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCapturedWebContents) { | 3384 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderCapturedWebContents) { |
3461 PrerenderTestURL("files/prerender/prerender_page.html", | 3385 PrerenderTestURL("files/prerender/prerender_page.html", |
3462 FINAL_STATUS_PAGE_BEING_CAPTURED, 1); | 3386 FINAL_STATUS_PAGE_BEING_CAPTURED, 1); |
3463 WebContents* web_contents = | 3387 WebContents* web_contents = GetActiveWebContents(); |
3464 current_browser()->tab_strip_model()->GetActiveWebContents(); | |
3465 web_contents->IncrementCapturerCount(); | 3388 web_contents->IncrementCapturerCount(); |
3466 NavigateToDestURLWithDisposition(CURRENT_TAB, false); | 3389 NavigateToDestURLWithDisposition(CURRENT_TAB, false); |
3467 web_contents->DecrementCapturerCount(); | 3390 web_contents->DecrementCapturerCount(); |
3468 } | 3391 } |
3469 | 3392 |
3470 // Checks that prerenders are aborted on cross-process navigation from | 3393 // Checks that prerenders are aborted on cross-process navigation from |
3471 // a server redirect. | 3394 // a server redirect. |
3472 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3395 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3473 PrerenderCrossProcessServerRedirect) { | 3396 PrerenderCrossProcessServerRedirect) { |
3474 // Force everything to be a process swap. | 3397 // Force everything to be a process swap. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3518 GetPrerenderManager()->CancelAllPrerenders(); | 3441 GetPrerenderManager()->CancelAllPrerenders(); |
3519 prerenders[1]->WaitForStop(); | 3442 prerenders[1]->WaitForStop(); |
3520 | 3443 |
3521 // Check the referring page only got one copy of the event. | 3444 // Check the referring page only got one copy of the event. |
3522 EXPECT_FALSE(HadPrerenderEventErrors()); | 3445 EXPECT_FALSE(HadPrerenderEventErrors()); |
3523 } | 3446 } |
3524 | 3447 |
3525 // Checks that a deferred redirect to an image is not loaded until the | 3448 // Checks that a deferred redirect to an image is not loaded until the |
3526 // page is visible. | 3449 // page is visible. |
3527 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredImage) { | 3450 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredImage) { |
3528 // We do NOT wait for a load event, as the image will block the | 3451 DisableJavascriptCalls(); |
3529 // load. Instead, wait for the title to change. | 3452 |
3453 // The prerender will not completely load until after the swap, so wait for a | |
3454 // title change before calling DidPrerenderPass. | |
3530 scoped_ptr<TestPrerender> prerender = | 3455 scoped_ptr<TestPrerender> prerender = |
3531 PrerenderTestURL("files/prerender/prerender_deferred_image.html", | 3456 PrerenderTestURL( |
3532 FINAL_STATUS_USED, 0, true); | 3457 "files/prerender/prerender_deferred_image.html", |
3533 | 3458 FINAL_STATUS_USED, 0); |
3534 // The prerender hasn't loaded yet because its image is deferred. | 3459 WaitForASCIITitle(prerender->contents()->prerender_contents(), kReadyTitle); |
3460 EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents())); | |
3535 EXPECT_EQ(0, prerender->number_of_loads()); | 3461 EXPECT_EQ(0, prerender->number_of_loads()); |
3536 | 3462 |
3537 // Navigate, waiting for both the swap and an extra load from the prerender. | 3463 // Swap. |
3538 // The swap happens before the load, so |prerender->WaitForLoads(1)| doesn't | 3464 NavigationOrSwapObserver swap_observer(current_browser()->tab_strip_model(), |
3539 // work. | 3465 GetActiveWebContents()); |
3540 content::WindowedNotificationObserver page_load_observer( | |
3541 content::NOTIFICATION_LOAD_STOP, | |
3542 content::Source<NavigationController>( | |
3543 &prerender->contents()->prerender_contents()->GetController())); | |
3544 NavigationOrSwapObserver swap_observer( | |
3545 current_browser()->tab_strip_model(), | |
3546 current_browser()->tab_strip_model()->GetActiveWebContents()); | |
3547 ui_test_utils::NavigateToURLWithDisposition( | 3466 ui_test_utils::NavigateToURLWithDisposition( |
3548 current_browser(), dest_url(), CURRENT_TAB, | 3467 current_browser(), dest_url(), CURRENT_TAB, |
3549 ui_test_utils::BROWSER_TEST_NONE); | 3468 ui_test_utils::BROWSER_TEST_NONE); |
3550 swap_observer.Wait(); | 3469 swap_observer.Wait(); |
3551 page_load_observer.Wait(); | |
3552 | 3470 |
3553 // The prerender never observed the final load. | 3471 // The page only finishes navigating after the swap. Wait for it to if it |
3472 // hasn't yet. | |
3473 content::WaitForLoadStop(GetActiveWebContents()); | |
3474 | |
3475 // The prerender never observes the final load. | |
3554 EXPECT_EQ(0, prerender->number_of_loads()); | 3476 EXPECT_EQ(0, prerender->number_of_loads()); |
3555 | 3477 |
3556 // Now check DidDisplayPass. | 3478 // Now check DidDisplayPass. |
3557 EXPECT_TRUE(DidDisplayPass( | 3479 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); |
3558 current_browser()->tab_strip_model()->GetActiveWebContents())); | |
3559 } | 3480 } |
3560 | 3481 |
3561 // Checks that a deferred redirect to an image is not loaded until the | 3482 // Checks that a deferred redirect to an image is not loaded until the |
3562 // page is visible, even after another redirect. | 3483 // page is visible, even after another redirect. |
3563 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3484 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3564 PrerenderDeferredImageAfterRedirect) { | 3485 PrerenderDeferredImageAfterRedirect) { |
3565 // We do NOT wait for a load event, as the image will block the | 3486 DisableJavascriptCalls(); |
3566 // load. Instead, wait for the title to change. | 3487 |
3488 // The prerender will not completely load until after the swap, so wait for a | |
3489 // title change before calling DidPrerenderPass. | |
3567 scoped_ptr<TestPrerender> prerender = | 3490 scoped_ptr<TestPrerender> prerender = |
3568 PrerenderTestURL( | 3491 PrerenderTestURL( |
3569 "files/prerender/prerender_deferred_image.html#double_redirect", | 3492 "files/prerender/prerender_deferred_image.html", |
3570 FINAL_STATUS_USED, 0, true); | 3493 FINAL_STATUS_USED, 0); |
3571 | 3494 WaitForASCIITitle(prerender->contents()->prerender_contents(), kReadyTitle); |
3572 // The prerender hasn't loaded yet because its image is deferred. | 3495 EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents())); |
3573 EXPECT_EQ(0, prerender->number_of_loads()); | 3496 EXPECT_EQ(0, prerender->number_of_loads()); |
3574 | 3497 |
3575 // Navigate, waiting for both the swap and an extra load from the prerender. | 3498 // Swap. |
3576 // The swap happens before the load, so |prerender->WaitForLoads(1)| doesn't | 3499 NavigationOrSwapObserver swap_observer(current_browser()->tab_strip_model(), |
3577 // work. | 3500 GetActiveWebContents()); |
3578 content::WindowedNotificationObserver page_load_observer( | |
3579 content::NOTIFICATION_LOAD_STOP, | |
3580 content::Source<NavigationController>( | |
3581 &prerender->contents()->prerender_contents()->GetController())); | |
3582 NavigationOrSwapObserver swap_observer( | |
3583 current_browser()->tab_strip_model(), | |
3584 current_browser()->tab_strip_model()->GetActiveWebContents()); | |
3585 ui_test_utils::NavigateToURLWithDisposition( | 3501 ui_test_utils::NavigateToURLWithDisposition( |
3586 current_browser(), dest_url(), CURRENT_TAB, | 3502 current_browser(), dest_url(), CURRENT_TAB, |
3587 ui_test_utils::BROWSER_TEST_NONE); | 3503 ui_test_utils::BROWSER_TEST_NONE); |
3588 swap_observer.Wait(); | 3504 swap_observer.Wait(); |
3589 page_load_observer.Wait(); | |
3590 | 3505 |
3591 // The prerender never observed the final load. | 3506 // The page only finishes navigating after the swap. Wait for it to if it |
3507 // hasn't yet. | |
3508 content::WaitForLoadStop(GetActiveWebContents()); | |
3509 | |
3510 // The prerender never observes the final load. | |
3592 EXPECT_EQ(0, prerender->number_of_loads()); | 3511 EXPECT_EQ(0, prerender->number_of_loads()); |
3593 | 3512 |
3594 // Now check DidDisplayPass. | 3513 // Now check DidDisplayPass. |
3595 EXPECT_TRUE(DidDisplayPass( | 3514 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); |
3596 current_browser()->tab_strip_model()->GetActiveWebContents())); | |
3597 } | 3515 } |
3598 | 3516 |
3599 // Checks that deferred redirects in the main frame are followed. | 3517 // Checks that deferred redirects in the main frame are followed. |
3600 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredMainFrame) { | 3518 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredMainFrame) { |
3601 DisableJavascriptCalls(); | 3519 DisableJavascriptCalls(); |
3602 PrerenderTestURL( | 3520 PrerenderTestURL( |
3603 "files/prerender/image-deferred.png", | 3521 "files/prerender/image-deferred.png", |
3604 FINAL_STATUS_USED, 1); | 3522 FINAL_STATUS_USED, 1); |
3605 NavigateToDestURL(); | 3523 NavigateToDestURL(); |
3606 } | 3524 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3739 | 3657 |
3740 // Now navigate in the new tab. Set expect_swap_to_succeed to false because | 3658 // Now navigate in the new tab. Set expect_swap_to_succeed to false because |
3741 // the swap does not occur synchronously. | 3659 // the swap does not occur synchronously. |
3742 // | 3660 // |
3743 // TODO(davidben): When all swaps become asynchronous, remove the OpenURL | 3661 // TODO(davidben): When all swaps become asynchronous, remove the OpenURL |
3744 // return value assertion and let this go through the usual successful-swap | 3662 // return value assertion and let this go through the usual successful-swap |
3745 // codepath. | 3663 // codepath. |
3746 NavigateToDestURLWithDisposition(CURRENT_TAB, false); | 3664 NavigateToDestURLWithDisposition(CURRENT_TAB, false); |
3747 | 3665 |
3748 // Verify DidDisplayPass manually since the previous call skipped it. | 3666 // Verify DidDisplayPass manually since the previous call skipped it. |
3749 EXPECT_TRUE(DidDisplayPass( | 3667 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); |
3750 current_browser()->tab_strip_model()->GetActiveWebContents())); | |
3751 | 3668 |
3752 // Only one request to the test URL started. | 3669 // Only one request to the test URL started. |
3753 EXPECT_EQ(1, counter.count()); | 3670 EXPECT_EQ(1, counter.count()); |
3754 } | 3671 } |
3755 | 3672 |
3756 // Verify that session storage conflicts don't merge. | 3673 // Verify that session storage conflicts don't merge. |
3757 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSessionStorageConflict) { | 3674 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSessionStorageConflict) { |
3758 PrerenderTestURL("files/prerender/prerender_session_storage_conflict.html", | 3675 PrerenderTestURL("files/prerender/prerender_session_storage_conflict.html", |
3759 FINAL_STATUS_APP_TERMINATING, 1); | 3676 FINAL_STATUS_APP_TERMINATING, 1); |
3760 | 3677 |
3761 // Open a new tab to navigate in. | 3678 // Open a new tab to navigate in. |
3762 ui_test_utils::NavigateToURLWithDisposition( | 3679 ui_test_utils::NavigateToURLWithDisposition( |
3763 current_browser(), | 3680 current_browser(), |
3764 test_server()->GetURL("files/prerender/init_session_storage.html"), | 3681 test_server()->GetURL("files/prerender/init_session_storage.html"), |
3765 NEW_FOREGROUND_TAB, | 3682 NEW_FOREGROUND_TAB, |
3766 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 3683 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
3767 | 3684 |
3768 // Now navigate in the new tab. | 3685 // Now navigate in the new tab. |
3769 NavigateToDestURLWithDisposition(CURRENT_TAB, false); | 3686 NavigateToDestURLWithDisposition(CURRENT_TAB, false); |
3770 | 3687 |
3771 // Verify DidDisplayPass in the new tab. | 3688 // Verify DidDisplayPass in the new tab. |
3772 EXPECT_TRUE(DidDisplayPass( | 3689 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); |
3773 current_browser()->tab_strip_model()->GetActiveWebContents())); | |
3774 } | 3690 } |
3775 | 3691 |
3776 // Checks that prerenders honor |should_replace_current_entry|. | 3692 // Checks that prerenders honor |should_replace_current_entry|. |
3777 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) { | 3693 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderReplaceCurrentEntry) { |
3778 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 3694 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
3779 | 3695 |
3780 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB, | 3696 content::OpenURLParams params(dest_url(), Referrer(), CURRENT_TAB, |
3781 content::PAGE_TRANSITION_TYPED, false); | 3697 content::PAGE_TRANSITION_TYPED, false); |
3782 params.should_replace_current_entry = true; | 3698 params.should_replace_current_entry = true; |
3783 NavigateToURLWithParams(params, false); | 3699 NavigateToURLWithParams(params, false); |
3784 | 3700 |
3785 WebContents* web_contents = | 3701 const NavigationController& controller = |
3786 current_browser()->tab_strip_model()->GetActiveWebContents(); | 3702 GetActiveWebContents()->GetController(); |
3787 const NavigationController& controller = web_contents->GetController(); | |
3788 // First entry is about:blank, second is prerender_page.html. | 3703 // First entry is about:blank, second is prerender_page.html. |
3789 EXPECT_TRUE(controller.GetPendingEntry() == NULL); | 3704 EXPECT_TRUE(controller.GetPendingEntry() == NULL); |
3790 EXPECT_EQ(2, controller.GetEntryCount()); | 3705 EXPECT_EQ(2, controller.GetEntryCount()); |
3791 EXPECT_EQ(GURL(content::kAboutBlankURL), | 3706 EXPECT_EQ(GURL(content::kAboutBlankURL), |
3792 controller.GetEntryAtIndex(0)->GetURL()); | 3707 controller.GetEntryAtIndex(0)->GetURL()); |
3793 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL()); | 3708 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL()); |
3794 } | 3709 } |
3795 | 3710 |
3711 class PrerenderIncognitoBrowserTest : public PrerenderBrowserTest { | |
3712 public: | |
3713 virtual void SetUpOnMainThread() OVERRIDE { | |
3714 Profile* normal_profile = current_browser()->profile(); | |
3715 set_browser(ui_test_utils::OpenURLOffTheRecord( | |
3716 normal_profile, GURL("about:blank"))); | |
3717 PrerenderBrowserTest::SetUpOnMainThread(); | |
3718 } | |
3719 }; | |
3720 | |
3721 // Checks that prerendering works in incognito mode. | |
3722 IN_PROC_BROWSER_TEST_F(PrerenderIncognitoBrowserTest, PrerenderIncognito) { | |
3723 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | |
3724 NavigateToDestURL(); | |
3725 } | |
3726 | |
3796 } // namespace prerender | 3727 } // namespace prerender |
OLD | NEW |