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

Side by Side 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 unified diff | Download patch
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "content/browser/loader/resource_dispatcher_host_impl.h" 8 #include "content/browser/loader/resource_dispatcher_host_impl.h"
9 #include "content/public/browser/navigation_entry.h" 9 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/resource_dispatcher_host_delegate.h" 11 #include "content/public/browser/resource_dispatcher_host_delegate.h"
11 #include "content/public/browser/resource_throttle.h" 12 #include "content/public/browser/resource_throttle.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/renderer_preferences.h"
13 #include "content/public/test/browser_test_utils.h" 15 #include "content/public/test/browser_test_utils.h"
14 #include "content/public/test/content_browser_test.h" 16 #include "content/public/test/content_browser_test.h"
15 #include "content/public/test/content_browser_test_utils.h" 17 #include "content/public/test/content_browser_test_utils.h"
16 #include "content/public/test/test_navigation_observer.h" 18 #include "content/public/test/test_navigation_observer.h"
17 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
18 #include "content/shell/browser/shell_content_browser_client.h" 20 #include "content/shell/browser/shell_content_browser_client.h"
19 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" 21 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h"
20 #include "net/base/escape.h" 22 #include "net/base/escape.h"
21 #include "net/dns/mock_host_resolver.h" 23 #include "net/dns/mock_host_resolver.h"
22 #include "net/test/embedded_test_server/embedded_test_server.h" 24 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 EXPECT_EQ(1, controller.GetEntryCount()); 413 EXPECT_EQ(1, controller.GetEntryCount());
412 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 414 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
413 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); 415 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL());
414 416
415 // Make sure the request for url2 did not complete. 417 // Make sure the request for url2 did not complete.
416 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); 418 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted());
417 419
418 shell()->web_contents()->SetDelegate(old_delegate); 420 shell()->web_contents()->SetDelegate(old_delegate);
419 } 421 }
420 422
423 // Tests that POST body is not lost when decidePolicyForNavigation tells the
424 // renderer to route the request via FrameHostMsg_OpenURL sent to the browser.
425 // See also https://crbug.com/344348.
426 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.
427 GURL main_url(
428 embedded_test_server()->GetURL("/form_that_posts_to_echoall.html"));
429 EXPECT_TRUE(NavigateToURL(shell(), main_url));
430
431 // Ask the renderer to go through OpenURL FrameHostMsg_OpenURL IPC message.
432 // Without this, the test wouldn't repro https://crbug.com/344348.
433 shell()
434 ->web_contents()
435 ->GetMutableRendererPrefs()
436 ->browser_handles_all_top_level_requests = true;
437 shell()->web_contents()->GetRenderViewHost()->SyncRendererPrefs();
438
439 // Submit the form.
440 TestNavigationObserver form_post_observer(shell()->web_contents(), 1);
441 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
442 "document.getElementById('form').submit();"));
443 form_post_observer.Wait();
444
445 // 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
446 GURL target_url(embedded_test_server()->GetURL("/echoall"));
447 EXPECT_EQ(target_url, shell()->web_contents()->GetLastCommittedURL());
448
449 // 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.
450 std::string body;
451 EXPECT_TRUE(ExecuteScriptAndExtractString(
452 shell()->web_contents(),
453 "window.domAutomationController.send("
454 "document.getElementsByTagName('pre')[0].innerText);",
455 &body));
456 EXPECT_EQ("text=value\n", body);
457 }
458
421 } // namespace content 459 } // namespace content
OLDNEW
« 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