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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "content/browser/child_process_security_policy_impl.h" | 14 #include "content/browser/child_process_security_policy_impl.h" |
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 15 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
16 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/navigation_handle.h" |
17 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 19 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
19 #include "content/public/browser/resource_throttle.h" | 20 #include "content/public/browser/resource_throttle.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
22 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
23 #include "content/public/test/content_browser_test.h" | 24 #include "content/public/test/content_browser_test.h" |
24 #include "content/public/test/content_browser_test_utils.h" | 25 #include "content/public/test/content_browser_test_utils.h" |
| 26 #include "content/public/test/navigation_handle_observer.h" |
25 #include "content/public/test/test_navigation_observer.h" | 27 #include "content/public/test/test_navigation_observer.h" |
26 #include "content/shell/browser/shell.h" | 28 #include "content/shell/browser/shell.h" |
27 #include "content/shell/browser/shell_content_browser_client.h" | 29 #include "content/shell/browser/shell_content_browser_client.h" |
28 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 30 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
29 #include "content/test/content_browser_test_utils_internal.h" | 31 #include "content/test/content_browser_test_utils_internal.h" |
30 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
31 #include "net/dns/mock_host_resolver.h" | 33 #include "net/dns/mock_host_resolver.h" |
32 #include "net/test/embedded_test_server/embedded_test_server.h" | 34 #include "net/test/embedded_test_server/embedded_test_server.h" |
33 #include "net/url_request/url_request.h" | 35 #include "net/url_request/url_request.h" |
34 #include "net/url_request/url_request_status.h" | 36 #include "net/url_request/url_request_status.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Navigate to a page on A.com with entry replacement. This navigation is | 423 // Navigate to a page on A.com with entry replacement. This navigation is |
422 // cross-site, so the renderer will send it to the browser via OpenURL to give | 424 // cross-site, so the renderer will send it to the browser via OpenURL to give |
423 // to a new process. It will then be transferred into yet another process due | 425 // to a new process. It will then be transferred into yet another process due |
424 // to the call above. | 426 // to the call above. |
425 GURL url2 = | 427 GURL url2 = |
426 embedded_test_server()->GetURL("A.com", "/site_isolation/blank.html?2"); | 428 embedded_test_server()->GetURL("A.com", "/site_isolation/blank.html?2"); |
427 // Used to make sure the second request is cancelled, and there is only one | 429 // Used to make sure the second request is cancelled, and there is only one |
428 // request for url2. | 430 // request for url2. |
429 tracking_delegate().SetTrackedURL(url2); | 431 tracking_delegate().SetTrackedURL(url2); |
430 | 432 |
| 433 NavigationHandleObserver handle_observer(shell()->web_contents(), url2); |
431 // Don't wait for the navigation to complete, since that never happens in | 434 // Don't wait for the navigation to complete, since that never happens in |
432 // this case. | 435 // this case. |
433 NavigateToURLContentInitiated(shell(), url2, false, false); | 436 NavigateToURLContentInitiated(shell(), url2, false, false); |
434 | 437 |
435 // There should be one history entry, with url1. | 438 // There should be one history entry, with url1. |
436 EXPECT_EQ(1, controller.GetEntryCount()); | 439 EXPECT_EQ(1, controller.GetEntryCount()); |
437 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 440 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
438 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); | 441 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); |
439 | 442 |
440 // Make sure the request for url2 did not complete. | 443 // Make sure the request for url2 did not complete. |
441 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); | 444 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); |
442 | 445 |
| 446 EXPECT_EQ(net::ERR_ABORTED, handle_observer.net_error_code()); |
443 shell()->web_contents()->SetDelegate(old_delegate); | 447 shell()->web_contents()->SetDelegate(old_delegate); |
444 } | 448 } |
445 | 449 |
446 // Test that verifies that a cross-process transfer retains ability to read | 450 // Test that verifies that a cross-process transfer retains ability to read |
447 // files encapsulated by HTTP POST body that is forwarded to the new renderer. | 451 // files encapsulated by HTTP POST body that is forwarded to the new renderer. |
448 // Invalid handling of this scenario has been suspected as the cause of at least | 452 // Invalid handling of this scenario has been suspected as the cause of at least |
449 // some of the renderer kills tracked in https://crbug.com/613260. | 453 // some of the renderer kills tracked in https://crbug.com/613260. |
450 IN_PROC_BROWSER_TEST_P(CrossSiteTransferTest, PostWithFileData) { | 454 IN_PROC_BROWSER_TEST_P(CrossSiteTransferTest, PostWithFileData) { |
451 // Navigate to the page with form that posts via 307 redirection to | 455 // Navigate to the page with form that posts via 307 redirection to |
452 // |redirect_target_url| (cross-site from |form_url|). Using 307 (rather than | 456 // |redirect_target_url| (cross-site from |form_url|). Using 307 (rather than |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 EXPECT_THAT(actual_page_body, | 514 EXPECT_THAT(actual_page_body, |
511 ::testing::HasSubstr("form-data; name=\"file\"")); | 515 ::testing::HasSubstr("form-data; name=\"file\"")); |
512 } | 516 } |
513 | 517 |
514 INSTANTIATE_TEST_CASE_P(CrossSiteTransferTest, | 518 INSTANTIATE_TEST_CASE_P(CrossSiteTransferTest, |
515 CrossSiteTransferTest, | 519 CrossSiteTransferTest, |
516 ::testing::Values(TestParameter::LOADING_WITHOUT_MOJO, | 520 ::testing::Values(TestParameter::LOADING_WITHOUT_MOJO, |
517 TestParameter::LOADING_WITH_MOJO)); | 521 TestParameter::LOADING_WITH_MOJO)); |
518 | 522 |
519 } // namespace content | 523 } // namespace content |
OLD | NEW |