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 <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 Loading... |
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. This test checks that the |
| 742 // Omnibox does not get focused when loading about:blank in a case where it's |
| 743 // not the startup URL, e.g. when a page opens a popup to about:blank, with a |
| 744 // null opener, and then navigates it. This is a potential security issue; see |
| 745 // comments in |WebContentsImpl::FocusLocationBarByDefault|. |
| 746 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, AboutBlankNavigationLocationTest) { |
| 747 const GURL url1(embedded_test_server()->GetURL("/title1.html")); |
| 748 ui_test_utils::NavigateToURL(browser(), url1); |
| 749 |
| 750 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 751 WebContents* web_contents = tab_strip->GetActiveWebContents(); |
| 752 |
| 753 const GURL url2(embedded_test_server()->GetURL("/title2.html")); |
| 754 const std::string spoof("var w = window.open('about:blank'); w.opener = null;" |
| 755 "w.document.location = '" + url2.spec() + "';"); |
| 756 |
| 757 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof)); |
| 758 EXPECT_EQ(url1, web_contents->GetVisibleURL()); |
| 759 // After running the spoof code, |GetActiveWebContents| returns the new tab, |
| 760 // not the same as |web_contents|. |
| 761 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( |
| 762 browser()->tab_strip_model()->GetActiveWebContents())); |
| 763 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
| 764 } |
| 765 |
741 } // namespace | 766 } // namespace |
OLD | NEW |