Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2004653002: OpenURL post data handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@post-data-my-stuff
Patch Set: Tweaked test comments to address CR feedback. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/navigator.h » ('j') | content/common/frame_messages.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 4115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4157 EXPECT_EQ("POST", frame_entry->method()); 4158 EXPECT_EQ("POST", frame_entry->method());
4158 // TODO(clamy): Check the post id as well when PlzNavigate handles it 4159 // TODO(clamy): Check the post id as well when PlzNavigate handles it
4159 // properly. 4160 // properly.
4160 if (!IsBrowserSideNavigationEnabled()) 4161 if (!IsBrowserSideNavigationEnabled())
4161 EXPECT_NE(-1, frame_entry->post_id()); 4162 EXPECT_NE(-1, frame_entry->post_id());
4162 EXPECT_FALSE(entry->GetHasPostData()); 4163 EXPECT_FALSE(entry->GetHasPostData());
4163 EXPECT_EQ(-1, entry->GetPostID()); 4164 EXPECT_EQ(-1, entry->GetPostID());
4164 } 4165 }
4165 } 4166 }
4166 4167
4168 // Tests that POST body is not lost when decidePolicyForNavigation tells the
4169 // renderer to route the request via FrameHostMsg_OpenURL sent to the browser.
4170 // See also https://crbug.com/344348.
4171 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, PostViaOpenUrlMsg) {
4172 GURL main_url(
4173 embedded_test_server()->GetURL("/form_that_posts_to_echoall.html"));
4174 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4175
4176 // Ask the renderer to go through OpenURL FrameHostMsg_OpenURL IPC message.
4177 // Without this, the test wouldn't repro https://crbug.com/344348.
4178 shell()
4179 ->web_contents()
4180 ->GetMutableRendererPrefs()
4181 ->browser_handles_all_top_level_requests = true;
4182 shell()->web_contents()->GetRenderViewHost()->SyncRendererPrefs();
4183
4184 // Submit the form.
4185 TestNavigationObserver form_post_observer(shell()->web_contents(), 1);
4186 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
4187 "document.getElementById('form').submit();"));
4188 form_post_observer.Wait();
4189
4190 // Verify that we arrived at the expected location.
4191 GURL target_url(embedded_test_server()->GetURL("/echoall"));
4192 EXPECT_EQ(target_url, shell()->web_contents()->GetLastCommittedURL());
4193
4194 // Verify that POST body was correctly passed to the server and ended up in
4195 // the body of the page.
4196 std::string body;
4197 EXPECT_TRUE(ExecuteScriptAndExtractString(
4198 shell()->web_contents(),
4199 "window.domAutomationController.send("
4200 "document.getElementsByTagName('pre')[0].innerText);",
4201 &body));
4202 EXPECT_EQ("text=value\n", body);
4203 }
4204
4167 } // namespace content 4205 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigator.h » ('j') | content/common/frame_messages.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698