OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "content/public/browser/navigation_handle.h" | 22 #include "content/public/browser/navigation_handle.h" |
23 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
24 #include "content/public/browser/resource_controller.h" | 24 #include "content/public/browser/resource_controller.h" |
25 #include "content/public/browser/resource_dispatcher_host.h" | 25 #include "content/public/browser/resource_dispatcher_host.h" |
26 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 26 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
27 #include "content/public/browser/resource_throttle.h" | 27 #include "content/public/browser/resource_throttle.h" |
28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
29 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
30 #include "content/public/common/bindings_policy.h" | 30 #include "content/public/common/bindings_policy.h" |
31 #include "content/public/common/browser_side_navigation_policy.h" | 31 #include "content/public/common/browser_side_navigation_policy.h" |
| 32 #include "content/public/common/renderer_preferences.h" |
32 #include "content/public/common/url_constants.h" | 33 #include "content/public/common/url_constants.h" |
33 #include "content/public/test/browser_test_utils.h" | 34 #include "content/public/test/browser_test_utils.h" |
34 #include "content/public/test/content_browser_test.h" | 35 #include "content/public/test/content_browser_test.h" |
35 #include "content/public/test/content_browser_test_utils.h" | 36 #include "content/public/test/content_browser_test_utils.h" |
36 #include "content/public/test/test_navigation_observer.h" | 37 #include "content/public/test/test_navigation_observer.h" |
37 #include "content/public/test/test_utils.h" | 38 #include "content/public/test/test_utils.h" |
38 #include "content/shell/browser/shell.h" | 39 #include "content/shell/browser/shell.h" |
39 #include "content/shell/common/shell_switches.h" | 40 #include "content/shell/common/shell_switches.h" |
40 #include "content/test/content_browser_test_utils_internal.h" | 41 #include "content/test/content_browser_test_utils_internal.h" |
41 #include "content/test/test_frame_navigation_observer.h" | 42 #include "content/test/test_frame_navigation_observer.h" |
(...skipping 4529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4571 EXPECT_EQ("POST", frame_entry->method()); | 4572 EXPECT_EQ("POST", frame_entry->method()); |
4572 // TODO(clamy): Check the post id as well when PlzNavigate handles it | 4573 // TODO(clamy): Check the post id as well when PlzNavigate handles it |
4573 // properly. | 4574 // properly. |
4574 if (!IsBrowserSideNavigationEnabled()) | 4575 if (!IsBrowserSideNavigationEnabled()) |
4575 EXPECT_NE(-1, frame_entry->post_id()); | 4576 EXPECT_NE(-1, frame_entry->post_id()); |
4576 EXPECT_FALSE(entry->GetHasPostData()); | 4577 EXPECT_FALSE(entry->GetHasPostData()); |
4577 EXPECT_EQ(-1, entry->GetPostID()); | 4578 EXPECT_EQ(-1, entry->GetPostID()); |
4578 } | 4579 } |
4579 } | 4580 } |
4580 | 4581 |
| 4582 // Tests that POST body is not lost when decidePolicyForNavigation tells the |
| 4583 // renderer to route the request via FrameHostMsg_OpenURL sent to the browser. |
| 4584 // See also https://crbug.com/344348. |
| 4585 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, PostViaOpenUrlMsg) { |
| 4586 GURL main_url( |
| 4587 embedded_test_server()->GetURL("/form_that_posts_to_echoall.html")); |
| 4588 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 4589 |
| 4590 // Ask the renderer to go through OpenURL FrameHostMsg_OpenURL IPC message. |
| 4591 // Without this, the test wouldn't repro https://crbug.com/344348. |
| 4592 shell() |
| 4593 ->web_contents() |
| 4594 ->GetMutableRendererPrefs() |
| 4595 ->browser_handles_all_top_level_requests = true; |
| 4596 shell()->web_contents()->GetRenderViewHost()->SyncRendererPrefs(); |
| 4597 |
| 4598 // Submit the form. |
| 4599 TestNavigationObserver form_post_observer(shell()->web_contents(), 1); |
| 4600 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
| 4601 "document.getElementById('form').submit();")); |
| 4602 form_post_observer.Wait(); |
| 4603 |
| 4604 // Verify that we arrived at the expected location. |
| 4605 GURL target_url(embedded_test_server()->GetURL("/echoall")); |
| 4606 EXPECT_EQ(target_url, shell()->web_contents()->GetLastCommittedURL()); |
| 4607 |
| 4608 // Verify that POST body was correctly passed to the server and ended up in |
| 4609 // the body of the page. |
| 4610 std::string body; |
| 4611 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 4612 shell()->web_contents(), |
| 4613 "window.domAutomationController.send(" |
| 4614 "document.getElementsByTagName('pre')[0].innerText);", |
| 4615 &body)); |
| 4616 EXPECT_EQ("text=value\n", body); |
| 4617 } |
| 4618 |
4581 } // namespace content | 4619 } // namespace content |
OLD | NEW |