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

Unified Diff: content/browser/cross_site_transfer_browsertest.cc

Issue 2004653002: OpenURL post data handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@post-data-my-stuff
Patch Set: Self-review. 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/cross_site_transfer_browsertest.cc
diff --git a/content/browser/cross_site_transfer_browsertest.cc b/content/browser/cross_site_transfer_browsertest.cc
index 658519c3451954db5fa44b26eafb065b1ad473c8..953236870423a56e63d3642613b70603871a1eef 100644
--- a/content/browser/cross_site_transfer_browsertest.cc
+++ b/content/browser/cross_site_transfer_browsertest.cc
@@ -7,9 +7,11 @@
#include "base/strings/stringprintf.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_dispatcher_host_delegate.h"
#include "content/public/browser/resource_throttle.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/renderer_preferences.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
@@ -418,4 +420,40 @@ IN_PROC_BROWSER_TEST_F(CrossSiteTransferTest, NoLeakOnCrossSiteCancel) {
shell()->web_contents()->SetDelegate(old_delegate);
}
+// Tests that POST body is not lost when decidePolicyForNavigation tells the
+// renderer to route the request via FrameHostMsg_OpenURL sent to the browser.
+// See also https://crbug.com/344348.
+IN_PROC_BROWSER_TEST_F(CrossSiteTransferTest, PostViaOpenUrlMsg) {
Charlie Reis 2016/06/09 22:59:42 I think this might not belong in CrossSiteTransfer
Łukasz Anforowicz 2016/06/10 19:53:51 Done.
+ GURL main_url(
+ embedded_test_server()->GetURL("/form_that_posts_to_echoall.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+
+ // Ask the renderer to go through OpenURL FrameHostMsg_OpenURL IPC message.
+ // Without this, the test wouldn't repro https://crbug.com/344348.
+ shell()
+ ->web_contents()
+ ->GetMutableRendererPrefs()
+ ->browser_handles_all_top_level_requests = true;
+ shell()->web_contents()->GetRenderViewHost()->SyncRendererPrefs();
+
+ // Submit the form.
+ TestNavigationObserver form_post_observer(shell()->web_contents(), 1);
+ EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
+ "document.getElementById('form').submit();"));
+ form_post_observer.Wait();
+
+ // Verify that we arrived at the expected, redirected location.
Charlie Reis 2016/06/09 22:59:42 What do you mean by redirected? I don't see any r
Łukasz Anforowicz 2016/06/10 19:53:51 My fault - I've incorrectly copy&paste parts of th
+ GURL target_url(embedded_test_server()->GetURL("/echoall"));
+ EXPECT_EQ(target_url, shell()->web_contents()->GetLastCommittedURL());
+
+ // Verify that POST body was correctly passed to the server.
Charlie Reis 2016/06/09 22:59:42 nit: ...and ended up in the body of the page.
Łukasz Anforowicz 2016/06/10 19:53:51 Done.
+ std::string body;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ shell()->web_contents(),
+ "window.domAutomationController.send("
+ "document.getElementsByTagName('pre')[0].innerText);",
+ &body));
+ EXPECT_EQ("text=value\n", body);
+}
+
} // namespace content
« no previous file with comments | « no previous file | content/browser/frame_host/navigator.h » ('j') | content/browser/frame_host/render_frame_proxy_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698