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

Unified Diff: chrome/browser/ui/browser_focus_uitest.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: Wait for load in the WC returned by GetActiveWebContents 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
Index: chrome/browser/ui/browser_focus_uitest.cc
diff --git a/chrome/browser/ui/browser_focus_uitest.cc b/chrome/browser/ui/browser_focus_uitest.cc
index 142b522a2f57f1115904b454efc30aaabd8ba406..0cfb2b8f79a61e7cfec5d9ff72fd254bf63744b6 100644
--- a/chrome/browser/ui/browser_focus_uitest.cc
+++ b/chrome/browser/ui/browser_focus_uitest.cc
@@ -738,4 +738,29 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnNavigate) {
EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
}
+// Ensure that crbug.com/567445 does not regress.
Peter Kasting 2016/03/03 21:02:18 Nit: Explain here what this is testing, e.g. "Ensu
palmer 2016/03/04 22:15:56 Done.
+IN_PROC_BROWSER_TEST_F(BrowserFocusTest, AboutBlankNavigationLocationTest) {
+ ui_test_utils::NavigateToURL(browser(),
+ embedded_test_server()->GetURL("/title1.html"));
Peter Kasting 2016/03/03 21:02:18 Nit: Store URL in a temp since you use it twice:
palmer 2016/03/04 22:15:56 Done.
+
+ const char kSpoofScript[] =
+ "var w = window.open('about:blank');"
Peter Kasting 2016/03/03 21:02:18 Nit: Could go on previous line (and next two lines
palmer 2016/03/04 22:15:56 Done.
+ "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_EQ(embedded_test_server()->GetURL("/title1.html"),
+ web_contents->GetVisibleURL());
+ ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
+ browser()->tab_strip_model()->GetActiveWebContents()));
Peter Kasting 2016/03/03 21:02:18 Is this different than |web_contents|? If so I'd
palmer 2016/03/04 22:15:56 Yes, they are different; it's the newly-opened con
+ EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
Charlie Reis 2016/02/25 00:48:40 Sure, these lines look plausible to me, assuming t
palmer 2016/03/04 22:15:56 Acknowledged.
+}
+
} // namespace
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | content/browser/web_contents/web_contents_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698