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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_navigator_browsertest.cc
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc
index e5442d429d4b1eb8e586e0429e2ea9d502bd5975..f2125c04f395c5bba29dc6ade688b4d2c92ff22c 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.cc
+++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
@@ -25,12 +26,14 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/omnibox/browser/omnibox_view.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
using content::WebContents;
@@ -1418,4 +1421,34 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText());
}
+// Ensure that crbug.com/567445 does not regress.
+IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, AboutBlankNavigationLocationTest) {
+ ASSERT_TRUE(embedded_test_server()->Start());
+
+ ui_test_utils::NavigateToURL(browser(),
+ embedded_test_server()->GetURL("/title1.html"));
+
+ const char kSpoofScript[] =
+ "var w = window.open('about:blank');"
+ "w.opener = null;"
+ "w.document.location = '%s';";
+
+ TabStripModel* tab_strip = browser()->tab_strip_model();
+ WebContents* web_contents = tab_strip->GetActiveWebContents();
+
+ ASSERT_TRUE(content::ExecuteScript(
+ web_contents,
+ base::StringPrintf(
+ kSpoofScript,
+ embedded_test_server()->GetURL("/title2.html").spec().c_str())));
+ EXPECT_FALSE(web_contents->GetController().GetPendingEntry());
+ EXPECT_EQ(embedded_test_server()->GetURL("/title1.html"),
+ web_contents->GetVisibleURL());
+
+ LocationBar* location_bar = browser()->window()->GetLocationBar();
+ OmniboxView* omnibox = location_bar->GetOmniboxView();
+ 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
+ // 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
+}
+
} // namespace
« 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