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 "base/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
6 #include "content/browser/frame_host/navigation_handle_impl.h" | 6 #include "content/browser/frame_host/navigation_handle_impl.h" |
7 #include "content/browser/web_contents/web_contents_impl.h" | 7 #include "content/browser/web_contents/web_contents_impl.h" |
8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
9 #include "content/public/browser/web_contents_observer.h" | 9 #include "content/public/browser/web_contents_observer.h" |
10 #include "content/public/common/browser_side_navigation_policy.h" | 10 #include "content/public/common/browser_side_navigation_policy.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 : NavigationThrottle(handle), | 133 : NavigationThrottle(handle), |
134 will_start_result_(will_start_result), | 134 will_start_result_(will_start_result), |
135 will_redirect_result_(will_redirect_result), | 135 will_redirect_result_(will_redirect_result), |
136 will_process_result_(will_process_result), | 136 will_process_result_(will_process_result), |
137 did_call_will_start_(did_call_will_start), | 137 did_call_will_start_(did_call_will_start), |
138 did_call_will_redirect_(did_call_will_redirect), | 138 did_call_will_redirect_(did_call_will_redirect), |
139 did_call_will_process_(did_call_will_process) {} | 139 did_call_will_process_(did_call_will_process) {} |
140 ~TestNavigationThrottle() override {} | 140 ~TestNavigationThrottle() override {} |
141 | 141 |
142 void Resume() { navigation_handle()->Resume(); } | 142 void Resume() { navigation_handle()->Resume(); } |
| 143 void Cancel(NavigationThrottle::ThrottleCheckResult result) { |
| 144 navigation_handle()->CancelDeferredNavigation(result); |
| 145 } |
143 | 146 |
144 RequestContextType request_context_type() { return request_context_type_; } | 147 RequestContextType request_context_type() { return request_context_type_; } |
145 | 148 |
146 private: | 149 private: |
147 // NavigationThrottle implementation. | 150 // NavigationThrottle implementation. |
148 NavigationThrottle::ThrottleCheckResult WillStartRequest() override { | 151 NavigationThrottle::ThrottleCheckResult WillStartRequest() override { |
149 NavigationHandleImpl* navigation_handle_impl = | 152 NavigationHandleImpl* navigation_handle_impl = |
150 static_cast<NavigationHandleImpl*>(navigation_handle()); | 153 static_cast<NavigationHandleImpl*>(navigation_handle()); |
151 CHECK_NE(REQUEST_CONTEXT_TYPE_UNSPECIFIED, | 154 CHECK_NE(REQUEST_CONTEXT_TYPE_UNSPECIFIED, |
152 navigation_handle_impl->request_context_type()); | 155 navigation_handle_impl->request_context_type()); |
(...skipping 27 matching lines...) Expand all Loading... |
180 | 183 |
181 NavigationThrottle::ThrottleCheckResult will_start_result_; | 184 NavigationThrottle::ThrottleCheckResult will_start_result_; |
182 NavigationThrottle::ThrottleCheckResult will_redirect_result_; | 185 NavigationThrottle::ThrottleCheckResult will_redirect_result_; |
183 NavigationThrottle::ThrottleCheckResult will_process_result_; | 186 NavigationThrottle::ThrottleCheckResult will_process_result_; |
184 base::Closure did_call_will_start_; | 187 base::Closure did_call_will_start_; |
185 base::Closure did_call_will_redirect_; | 188 base::Closure did_call_will_redirect_; |
186 base::Closure did_call_will_process_; | 189 base::Closure did_call_will_process_; |
187 RequestContextType request_context_type_ = REQUEST_CONTEXT_TYPE_UNSPECIFIED; | 190 RequestContextType request_context_type_ = REQUEST_CONTEXT_TYPE_UNSPECIFIED; |
188 }; | 191 }; |
189 | 192 |
190 // Install a TestNavigationThrottle on all following requests and allows waiting | 193 // Installs a TestNavigationThrottle either on all following requests or on |
191 // for various NavigationThrottle related events. Waiting works only for the | 194 // requests with an expected starting URL, and allows waiting for various |
192 // immediately next navigation. New instances are needed to wait for further | 195 // NavigationThrottle related events. Waiting works only for the immediately |
193 // navigations. | 196 // next navigation. New instances are needed to wait for further navigations. |
194 class TestNavigationThrottleInstaller : public WebContentsObserver { | 197 class TestNavigationThrottleInstaller : public WebContentsObserver { |
195 public: | 198 public: |
196 TestNavigationThrottleInstaller( | 199 TestNavigationThrottleInstaller( |
197 WebContents* web_contents, | 200 WebContents* web_contents, |
198 NavigationThrottle::ThrottleCheckResult will_start_result, | 201 NavigationThrottle::ThrottleCheckResult will_start_result, |
199 NavigationThrottle::ThrottleCheckResult will_redirect_result, | 202 NavigationThrottle::ThrottleCheckResult will_redirect_result, |
200 NavigationThrottle::ThrottleCheckResult will_process_result) | 203 NavigationThrottle::ThrottleCheckResult will_process_result, |
| 204 const GURL& expected_start_url = GURL()) |
201 : WebContentsObserver(web_contents), | 205 : WebContentsObserver(web_contents), |
202 will_start_result_(will_start_result), | 206 will_start_result_(will_start_result), |
203 will_redirect_result_(will_redirect_result), | 207 will_redirect_result_(will_redirect_result), |
204 will_process_result_(will_process_result), | 208 will_process_result_(will_process_result), |
| 209 expected_start_url_(expected_start_url), |
205 weak_factory_(this) {} | 210 weak_factory_(this) {} |
206 ~TestNavigationThrottleInstaller() override {} | 211 ~TestNavigationThrottleInstaller() override {} |
207 | 212 |
208 TestNavigationThrottle* navigation_throttle() { return navigation_throttle_; } | 213 TestNavigationThrottle* navigation_throttle() { return navigation_throttle_; } |
209 | 214 |
210 void WaitForThrottleWillStart() { | 215 void WaitForThrottleWillStart() { |
211 if (will_start_called_) | 216 if (will_start_called_) |
212 return; | 217 return; |
213 will_start_loop_runner_ = new MessageLoopRunner(); | 218 will_start_loop_runner_ = new MessageLoopRunner(); |
214 will_start_loop_runner_->Run(); | 219 will_start_loop_runner_->Run(); |
215 will_start_loop_runner_ = nullptr; | 220 will_start_loop_runner_ = nullptr; |
216 } | 221 } |
217 | 222 |
218 void WaitForThrottleWillRedirect() { | 223 void WaitForThrottleWillRedirect() { |
219 if (will_redirect_called_) | 224 if (will_redirect_called_) |
220 return; | 225 return; |
221 will_redirect_loop_runner_ = new MessageLoopRunner(); | 226 will_redirect_loop_runner_ = new MessageLoopRunner(); |
222 will_redirect_loop_runner_->Run(); | 227 will_redirect_loop_runner_->Run(); |
223 will_redirect_loop_runner_ = nullptr; | 228 will_redirect_loop_runner_ = nullptr; |
224 } | 229 } |
225 | 230 |
226 void WaitForThrottleWillProcess() { | 231 void WaitForThrottleWillProcess() { |
227 if (will_process_called_) | 232 if (will_process_called_) |
228 return; | 233 return; |
229 will_process_loop_runner_ = new MessageLoopRunner(); | 234 will_process_loop_runner_ = new MessageLoopRunner(); |
230 will_process_loop_runner_->Run(); | 235 will_process_loop_runner_->Run(); |
231 will_process_loop_runner_ = nullptr; | 236 will_process_loop_runner_ = nullptr; |
232 } | 237 } |
233 | 238 |
| 239 void Continue(NavigationThrottle::ThrottleCheckResult result) { |
| 240 ASSERT_NE(NavigationThrottle::DEFER, result); |
| 241 if (result == NavigationThrottle::PROCEED) |
| 242 navigation_throttle()->Resume(); |
| 243 else |
| 244 navigation_throttle()->Cancel(result); |
| 245 } |
| 246 |
234 int will_start_called() { return will_start_called_; } | 247 int will_start_called() { return will_start_called_; } |
235 int will_redirect_called() { return will_redirect_called_; } | 248 int will_redirect_called() { return will_redirect_called_; } |
236 int will_process_called() { return will_process_called_; } | 249 int will_process_called() { return will_process_called_; } |
237 | 250 |
238 int install_count() { return install_count_; } | 251 int install_count() { return install_count_; } |
239 | 252 |
| 253 protected: |
| 254 virtual void DidCallWillStartRequest() { |
| 255 will_start_called_++; |
| 256 if (will_start_loop_runner_) |
| 257 will_start_loop_runner_->Quit(); |
| 258 } |
| 259 |
| 260 virtual void DidCallWillRedirectRequest() { |
| 261 will_redirect_called_++; |
| 262 if (will_redirect_loop_runner_) |
| 263 will_redirect_loop_runner_->Quit(); |
| 264 } |
| 265 |
| 266 virtual void DidCallWillProcessResponse() { |
| 267 will_process_called_++; |
| 268 if (will_process_loop_runner_) |
| 269 will_process_loop_runner_->Quit(); |
| 270 } |
| 271 |
240 private: | 272 private: |
241 void DidStartNavigation(NavigationHandle* handle) override { | 273 void DidStartNavigation(NavigationHandle* handle) override { |
| 274 if (!expected_start_url_.is_empty() && |
| 275 handle->GetURL() != expected_start_url_) |
| 276 return; |
| 277 |
242 std::unique_ptr<NavigationThrottle> throttle(new TestNavigationThrottle( | 278 std::unique_ptr<NavigationThrottle> throttle(new TestNavigationThrottle( |
243 handle, will_start_result_, will_redirect_result_, will_process_result_, | 279 handle, will_start_result_, will_redirect_result_, will_process_result_, |
244 base::Bind(&TestNavigationThrottleInstaller::DidCallWillStartRequest, | 280 base::Bind(&TestNavigationThrottleInstaller::DidCallWillStartRequest, |
245 weak_factory_.GetWeakPtr()), | 281 weak_factory_.GetWeakPtr()), |
246 base::Bind(&TestNavigationThrottleInstaller::DidCallWillRedirectRequest, | 282 base::Bind(&TestNavigationThrottleInstaller::DidCallWillRedirectRequest, |
247 weak_factory_.GetWeakPtr()), | 283 weak_factory_.GetWeakPtr()), |
248 base::Bind(&TestNavigationThrottleInstaller::DidCallWillProcessResponse, | 284 base::Bind(&TestNavigationThrottleInstaller::DidCallWillProcessResponse, |
249 weak_factory_.GetWeakPtr()))); | 285 weak_factory_.GetWeakPtr()))); |
250 navigation_throttle_ = static_cast<TestNavigationThrottle*>(throttle.get()); | 286 navigation_throttle_ = static_cast<TestNavigationThrottle*>(throttle.get()); |
251 handle->RegisterThrottleForTesting(std::move(throttle)); | 287 handle->RegisterThrottleForTesting(std::move(throttle)); |
252 ++install_count_; | 288 ++install_count_; |
253 } | 289 } |
254 | 290 |
255 void DidFinishNavigation(NavigationHandle* handle) override { | 291 void DidFinishNavigation(NavigationHandle* handle) override { |
256 if (!navigation_throttle_) | 292 if (!navigation_throttle_) |
257 return; | 293 return; |
258 | 294 |
259 if (handle == navigation_throttle_->navigation_handle()) | 295 if (handle == navigation_throttle_->navigation_handle()) |
260 navigation_throttle_ = nullptr; | 296 navigation_throttle_ = nullptr; |
261 } | 297 } |
262 | 298 |
263 void DidCallWillStartRequest() { | |
264 will_start_called_++; | |
265 if (will_start_loop_runner_) | |
266 will_start_loop_runner_->Quit(); | |
267 } | |
268 | |
269 void DidCallWillRedirectRequest() { | |
270 will_redirect_called_++; | |
271 if (will_redirect_loop_runner_) | |
272 will_redirect_loop_runner_->Quit(); | |
273 } | |
274 | |
275 void DidCallWillProcessResponse() { | |
276 will_process_called_++; | |
277 if (will_process_loop_runner_) | |
278 will_process_loop_runner_->Quit(); | |
279 } | |
280 | |
281 NavigationThrottle::ThrottleCheckResult will_start_result_; | 299 NavigationThrottle::ThrottleCheckResult will_start_result_; |
282 NavigationThrottle::ThrottleCheckResult will_redirect_result_; | 300 NavigationThrottle::ThrottleCheckResult will_redirect_result_; |
283 NavigationThrottle::ThrottleCheckResult will_process_result_; | 301 NavigationThrottle::ThrottleCheckResult will_process_result_; |
284 int will_start_called_ = 0; | 302 int will_start_called_ = 0; |
285 int will_redirect_called_ = 0; | 303 int will_redirect_called_ = 0; |
286 int will_process_called_ = 0; | 304 int will_process_called_ = 0; |
287 TestNavigationThrottle* navigation_throttle_ = nullptr; | 305 TestNavigationThrottle* navigation_throttle_ = nullptr; |
288 int install_count_ = 0; | 306 int install_count_ = 0; |
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_; |
292 | 311 |
293 // The throttle installer can be deleted before all tasks posted by its | 312 // The throttle installer can be deleted before all tasks posted by its |
294 // throttles are run, so it must be referenced via weak pointers. | 313 // throttles are run, so it must be referenced via weak pointers. |
295 base::WeakPtrFactory<TestNavigationThrottleInstaller> weak_factory_; | 314 base::WeakPtrFactory<TestNavigationThrottleInstaller> weak_factory_; |
296 }; | 315 }; |
297 | 316 |
| 317 // Same as above, but installs NavigationThrottles that do not directly return |
| 318 // the pre-programmed check results, but first DEFER the navigation at each |
| 319 // stage and then resume/cancel asynchronously. |
| 320 class TestDeferringNavigationThrottleInstaller |
| 321 : public TestNavigationThrottleInstaller { |
| 322 public: |
| 323 TestDeferringNavigationThrottleInstaller( |
| 324 WebContents* web_contents, |
| 325 NavigationThrottle::ThrottleCheckResult will_start_result, |
| 326 NavigationThrottle::ThrottleCheckResult will_redirect_result, |
| 327 NavigationThrottle::ThrottleCheckResult will_process_result, |
| 328 GURL expected_start_url = GURL()) |
| 329 : TestNavigationThrottleInstaller(web_contents, |
| 330 NavigationThrottle::DEFER, |
| 331 NavigationThrottle::DEFER, |
| 332 NavigationThrottle::DEFER, |
| 333 expected_start_url), |
| 334 will_start_deferred_result_(will_start_result), |
| 335 will_redirect_deferred_result_(will_redirect_result), |
| 336 will_process_deferred_result_(will_process_result) {} |
| 337 |
| 338 protected: |
| 339 void DidCallWillStartRequest() override { |
| 340 TestNavigationThrottleInstaller::DidCallWillStartRequest(); |
| 341 Continue(will_start_deferred_result_); |
| 342 } |
| 343 |
| 344 void DidCallWillRedirectRequest() override { |
| 345 TestNavigationThrottleInstaller::DidCallWillStartRequest(); |
| 346 Continue(will_redirect_deferred_result_); |
| 347 } |
| 348 |
| 349 void DidCallWillProcessResponse() override { |
| 350 TestNavigationThrottleInstaller::DidCallWillStartRequest(); |
| 351 Continue(will_process_deferred_result_); |
| 352 } |
| 353 |
| 354 private: |
| 355 NavigationThrottle::ThrottleCheckResult will_start_deferred_result_; |
| 356 NavigationThrottle::ThrottleCheckResult will_redirect_deferred_result_; |
| 357 NavigationThrottle::ThrottleCheckResult will_process_deferred_result_; |
| 358 }; |
| 359 |
298 // Records all navigation start URLs from the WebContents. | 360 // Records all navigation start URLs from the WebContents. |
299 class NavigationStartUrlRecorder : public WebContentsObserver { | 361 class NavigationStartUrlRecorder : public WebContentsObserver { |
300 public: | 362 public: |
301 NavigationStartUrlRecorder(WebContents* web_contents) | 363 NavigationStartUrlRecorder(WebContents* web_contents) |
302 : WebContentsObserver(web_contents) {} | 364 : WebContentsObserver(web_contents) {} |
303 | 365 |
304 void DidStartNavigation(NavigationHandle* navigation_handle) override { | 366 void DidStartNavigation(NavigationHandle* navigation_handle) override { |
305 urls_.push_back(navigation_handle->GetURL()); | 367 urls_.push_back(navigation_handle->GetURL()); |
306 } | 368 } |
307 | 369 |
308 const std::vector<GURL>& urls() const { return urls_; } | 370 const std::vector<GURL>& urls() const { return urls_; } |
309 | 371 |
310 private: | 372 private: |
311 std::vector<GURL> urls_; | 373 std::vector<GURL> urls_; |
312 }; | 374 }; |
313 | 375 |
| 376 void ExpectChildFrameCollapsed(Shell* shell, |
| 377 const std::string& frame_id, |
| 378 bool expect_collapsed) { |
| 379 // Check if the frame should be collapsed in theory as per FTN. |
| 380 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) |
| 381 ->GetFrameTree() |
| 382 ->root(); |
| 383 ASSERT_EQ(1u, root->child_count()); |
| 384 FrameTreeNode* child = root->child_at(0u); |
| 385 EXPECT_EQ(expect_collapsed, child->is_collapsed()); |
| 386 |
| 387 // Check if the frame is collapsed in practice. |
| 388 const char kScript[] = |
| 389 "window.domAutomationController.send(" |
| 390 " document.getElementById(\"%s\").clientWidth" |
| 391 ");"; |
| 392 int client_width = 0; |
| 393 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
| 394 shell, base::StringPrintf(kScript, frame_id.c_str()), &client_width)); |
| 395 EXPECT_EQ(expect_collapsed, !client_width) << client_width; |
| 396 } |
| 397 |
314 } // namespace | 398 } // namespace |
315 | 399 |
316 class NavigationHandleImplBrowserTest : public ContentBrowserTest { | 400 class NavigationHandleImplBrowserTest : public ContentBrowserTest { |
317 protected: | 401 protected: |
318 void SetUpOnMainThread() override { | 402 void SetUpOnMainThread() override { |
319 host_resolver()->AddRule("*", "127.0.0.1"); | 403 host_resolver()->AddRule("*", "127.0.0.1"); |
320 SetupCrossSiteRedirector(embedded_test_server()); | 404 SetupCrossSiteRedirector(embedded_test_server()); |
321 ASSERT_TRUE(embedded_test_server()->Start()); | 405 ASSERT_TRUE(embedded_test_server()->Start()); |
322 } | 406 } |
323 }; | 407 }; |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 // Wait for the end of the navigation. | 796 // Wait for the end of the navigation. |
713 navigation_observer.Wait(); | 797 navigation_observer.Wait(); |
714 | 798 |
715 EXPECT_TRUE(observer.has_committed()); | 799 EXPECT_TRUE(observer.has_committed()); |
716 EXPECT_TRUE(observer.was_redirected()); | 800 EXPECT_TRUE(observer.was_redirected()); |
717 EXPECT_FALSE(observer.is_error()); | 801 EXPECT_FALSE(observer.is_error()); |
718 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), | 802 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), |
719 GURL(embedded_test_server()->GetURL("bar.com", "/title2.html"))); | 803 GURL(embedded_test_server()->GetURL("bar.com", "/title2.html"))); |
720 } | 804 } |
721 | 805 |
| 806 // Ensure that a NavigationThrottle can block the navigation and collapse the |
| 807 // frame owner both on request start as well as after a redirect. Plus, ensure |
| 808 // that the frame is restored on the subsequent non-error-page navigation. |
| 809 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, |
| 810 ThrottleBlockAndCollapse) { |
| 811 const char kChildFrameId[] = "child0"; |
| 812 GURL main_url(embedded_test_server()->GetURL( |
| 813 "a.com", "/frame_tree/page_with_one_frame.html")); |
| 814 GURL blocked_subframe_url(embedded_test_server()->GetURL( |
| 815 "a.com", "/cross-site/baz.com/title1.html")); |
| 816 GURL allowed_subframe_url(embedded_test_server()->GetURL( |
| 817 "a.com", "/cross-site/baz.com/title2.html")); |
| 818 GURL allowed_subframe_final_url( |
| 819 embedded_test_server()->GetURL("baz.com", "/title2.html")); |
| 820 |
| 821 // Exercise both synchronous and deferred throttle check results, and both on |
| 822 // WillStartRequest and on WillRedirectRequest. |
| 823 const struct { |
| 824 NavigationThrottle::ThrottleCheckResult will_start_result; |
| 825 NavigationThrottle::ThrottleCheckResult will_redirect_result; |
| 826 bool deferred_block; |
| 827 } kTestCases[] = { |
| 828 {NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE, |
| 829 NavigationThrottle::PROCEED, false}, |
| 830 {NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE, |
| 831 NavigationThrottle::PROCEED, true}, |
| 832 {NavigationThrottle::PROCEED, |
| 833 NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE, false}, |
| 834 {NavigationThrottle::PROCEED, |
| 835 NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE, true}, |
| 836 }; |
| 837 |
| 838 for (const auto& test_case : kTestCases) { |
| 839 SCOPED_TRACE(::testing::Message() << test_case.will_start_result << ", " |
| 840 << test_case.will_redirect_result << ", " |
| 841 << test_case.deferred_block); |
| 842 |
| 843 if (!IsBrowserSideNavigationEnabled() && |
| 844 test_case.will_redirect_result == |
| 845 NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) { |
| 846 continue; |
| 847 } |
| 848 |
| 849 std::unique_ptr<TestNavigationThrottleInstaller> |
| 850 subframe_throttle_installer; |
| 851 if (test_case.deferred_block) { |
| 852 subframe_throttle_installer.reset( |
| 853 new TestDeferringNavigationThrottleInstaller( |
| 854 shell()->web_contents(), test_case.will_start_result, |
| 855 test_case.will_redirect_result, NavigationThrottle::PROCEED, |
| 856 blocked_subframe_url)); |
| 857 } else { |
| 858 subframe_throttle_installer.reset(new TestNavigationThrottleInstaller( |
| 859 shell()->web_contents(), test_case.will_start_result, |
| 860 test_case.will_redirect_result, NavigationThrottle::PROCEED, |
| 861 blocked_subframe_url)); |
| 862 } |
| 863 |
| 864 { |
| 865 SCOPED_TRACE("Initial navigation blocked on main frame load."); |
| 866 NavigationHandleObserver subframe_observer(shell()->web_contents(), |
| 867 blocked_subframe_url); |
| 868 |
| 869 ASSERT_TRUE(NavigateToURL(shell(), main_url)); |
| 870 EXPECT_TRUE(subframe_observer.is_error()); |
| 871 EXPECT_TRUE(subframe_observer.has_committed()); |
| 872 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, subframe_observer.net_error_code()); |
| 873 ExpectChildFrameCollapsed(shell(), kChildFrameId, |
| 874 true /* expect_collapsed */); |
| 875 } |
| 876 |
| 877 { |
| 878 SCOPED_TRACE("Subsequent subframe navigation is allowed."); |
| 879 NavigationHandleObserver subframe_observer(shell()->web_contents(), |
| 880 allowed_subframe_url); |
| 881 |
| 882 ASSERT_TRUE(NavigateIframeToURL(shell()->web_contents(), kChildFrameId, |
| 883 allowed_subframe_url)); |
| 884 EXPECT_TRUE(subframe_observer.has_committed()); |
| 885 EXPECT_FALSE(subframe_observer.is_error()); |
| 886 EXPECT_EQ(allowed_subframe_final_url, |
| 887 subframe_observer.last_committed_url()); |
| 888 ExpectChildFrameCollapsed(shell(), kChildFrameId, |
| 889 false /* expect_collapsed */); |
| 890 } |
| 891 |
| 892 { |
| 893 SCOPED_TRACE("Subsequent subframe navigation is blocked."); |
| 894 NavigationHandleObserver subframe_observer(shell()->web_contents(), |
| 895 blocked_subframe_url); |
| 896 |
| 897 ASSERT_TRUE(NavigateIframeToURL(shell()->web_contents(), kChildFrameId, |
| 898 blocked_subframe_url)); |
| 899 |
| 900 EXPECT_TRUE(subframe_observer.has_committed()); |
| 901 EXPECT_TRUE(subframe_observer.is_error()); |
| 902 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, subframe_observer.net_error_code()); |
| 903 ExpectChildFrameCollapsed(shell(), kChildFrameId, |
| 904 true /* expect_collapsed */); |
| 905 } |
| 906 } |
| 907 } |
| 908 |
722 // Checks that the RequestContextType value is properly set. | 909 // Checks that the RequestContextType value is properly set. |
723 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, | 910 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, |
724 VerifyRequestContextTypeForFrameTree) { | 911 VerifyRequestContextTypeForFrameTree) { |
725 GURL main_url(embedded_test_server()->GetURL( | 912 GURL main_url(embedded_test_server()->GetURL( |
726 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); | 913 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); |
727 GURL b_url(embedded_test_server()->GetURL( | 914 GURL b_url(embedded_test_server()->GetURL( |
728 "b.com", "/cross_site_iframe_factory.html?b(c())")); | 915 "b.com", "/cross_site_iframe_factory.html?b(c())")); |
729 GURL c_url(embedded_test_server()->GetURL( | 916 GURL c_url(embedded_test_server()->GetURL( |
730 "c.com", "/cross_site_iframe_factory.html?c()")); | 917 "c.com", "/cross_site_iframe_factory.html?c()")); |
731 | 918 |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 NavigationHandleObserver observer(shell()->web_contents(), error_url); | 1399 NavigationHandleObserver observer(shell()->web_contents(), error_url); |
1213 EXPECT_FALSE(NavigateToURL(shell(), error_url)); | 1400 EXPECT_FALSE(NavigateToURL(shell(), error_url)); |
1214 EXPECT_TRUE(observer.has_committed()); | 1401 EXPECT_TRUE(observer.has_committed()); |
1215 EXPECT_TRUE(observer.is_error()); | 1402 EXPECT_TRUE(observer.is_error()); |
1216 EXPECT_NE(site_instance, | 1403 EXPECT_NE(site_instance, |
1217 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); | 1404 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); |
1218 } | 1405 } |
1219 } | 1406 } |
1220 | 1407 |
1221 } // namespace content | 1408 } // namespace content |
OLD | NEW |