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

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

Issue 1678233003: Don't focus the location bar in a phishy situation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test in chrome/. Created 4 years, 10 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 | « no previous file | chrome/chrome_tests.gypi » ('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/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
11 #include "chrome/app/chrome_command_ids.h" 12 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" 13 #include "chrome/browser/prefs/incognito_mode_prefs.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 16 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/browser_navigator.h" 18 #include "chrome/browser/ui/browser_navigator.h"
18 #include "chrome/browser/ui/browser_navigator_params.h" 19 #include "chrome/browser/ui/browser_navigator_params.h"
19 #include "chrome/browser/ui/browser_tabstrip.h" 20 #include "chrome/browser/ui/browser_tabstrip.h"
20 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/chrome_pages.h" 22 #include "chrome/browser/ui/chrome_pages.h"
22 #include "chrome/browser/ui/location_bar/location_bar.h" 23 #include "chrome/browser/ui/location_bar/location_bar.h"
23 #include "chrome/browser/ui/singleton_tabs.h" 24 #include "chrome/browser/ui/singleton_tabs.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
29 #include "chrome/test/base/interactive_test_utils.h"
28 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
29 #include "components/omnibox/browser/omnibox_view.h" 31 #include "components/omnibox/browser/omnibox_view.h"
30 #include "components/prefs/pref_service.h" 32 #include "components/prefs/pref_service.h"
31 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
32 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
33 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "content/public/test/browser_test_utils.h"
34 #include "net/test/embedded_test_server/embedded_test_server.h" 37 #include "net/test/embedded_test_server/embedded_test_server.h"
35 38
36 using content::WebContents; 39 using content::WebContents;
37 40
38 namespace { 41 namespace {
39 42
40 const char kExpectedTitle[] = "PASSED!"; 43 const char kExpectedTitle[] = "PASSED!";
41 const char kEchoTitleCommand[] = "/echotitle"; 44 const char kEchoTitleCommand[] = "/echotitle";
42 45
43 GURL GetGoogleURL() { 46 GURL GetGoogleURL() {
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 EXPECT_TRUE(params.target_contents); 1414 EXPECT_TRUE(params.target_contents);
1412 EXPECT_EQ(expected_title, params.target_contents->GetTitle()); 1415 EXPECT_EQ(expected_title, params.target_contents->GetTitle());
1413 // GURL always keeps non-ASCII characters escaped, but check them anyways. 1416 // GURL always keeps non-ASCII characters escaped, but check them anyways.
1414 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec()); 1417 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec());
1415 // Check the omnibox text. It should have escaped RTL with unescaped text. 1418 // Check the omnibox text. It should have escaped RTL with unescaped text.
1416 LocationBar* location_bar = browser()->window()->GetLocationBar(); 1419 LocationBar* location_bar = browser()->window()->GetLocationBar();
1417 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 1420 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
1418 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText()); 1421 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText());
1419 } 1422 }
1420 1423
1424 // Ensure that crbug.com/567445 does not regress.
1425 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, AboutBlankNavigationLocationTest) {
1426 ASSERT_TRUE(embedded_test_server()->Start());
1427
1428 ui_test_utils::NavigateToURL(browser(),
1429 embedded_test_server()->GetURL("/title1.html"));
1430
1431 const char kSpoofScript[] =
1432 "var w = window.open('about:blank');"
1433 "w.opener = null;"
1434 "w.document.location = '%s';";
1435
1436 TabStripModel* tab_strip = browser()->tab_strip_model();
1437 WebContents* web_contents = tab_strip->GetActiveWebContents();
1438
1439 ASSERT_TRUE(content::ExecuteScript(
1440 web_contents,
1441 base::StringPrintf(
1442 kSpoofScript,
1443 embedded_test_server()->GetURL("/title2.html").spec().c_str())));
1444 EXPECT_FALSE(web_contents->GetController().GetPendingEntry());
1445 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html"),
1446 web_contents->GetVisibleURL());
1447
1448 LocationBar* location_bar = browser()->window()->GetLocationBar();
1449 OmniboxView* omnibox = location_bar->GetOmniboxView();
1450 ASSERT_FALSE(omnibox->IsEditingOrEmpty());
palmer 2016/02/12 01:15:54 This test passes, but I'm not 100% sure it's testi
Peter Kasting 2016/02/12 01:37:20 It's not. Just focusing the omnibox does not set
1451 // ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
palmer 2016/02/12 01:15:54 This line causes the link to fail: No implementati
Peter Kasting 2016/02/12 01:37:20 That's linked into the interactive_ui_tests target
1452 }
1453
1421 } // namespace 1454 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698