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

Side by Side 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 unified diff | Download patch
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 content::WindowedNotificationObserver forward_nav_observer( 731 content::WindowedNotificationObserver forward_nav_observer(
732 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 732 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
733 content::NotificationService::AllSources()); 733 content::NotificationService::AllSources());
734 chrome::GoForward(browser(), CURRENT_TAB); 734 chrome::GoForward(browser(), CURRENT_TAB);
735 forward_nav_observer.Wait(); 735 forward_nav_observer.Wait();
736 } 736 }
737 737
738 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); 738 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
739 } 739 }
740 740
741 // 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.
742 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, AboutBlankNavigationLocationTest) {
743 ui_test_utils::NavigateToURL(browser(),
744 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.
745
746 const char kSpoofScript[] =
747 "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.
748 "w.opener = null;"
749 "w.document.location = '%s';";
750
751 TabStripModel* tab_strip = browser()->tab_strip_model();
752 WebContents* web_contents = tab_strip->GetActiveWebContents();
753
754 ASSERT_TRUE(content::ExecuteScript(
755 web_contents,
756 base::StringPrintf(
757 kSpoofScript,
758 embedded_test_server()->GetURL("/title2.html").spec().c_str())));
759 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html"),
760 web_contents->GetVisibleURL());
761 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
762 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
763 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.
764 }
765
741 } // namespace 766 } // namespace
OLDNEW
« 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