OLD | NEW |
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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ui/singleton_tabs.h" | 23 #include "chrome/browser/ui/singleton_tabs.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
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 "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 33 #include "net/test/embedded_test_server/embedded_test_server.h" |
33 | 34 |
34 using content::WebContents; | 35 using content::WebContents; |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 const char kExpectedTitle[] = "PASSED!"; | 39 const char kExpectedTitle[] = "PASSED!"; |
39 const char kEchoTitleCommand[] = "echotitle"; | 40 const char kEchoTitleCommand[] = "/echotitle"; |
40 | 41 |
41 GURL GetGoogleURL() { | 42 GURL GetGoogleURL() { |
42 return GURL("http://www.google.com/"); | 43 return GURL("http://www.google.com/"); |
43 } | 44 } |
44 | 45 |
45 GURL GetSettingsURL() { | 46 GURL GetSettingsURL() { |
46 return GURL(chrome::kChromeUISettingsURL); | 47 return GURL(chrome::kChromeUISettingsURL); |
47 } | 48 } |
48 | 49 |
49 GURL GetContentSettingsURL() { | 50 GURL GetContentSettingsURL() { |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 ui::PAGE_TRANSITION_LINK); | 1349 ui::PAGE_TRANSITION_LINK); |
1349 singleton_params.disposition = SINGLETON_TAB; | 1350 singleton_params.disposition = SINGLETON_TAB; |
1350 EXPECT_EQ(-1, chrome::GetIndexOfSingletonTab(&singleton_params)); | 1351 EXPECT_EQ(-1, chrome::GetIndexOfSingletonTab(&singleton_params)); |
1351 } | 1352 } |
1352 | 1353 |
1353 // This test verifies that browser initiated navigations can send requests | 1354 // This test verifies that browser initiated navigations can send requests |
1354 // using POST. | 1355 // using POST. |
1355 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1356 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1356 SendBrowserInitiatedRequestUsingPOST) { | 1357 SendBrowserInitiatedRequestUsingPOST) { |
1357 // Uses a test sever to verify POST request. | 1358 // Uses a test sever to verify POST request. |
1358 ASSERT_TRUE(test_server()->Start()); | 1359 ASSERT_TRUE(embedded_test_server()->Start()); |
1359 | 1360 |
1360 // Open a browser initiated POST request in new foreground tab. | 1361 // Open a browser initiated POST request in new foreground tab. |
1361 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); | 1362 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); |
1362 std::string post_data = kExpectedTitle; | 1363 std::string post_data = kExpectedTitle; |
1363 base::string16 title; | 1364 base::string16 title; |
1364 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( | 1365 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( |
1365 test_server()->GetURL(kEchoTitleCommand), post_data, true, &title)); | 1366 embedded_test_server()->GetURL(kEchoTitleCommand), post_data, true, |
| 1367 &title)); |
1366 EXPECT_EQ(expected_title, title); | 1368 EXPECT_EQ(expected_title, title); |
1367 } | 1369 } |
1368 | 1370 |
1369 // This test verifies that renderer initiated navigations can NOT send requests | 1371 // This test verifies that renderer initiated navigations can NOT send requests |
1370 // using POST. | 1372 // using POST. |
1371 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1373 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1372 SendRendererInitiatedRequestUsingPOST) { | 1374 SendRendererInitiatedRequestUsingPOST) { |
1373 // Uses a test sever to verify POST request. | 1375 // Uses a test sever to verify POST request. |
1374 ASSERT_TRUE(test_server()->Start()); | 1376 ASSERT_TRUE(embedded_test_server()->Start()); |
1375 | 1377 |
1376 // Open a renderer initiated POST request in new foreground tab. | 1378 // Open a renderer initiated POST request in new foreground tab. |
1377 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); | 1379 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); |
1378 std::string post_data = kExpectedTitle; | 1380 std::string post_data = kExpectedTitle; |
1379 base::string16 title; | 1381 base::string16 title; |
1380 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( | 1382 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( |
1381 test_server()->GetURL(kEchoTitleCommand), post_data, false, &title)); | 1383 embedded_test_server()->GetURL(kEchoTitleCommand), post_data, false, |
| 1384 &title)); |
1382 EXPECT_NE(expected_title, title); | 1385 EXPECT_NE(expected_title, title); |
1383 } | 1386 } |
1384 | 1387 |
1385 // This test navigates to a data URL that contains BiDi control | 1388 // This test navigates to a data URL that contains BiDi control |
1386 // characters. For security reasons, BiDi control chars should always be | 1389 // characters. For security reasons, BiDi control chars should always be |
1387 // escaped in the URL but they should be unescaped in the loaded HTML. | 1390 // escaped in the URL but they should be unescaped in the loaded HTML. |
1388 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1391 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
1389 NavigateToDataURLWithBiDiControlChars) { | 1392 NavigateToDataURLWithBiDiControlChars) { |
1390 // Text in Arabic. | 1393 // Text in Arabic. |
1391 std::string text = "\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1"; | 1394 std::string text = "\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1"; |
(...skipping 19 matching lines...) Expand all Loading... |
1411 EXPECT_EQ(expected_title, params.target_contents->GetTitle()); | 1414 EXPECT_EQ(expected_title, params.target_contents->GetTitle()); |
1412 // GURL always keeps non-ASCII characters escaped, but check them anyways. | 1415 // GURL always keeps non-ASCII characters escaped, but check them anyways. |
1413 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec()); | 1416 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec()); |
1414 // Check the omnibox text. It should have escaped RTL with unescaped text. | 1417 // Check the omnibox text. It should have escaped RTL with unescaped text. |
1415 LocationBar* location_bar = browser()->window()->GetLocationBar(); | 1418 LocationBar* location_bar = browser()->window()->GetLocationBar(); |
1416 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 1419 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
1417 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText()); | 1420 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText()); |
1418 } | 1421 } |
1419 | 1422 |
1420 } // namespace | 1423 } // namespace |
OLD | NEW |