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