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

Side by Side Diff: chrome/browser/ui/browser_navigator_browsertest.cc

Issue 2038233002: Using ResourceRequestBody as the type of HTTP body outside of //content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@make-resource-request-body-public
Patch Set: Rebasing... 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 | « chrome/browser/ui/browser_navigator.cc ('k') | chrome/browser/ui/browser_navigator_params.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/browser_navigator_browsertest.h" 5 #include "chrome/browser/ui/browser_navigator_browsertest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 15 matching lines...) Expand all
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
29 #include "components/omnibox/browser/omnibox_view.h" 29 #include "components/omnibox/browser/omnibox_view.h"
30 #include "components/prefs/pref_service.h" 30 #include "components/prefs/pref_service.h"
31 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
32 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
33 #include "content/public/browser/render_frame_host.h" 33 #include "content/public/browser/render_frame_host.h"
34 #include "content/public/browser/render_process_host.h" 34 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "content/public/common/resource_request_body.h"
36 #include "content/public/test/browser_test_utils.h" 37 #include "content/public/test/browser_test_utils.h"
37 #include "net/test/embedded_test_server/embedded_test_server.h" 38 #include "net/test/embedded_test_server/embedded_test_server.h"
38 39
39 using content::WebContents; 40 using content::WebContents;
40 41
41 namespace { 42 namespace {
42 43
43 const char kExpectedTitle[] = "PASSED!"; 44 const char kExpectedTitle[] = "PASSED!";
44 const char kEchoTitleCommand[] = "/echotitle"; 45 const char kEchoTitleCommand[] = "/echotitle";
45 46
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 89 }
89 90
90 bool BrowserNavigatorTest::OpenPOSTURLInNewForegroundTabAndGetTitle( 91 bool BrowserNavigatorTest::OpenPOSTURLInNewForegroundTabAndGetTitle(
91 const GURL& url, const std::string& post_data, bool is_browser_initiated, 92 const GURL& url, const std::string& post_data, bool is_browser_initiated,
92 base::string16* title) { 93 base::string16* title) {
93 chrome::NavigateParams param(MakeNavigateParams()); 94 chrome::NavigateParams param(MakeNavigateParams());
94 param.disposition = NEW_FOREGROUND_TAB; 95 param.disposition = NEW_FOREGROUND_TAB;
95 param.url = url; 96 param.url = url;
96 param.is_renderer_initiated = !is_browser_initiated; 97 param.is_renderer_initiated = !is_browser_initiated;
97 param.uses_post = true; 98 param.uses_post = true;
98 param.browser_initiated_post_data = new base::RefCountedStaticMemory( 99 param.post_data = content::ResourceRequestBody::CreateFromBytes(
99 post_data.data(), post_data.size()); 100 post_data.data(), post_data.size());
100 101
101 ui_test_utils::NavigateToURL(&param); 102 ui_test_utils::NavigateToURL(&param);
102 if (!param.target_contents) 103 if (!param.target_contents)
103 return false; 104 return false;
104 105
105 // Navigate() should have opened the contents in new foreground tab in the 106 // Navigate() should have opened the contents in new foreground tab in the
106 // current Browser. 107 // current Browser.
107 EXPECT_EQ(browser(), param.browser); 108 EXPECT_EQ(browser(), param.browser);
108 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), 109 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(),
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 // Open a browser initiated POST request in new foreground tab. 1396 // Open a browser initiated POST request in new foreground tab.
1396 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); 1397 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle));
1397 std::string post_data = kExpectedTitle; 1398 std::string post_data = kExpectedTitle;
1398 base::string16 title; 1399 base::string16 title;
1399 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( 1400 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle(
1400 embedded_test_server()->GetURL(kEchoTitleCommand), post_data, true, 1401 embedded_test_server()->GetURL(kEchoTitleCommand), post_data, true,
1401 &title)); 1402 &title));
1402 EXPECT_EQ(expected_title, title); 1403 EXPECT_EQ(expected_title, title);
1403 } 1404 }
1404 1405
1405 // This test verifies that renderer initiated navigations can NOT send requests 1406 // This test verifies that renderer initiated navigations can also send requests
1406 // using POST. 1407 // using POST.
1407 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1408 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1408 SendRendererInitiatedRequestUsingPOST) { 1409 SendRendererInitiatedRequestUsingPOST) {
1409 // Uses a test sever to verify POST request. 1410 // Uses a test sever to verify POST request.
1410 ASSERT_TRUE(embedded_test_server()->Start()); 1411 ASSERT_TRUE(embedded_test_server()->Start());
1411 1412
1412 // Open a renderer initiated POST request in new foreground tab. 1413 // Open a renderer initiated POST request in new foreground tab.
1413 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); 1414 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle));
1414 std::string post_data = kExpectedTitle; 1415 std::string post_data = kExpectedTitle;
1415 base::string16 title; 1416 base::string16 title;
1416 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( 1417 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle(
1417 embedded_test_server()->GetURL(kEchoTitleCommand), post_data, false, 1418 embedded_test_server()->GetURL(kEchoTitleCommand), post_data, false,
1418 &title)); 1419 &title));
1419 EXPECT_NE(expected_title, title); 1420 EXPECT_EQ(expected_title, title);
1420 } 1421 }
1421 1422
1422 // This test navigates to a data URL that contains BiDi control 1423 // This test navigates to a data URL that contains BiDi control
1423 // characters. For security reasons, BiDi control chars should always be 1424 // characters. For security reasons, BiDi control chars should always be
1424 // escaped in the URL but they should be unescaped in the loaded HTML. 1425 // escaped in the URL but they should be unescaped in the loaded HTML.
1425 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1426 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1426 NavigateToDataURLWithBiDiControlChars) { 1427 NavigateToDataURLWithBiDiControlChars) {
1427 // Text in Arabic. 1428 // Text in Arabic.
1428 std::string text = "\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1"; 1429 std::string text = "\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1";
1429 // Page title starts with RTL mark. 1430 // Page title starts with RTL mark.
(...skipping 18 matching lines...) Expand all
1448 EXPECT_EQ(expected_title, params.target_contents->GetTitle()); 1449 EXPECT_EQ(expected_title, params.target_contents->GetTitle());
1449 // GURL always keeps non-ASCII characters escaped, but check them anyways. 1450 // GURL always keeps non-ASCII characters escaped, but check them anyways.
1450 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec()); 1451 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec());
1451 // Check the omnibox text. It should have escaped RTL with unescaped text. 1452 // Check the omnibox text. It should have escaped RTL with unescaped text.
1452 LocationBar* location_bar = browser()->window()->GetLocationBar(); 1453 LocationBar* location_bar = browser()->window()->GetLocationBar();
1453 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 1454 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
1454 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText()); 1455 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText());
1455 } 1456 }
1456 1457
1457 } // namespace 1458 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_navigator.cc ('k') | chrome/browser/ui/browser_navigator_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698