OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/frame_host/navigation_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
6 #include "content/browser/web_contents/web_contents_impl.h" | 6 #include "content/browser/web_contents/web_contents_impl.h" |
7 #include "content/public/browser/web_contents.h" | 7 #include "content/public/browser/web_contents.h" |
8 #include "content/public/browser/web_contents_observer.h" | 8 #include "content/public/browser/web_contents_observer.h" |
9 #include "content/public/common/request_context_type.h" | 9 #include "content/public/common/request_context_type.h" |
10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 : NavigationThrottle(handle), | 134 : NavigationThrottle(handle), |
135 will_start_result_(will_start_result), | 135 will_start_result_(will_start_result), |
136 will_redirect_result_(will_redirect_result), | 136 will_redirect_result_(will_redirect_result), |
137 will_process_result_(will_process_result), | 137 will_process_result_(will_process_result), |
138 did_call_will_start_(did_call_will_start), | 138 did_call_will_start_(did_call_will_start), |
139 did_call_will_redirect_(did_call_will_redirect), | 139 did_call_will_redirect_(did_call_will_redirect), |
140 did_call_will_process_(did_call_will_process) {} | 140 did_call_will_process_(did_call_will_process) {} |
141 ~TestNavigationThrottle() override {} | 141 ~TestNavigationThrottle() override {} |
142 | 142 |
143 void Resume() { navigation_handle()->Resume(); } | 143 void Resume() { navigation_handle()->Resume(); } |
144 void Cancel(NavigationThrottle::ThrottleCheckResult result) { | |
145 navigation_handle()->CancelDeferredNavigation(result); | |
146 } | |
144 | 147 |
145 RequestContextType request_context_type() { return request_context_type_; } | 148 RequestContextType request_context_type() { return request_context_type_; } |
146 | 149 |
147 private: | 150 private: |
148 // NavigationThrottle implementation. | 151 // NavigationThrottle implementation. |
149 NavigationThrottle::ThrottleCheckResult WillStartRequest() override { | 152 NavigationThrottle::ThrottleCheckResult WillStartRequest() override { |
150 NavigationHandleImpl* navigation_handle_impl = | 153 NavigationHandleImpl* navigation_handle_impl = |
151 static_cast<NavigationHandleImpl*>(navigation_handle()); | 154 static_cast<NavigationHandleImpl*>(navigation_handle()); |
152 CHECK_NE(REQUEST_CONTEXT_TYPE_UNSPECIFIED, | 155 CHECK_NE(REQUEST_CONTEXT_TYPE_UNSPECIFIED, |
153 navigation_handle_impl->request_context_type()); | 156 navigation_handle_impl->request_context_type()); |
(...skipping 27 matching lines...) Expand all Loading... | |
181 | 184 |
182 NavigationThrottle::ThrottleCheckResult will_start_result_; | 185 NavigationThrottle::ThrottleCheckResult will_start_result_; |
183 NavigationThrottle::ThrottleCheckResult will_redirect_result_; | 186 NavigationThrottle::ThrottleCheckResult will_redirect_result_; |
184 NavigationThrottle::ThrottleCheckResult will_process_result_; | 187 NavigationThrottle::ThrottleCheckResult will_process_result_; |
185 base::Closure did_call_will_start_; | 188 base::Closure did_call_will_start_; |
186 base::Closure did_call_will_redirect_; | 189 base::Closure did_call_will_redirect_; |
187 base::Closure did_call_will_process_; | 190 base::Closure did_call_will_process_; |
188 RequestContextType request_context_type_; | 191 RequestContextType request_context_type_; |
189 }; | 192 }; |
190 | 193 |
191 // Install a TestNavigationThrottle on all following requests and allows waiting | 194 // Installs a TestNavigationThrottle either on all following requests or on |
192 // for various NavigationThrottle related events. Waiting works only for the | 195 // requests with an expected starting URL, and allows waiting for various |
193 // immediately next navigation. New instances are needed to wait for further | 196 // NavigationThrottle related events. Waiting works only for the immediately |
194 // navigations. | 197 // next navigation. New instances are needed to wait for further navigations. |
195 class TestNavigationThrottleInstaller : public WebContentsObserver { | 198 class TestNavigationThrottleInstaller : public WebContentsObserver { |
196 public: | 199 public: |
197 TestNavigationThrottleInstaller( | 200 TestNavigationThrottleInstaller( |
198 WebContents* web_contents, | 201 WebContents* web_contents, |
199 NavigationThrottle::ThrottleCheckResult will_start_result, | 202 NavigationThrottle::ThrottleCheckResult will_start_result, |
200 NavigationThrottle::ThrottleCheckResult will_redirect_result, | 203 NavigationThrottle::ThrottleCheckResult will_redirect_result, |
201 NavigationThrottle::ThrottleCheckResult will_process_result) | 204 NavigationThrottle::ThrottleCheckResult will_process_result, |
205 GURL expected_start_url = GURL()) | |
202 : WebContentsObserver(web_contents), | 206 : WebContentsObserver(web_contents), |
203 will_start_result_(will_start_result), | 207 will_start_result_(will_start_result), |
204 will_redirect_result_(will_redirect_result), | 208 will_redirect_result_(will_redirect_result), |
205 will_process_result_(will_process_result), | 209 will_process_result_(will_process_result), |
206 will_start_called_(0), | 210 will_start_called_(0), |
207 will_redirect_called_(0), | 211 will_redirect_called_(0), |
208 will_process_called_(0), | 212 will_process_called_(0), |
209 navigation_throttle_(nullptr) {} | 213 navigation_throttle_(nullptr), |
214 expected_start_url_(expected_start_url) {} | |
210 ~TestNavigationThrottleInstaller() override{}; | 215 ~TestNavigationThrottleInstaller() override{}; |
211 | 216 |
212 TestNavigationThrottle* navigation_throttle() { return navigation_throttle_; } | 217 TestNavigationThrottle* navigation_throttle() { return navigation_throttle_; } |
213 | 218 |
214 void WaitForThrottleWillStart() { | 219 void WaitForThrottleWillStart() { |
215 if (will_start_called_) | 220 if (will_start_called_) |
216 return; | 221 return; |
217 will_start_loop_runner_ = new MessageLoopRunner(); | 222 will_start_loop_runner_ = new MessageLoopRunner(); |
218 will_start_loop_runner_->Run(); | 223 will_start_loop_runner_->Run(); |
219 will_start_loop_runner_ = nullptr; | 224 will_start_loop_runner_ = nullptr; |
220 } | 225 } |
221 | 226 |
222 void WaitForThrottleWillRedirect() { | 227 void WaitForThrottleWillRedirect() { |
223 if (will_redirect_called_) | 228 if (will_redirect_called_) |
224 return; | 229 return; |
225 will_redirect_loop_runner_ = new MessageLoopRunner(); | 230 will_redirect_loop_runner_ = new MessageLoopRunner(); |
226 will_redirect_loop_runner_->Run(); | 231 will_redirect_loop_runner_->Run(); |
227 will_redirect_loop_runner_ = nullptr; | 232 will_redirect_loop_runner_ = nullptr; |
228 } | 233 } |
229 | 234 |
230 void WaitForThrottleWillProcess() { | 235 void WaitForThrottleWillProcess() { |
231 if (will_process_called_) | 236 if (will_process_called_) |
232 return; | 237 return; |
233 will_process_loop_runner_ = new MessageLoopRunner(); | 238 will_process_loop_runner_ = new MessageLoopRunner(); |
234 will_process_loop_runner_->Run(); | 239 will_process_loop_runner_->Run(); |
235 will_process_loop_runner_ = nullptr; | 240 will_process_loop_runner_ = nullptr; |
236 } | 241 } |
237 | 242 |
243 void Continue(NavigationThrottle::ThrottleCheckResult result) { | |
244 ASSERT_NE(NavigationThrottle::DEFER, result); | |
245 if (result == NavigationThrottle::PROCEED) | |
246 navigation_throttle()->Resume(); | |
247 else | |
248 navigation_throttle()->Cancel(result); | |
249 } | |
250 | |
238 int will_start_called() { return will_start_called_; } | 251 int will_start_called() { return will_start_called_; } |
239 int will_redirect_called() { return will_redirect_called_; } | 252 int will_redirect_called() { return will_redirect_called_; } |
240 int will_process_called() { return will_process_called_; } | 253 int will_process_called() { return will_process_called_; } |
241 | 254 |
255 protected: | |
256 virtual void DidCallWillStartRequest() { | |
257 will_start_called_++; | |
258 if (will_start_loop_runner_) | |
259 will_start_loop_runner_->Quit(); | |
260 } | |
261 | |
262 virtual void DidCallWillRedirectRequest() { | |
263 will_redirect_called_++; | |
264 if (will_redirect_loop_runner_) | |
265 will_redirect_loop_runner_->Quit(); | |
266 } | |
267 | |
268 virtual void DidCallWillProcessResponse() { | |
269 will_process_called_++; | |
270 if (will_process_loop_runner_) | |
271 will_process_loop_runner_->Quit(); | |
272 } | |
273 | |
242 private: | 274 private: |
243 void DidStartNavigation(NavigationHandle* handle) override { | 275 void DidStartNavigation(NavigationHandle* handle) override { |
276 if (!expected_start_url_.is_empty() && | |
277 handle->GetURL() != expected_start_url_) | |
278 return; | |
279 | |
244 std::unique_ptr<NavigationThrottle> throttle(new TestNavigationThrottle( | 280 std::unique_ptr<NavigationThrottle> throttle(new TestNavigationThrottle( |
245 handle, will_start_result_, will_redirect_result_, will_process_result_, | 281 handle, will_start_result_, will_redirect_result_, will_process_result_, |
246 base::Bind(&TestNavigationThrottleInstaller::DidCallWillStartRequest, | 282 base::Bind(&TestNavigationThrottleInstaller::DidCallWillStartRequest, |
247 base::Unretained(this)), | 283 base::Unretained(this)), |
248 base::Bind(&TestNavigationThrottleInstaller::DidCallWillRedirectRequest, | 284 base::Bind(&TestNavigationThrottleInstaller::DidCallWillRedirectRequest, |
249 base::Unretained(this)), | 285 base::Unretained(this)), |
250 base::Bind(&TestNavigationThrottleInstaller::DidCallWillProcessResponse, | 286 base::Bind(&TestNavigationThrottleInstaller::DidCallWillProcessResponse, |
251 base::Unretained(this)))); | 287 base::Unretained(this)))); |
252 navigation_throttle_ = static_cast<TestNavigationThrottle*>(throttle.get()); | 288 navigation_throttle_ = static_cast<TestNavigationThrottle*>(throttle.get()); |
253 handle->RegisterThrottleForTesting(std::move(throttle)); | 289 handle->RegisterThrottleForTesting(std::move(throttle)); |
254 } | 290 } |
255 | 291 |
256 void DidFinishNavigation(NavigationHandle* handle) override { | 292 void DidFinishNavigation(NavigationHandle* handle) override { |
257 if (!navigation_throttle_) | 293 if (!navigation_throttle_) |
258 return; | 294 return; |
259 | 295 |
260 if (handle == navigation_throttle_->navigation_handle()) | 296 if (handle == navigation_throttle_->navigation_handle()) |
261 navigation_throttle_ = nullptr; | 297 navigation_throttle_ = nullptr; |
262 } | 298 } |
263 | 299 |
264 void DidCallWillStartRequest() { | |
265 will_start_called_++; | |
266 if (will_start_loop_runner_) | |
267 will_start_loop_runner_->Quit(); | |
268 } | |
269 | |
270 void DidCallWillRedirectRequest() { | |
271 will_redirect_called_++; | |
272 if (will_redirect_loop_runner_) | |
273 will_redirect_loop_runner_->Quit(); | |
274 } | |
275 | |
276 void DidCallWillProcessResponse() { | |
277 will_process_called_++; | |
278 if (will_process_loop_runner_) | |
279 will_process_loop_runner_->Quit(); | |
280 } | |
281 | |
282 NavigationThrottle::ThrottleCheckResult will_start_result_; | 300 NavigationThrottle::ThrottleCheckResult will_start_result_; |
283 NavigationThrottle::ThrottleCheckResult will_redirect_result_; | 301 NavigationThrottle::ThrottleCheckResult will_redirect_result_; |
284 NavigationThrottle::ThrottleCheckResult will_process_result_; | 302 NavigationThrottle::ThrottleCheckResult will_process_result_; |
285 int will_start_called_; | 303 int will_start_called_; |
286 int will_redirect_called_; | 304 int will_redirect_called_; |
287 int will_process_called_; | 305 int will_process_called_; |
288 TestNavigationThrottle* navigation_throttle_; | 306 TestNavigationThrottle* navigation_throttle_; |
289 scoped_refptr<MessageLoopRunner> will_start_loop_runner_; | 307 scoped_refptr<MessageLoopRunner> will_start_loop_runner_; |
290 scoped_refptr<MessageLoopRunner> will_redirect_loop_runner_; | 308 scoped_refptr<MessageLoopRunner> will_redirect_loop_runner_; |
291 scoped_refptr<MessageLoopRunner> will_process_loop_runner_; | 309 scoped_refptr<MessageLoopRunner> will_process_loop_runner_; |
310 GURL expected_start_url_; | |
311 }; | |
312 | |
313 // Same as above, but installs NavigationThrottles that do not directly return | |
314 // the pre-programmed check results, but first DEFER the navigation at each | |
315 // stage and then resume/cancel asynchronously. | |
316 class TestDeferringNavigationThrottleInstaller | |
317 : public TestNavigationThrottleInstaller { | |
318 public: | |
319 TestDeferringNavigationThrottleInstaller( | |
320 WebContents* web_contents, | |
321 NavigationThrottle::ThrottleCheckResult will_start_result, | |
322 NavigationThrottle::ThrottleCheckResult will_redirect_result, | |
323 NavigationThrottle::ThrottleCheckResult will_process_result, | |
324 GURL expected_start_url = GURL()) | |
325 : TestNavigationThrottleInstaller(web_contents, | |
326 NavigationThrottle::DEFER, | |
327 NavigationThrottle::DEFER, | |
328 NavigationThrottle::DEFER, | |
329 expected_start_url), | |
330 will_start_deferred_result_(will_start_result), | |
331 will_redirect_deferred_result_(will_redirect_result), | |
332 will_process_deferred_result_(will_process_result) {} | |
333 | |
334 protected: | |
335 void DidCallWillStartRequest() override { | |
336 TestNavigationThrottleInstaller::DidCallWillStartRequest(); | |
337 Continue(will_start_deferred_result_); | |
338 } | |
339 | |
340 void DidCallWillRedirectRequest() override { | |
341 TestNavigationThrottleInstaller::DidCallWillStartRequest(); | |
342 Continue(will_redirect_deferred_result_); | |
343 } | |
344 | |
345 void DidCallWillProcessResponse() override { | |
346 TestNavigationThrottleInstaller::DidCallWillStartRequest(); | |
347 Continue(will_process_deferred_result_); | |
348 } | |
349 | |
350 private: | |
351 NavigationThrottle::ThrottleCheckResult will_start_deferred_result_; | |
352 NavigationThrottle::ThrottleCheckResult will_redirect_deferred_result_; | |
353 NavigationThrottle::ThrottleCheckResult will_process_deferred_result_; | |
292 }; | 354 }; |
293 | 355 |
294 // Records all navigation start URLs from the WebContents. | 356 // Records all navigation start URLs from the WebContents. |
295 class NavigationStartUrlRecorder : public WebContentsObserver { | 357 class NavigationStartUrlRecorder : public WebContentsObserver { |
296 public: | 358 public: |
297 NavigationStartUrlRecorder(WebContents* web_contents) | 359 NavigationStartUrlRecorder(WebContents* web_contents) |
298 : WebContentsObserver(web_contents) {} | 360 : WebContentsObserver(web_contents) {} |
299 | 361 |
300 void DidStartNavigation(NavigationHandle* navigation_handle) override { | 362 void DidStartNavigation(NavigationHandle* navigation_handle) override { |
301 urls_.push_back(navigation_handle->GetURL()); | 363 urls_.push_back(navigation_handle->GetURL()); |
302 } | 364 } |
303 | 365 |
304 const std::vector<GURL>& urls() const { return urls_; } | 366 const std::vector<GURL>& urls() const { return urls_; } |
305 | 367 |
306 private: | 368 private: |
307 std::vector<GURL> urls_; | 369 std::vector<GURL> urls_; |
308 }; | 370 }; |
309 | 371 |
372 bool IsChildFrameCollapsed(Shell* shell, const char* element_id) { | |
373 const char kScript[] = | |
374 "window.domAutomationController.send(" | |
375 " document.getElementById(\"%s\").clientWidth" | |
376 ");"; | |
377 int client_width = 0; | |
378 EXPECT_TRUE(ExecuteScriptAndExtractInt( | |
379 shell, base::StringPrintf(kScript, element_id), &client_width)); | |
380 return !client_width; | |
381 } | |
382 | |
310 } // namespace | 383 } // namespace |
311 | 384 |
312 class NavigationHandleImplBrowserTest : public ContentBrowserTest { | 385 class NavigationHandleImplBrowserTest : public ContentBrowserTest { |
313 protected: | 386 protected: |
314 void SetUpOnMainThread() override { | 387 void SetUpOnMainThread() override { |
315 host_resolver()->AddRule("*", "127.0.0.1"); | 388 host_resolver()->AddRule("*", "127.0.0.1"); |
316 SetupCrossSiteRedirector(embedded_test_server()); | 389 SetupCrossSiteRedirector(embedded_test_server()); |
317 ASSERT_TRUE(embedded_test_server()->Start()); | 390 ASSERT_TRUE(embedded_test_server()->Start()); |
318 } | 391 } |
319 }; | 392 }; |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 // Wait for the end of the navigation. | 780 // Wait for the end of the navigation. |
708 navigation_observer.Wait(); | 781 navigation_observer.Wait(); |
709 | 782 |
710 EXPECT_TRUE(observer.has_committed()); | 783 EXPECT_TRUE(observer.has_committed()); |
711 EXPECT_TRUE(observer.was_redirected()); | 784 EXPECT_TRUE(observer.was_redirected()); |
712 EXPECT_FALSE(observer.is_error()); | 785 EXPECT_FALSE(observer.is_error()); |
713 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), | 786 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), |
714 GURL(embedded_test_server()->GetURL("bar.com", "/title2.html"))); | 787 GURL(embedded_test_server()->GetURL("bar.com", "/title2.html"))); |
715 } | 788 } |
716 | 789 |
790 // Ensure that a NavigationThrottle can block the navigation and collapse the | |
791 // frame owner both on request start as well as after a redirect. Plus, ensure | |
792 // that the frame is restored on the subsequent non-error-page navigation. | |
793 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, | |
794 ThrottleBlockAndCollapse) { | |
795 const char kChildFrameId[] = "child0"; | |
796 GURL main_url(embedded_test_server()->GetURL( | |
797 "a.com", "/frame_tree/page_with_one_frame.html")); | |
798 GURL blocked_subframe_url(embedded_test_server()->GetURL( | |
799 "a.com", "/cross-site/baz.com/title1.html")); | |
800 GURL allowed_subframe_url(embedded_test_server()->GetURL( | |
801 "a.com", "/cross-site/baz.com/title2.html")); | |
802 GURL allowed_subframe_final_url( | |
803 embedded_test_server()->GetURL("baz.com", "/title2.html")); | |
804 | |
805 // Exercise both synchronous and deferred throttle check results, and both on | |
806 // WillStartRequest and on WillRedirectRequest. | |
807 for (const bool deferred_block : {false, true}) { | |
808 for (const bool block_on_redirect : {false, true}) { | |
809 SCOPED_TRACE(deferred_block ? "Direct block" : "Deferred block"); | |
810 SCOPED_TRACE(block_on_redirect ? "Block on WillStartRequest" | |
811 : "Block on WillRedirectRequest"); | |
812 | |
813 NavigationThrottle::ThrottleCheckResult will_start_result = | |
814 block_on_redirect ? NavigationThrottle::PROCEED | |
815 : NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE; | |
816 NavigationThrottle::ThrottleCheckResult will_redirect_result = | |
817 block_on_redirect ? NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE | |
818 : NavigationThrottle::PROCEED; | |
819 | |
820 std::unique_ptr<TestNavigationThrottleInstaller> | |
821 subframe_throttle_installer; | |
822 if (deferred_block) { | |
823 subframe_throttle_installer.reset( | |
824 new TestDeferringNavigationThrottleInstaller( | |
825 shell()->web_contents(), will_start_result, | |
826 will_redirect_result, NavigationThrottle::PROCEED, | |
827 blocked_subframe_url)); | |
828 } else { | |
829 subframe_throttle_installer.reset(new TestNavigationThrottleInstaller( | |
830 shell()->web_contents(), will_start_result, will_redirect_result, | |
831 NavigationThrottle::PROCEED, blocked_subframe_url)); | |
832 } | |
833 | |
834 { | |
835 SCOPED_TRACE("Initial navigation blocked on main frame load."); | |
836 NavigationHandleObserver subframe_observer(shell()->web_contents(), | |
837 blocked_subframe_url); | |
838 | |
839 ASSERT_TRUE(NavigateToURL(shell(), main_url)); | |
840 EXPECT_TRUE(subframe_observer.is_error()); | |
841 EXPECT_TRUE(IsChildFrameCollapsed(shell(), kChildFrameId)); | |
842 } | |
843 | |
844 { | |
845 SCOPED_TRACE("Subsequent subframe navigation is allowed."); | |
846 NavigationHandleObserver subframe_observer(shell()->web_contents(), | |
847 allowed_subframe_url); | |
848 | |
849 ASSERT_TRUE(NavigateIframeToURL(shell()->web_contents(), kChildFrameId, | |
850 allowed_subframe_url)); | |
851 EXPECT_TRUE(subframe_observer.has_committed()); | |
852 EXPECT_FALSE(subframe_observer.is_error()); | |
853 EXPECT_EQ(allowed_subframe_final_url, | |
854 subframe_observer.last_committed_url()); | |
855 EXPECT_FALSE(IsChildFrameCollapsed(shell(), kChildFrameId)); | |
856 } | |
857 | |
858 { | |
859 SCOPED_TRACE("Subsequent subframe navigation is blocked."); | |
860 NavigationHandleObserver subframe_observer(shell()->web_contents(), | |
861 blocked_subframe_url); | |
862 | |
863 ASSERT_TRUE(NavigateIframeToURL(shell()->web_contents(), kChildFrameId, | |
864 blocked_subframe_url)); | |
865 | |
866 EXPECT_TRUE(subframe_observer.is_error()); | |
867 EXPECT_TRUE(IsChildFrameCollapsed(shell(), kChildFrameId)); | |
868 } | |
869 } | |
870 } | |
871 } | |
872 | |
717 // Checks that the RequestContextType value is properly set. | 873 // Checks that the RequestContextType value is properly set. |
718 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, | 874 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, |
719 VerifyRequestContextTypeForFrameTree) { | 875 VerifyRequestContextTypeForFrameTree) { |
720 GURL main_url(embedded_test_server()->GetURL( | 876 GURL main_url(embedded_test_server()->GetURL( |
721 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); | 877 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); |
722 GURL b_url(embedded_test_server()->GetURL( | 878 GURL b_url(embedded_test_server()->GetURL( |
723 "b.com", "/cross_site_iframe_factory.html?b(c())")); | 879 "b.com", "/cross_site_iframe_factory.html?b(c())")); |
724 GURL c_url(embedded_test_server()->GetURL( | 880 GURL c_url(embedded_test_server()->GetURL( |
725 "c.com", "/cross_site_iframe_factory.html?c()")); | 881 "c.com", "/cross_site_iframe_factory.html?c()")); |
726 | 882 |
727 TestNavigationThrottleInstaller installer( | 883 TestNavigationThrottleInstaller installer( |
728 shell()->web_contents(), NavigationThrottle::PROCEED, | 884 shell()->web_contents(), NavigationThrottle::PROCEED, |
729 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); | 885 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); |
730 TestNavigationManager main_manager(shell()->web_contents(), main_url); | 886 TestNavigationManager main_manager(shell()->web_contents(), main_url); |
731 TestNavigationManager b_manager(shell()->web_contents(), b_url); | 887 TestNavigationManager b_manager(shell()->web_contents(), b_url); |
732 TestNavigationManager c_manager(shell()->web_contents(), c_url); | 888 TestNavigationManager c_manager(shell()->web_contents(), c_url); |
733 NavigationStartUrlRecorder url_recorder(shell()->web_contents()); | 889 NavigationStartUrlRecorder url_recorder(shell()->web_contents()); |
734 TestNavigationThrottle* previous_throttle = nullptr; | 890 TestNavigationThrottle* previous_throttle = nullptr; |
735 | 891 |
736 // Starts and verifies the main frame navigation. | 892 // Starts and verifies the main frame navigation. |
737 shell()->LoadURL(main_url); | 893 shell()->LoadURL(main_url); |
738 EXPECT_TRUE(main_manager.WaitForRequestStart()); | 894 EXPECT_TRUE(main_manager.WaitForRequestStart()); |
739 // The throttle should not be null. | 895 // The throttle should not be null. |
740 EXPECT_NE(previous_throttle, installer.navigation_throttle()); | 896 EXPECT_NE(previous_throttle, installer.navigation_throttle()); |
741 // Checks the only URL recorded so far is the one expected for the main frame. | 897 // Checks the only URL recorded so far is the one expected for the main |
898 // frame. | |
nasko
2017/01/20 23:34:36
Why this change in comment? git cl format?
| |
742 EXPECT_EQ(main_url, url_recorder.urls().back()); | 899 EXPECT_EQ(main_url, url_recorder.urls().back()); |
743 EXPECT_EQ(1ul, url_recorder.urls().size()); | 900 EXPECT_EQ(1ul, url_recorder.urls().size()); |
744 // Checks the main frame RequestContextType. | 901 // Checks the main frame RequestContextType. |
745 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION, | 902 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION, |
746 installer.navigation_throttle()->request_context_type()); | 903 installer.navigation_throttle()->request_context_type()); |
747 // For each navigations the throttle should be a different instance. | 904 // For each navigations the throttle should be a different instance. |
748 previous_throttle = installer.navigation_throttle(); | 905 previous_throttle = installer.navigation_throttle(); |
749 | 906 |
750 // Ditto for frame b navigation. | 907 // Ditto for frame b navigation. |
751 main_manager.WaitForNavigationFinished(); | 908 main_manager.WaitForNavigationFinished(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
898 IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest, | 1055 IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest, |
899 StartUrlIsHttpsUpgradedCrossSite) { | 1056 StartUrlIsHttpsUpgradedCrossSite) { |
900 GURL start_url( | 1057 GURL start_url( |
901 embedded_test_server()->GetURL("/https_upgrade_cross_site.html")); | 1058 embedded_test_server()->GetURL("/https_upgrade_cross_site.html")); |
902 GURL cross_site_iframe_secure_url("https://other.com/title1.html"); | 1059 GURL cross_site_iframe_secure_url("https://other.com/title1.html"); |
903 | 1060 |
904 CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url); | 1061 CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url); |
905 } | 1062 } |
906 | 1063 |
907 } // namespace content | 1064 } // namespace content |
OLD | NEW |