| 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); | 2050 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); |
| 2051 // Navigate the new browser window so it'll be shown and we can pick the | 2051 // Navigate the new browser window so it'll be shown and we can pick the |
| 2052 // active window. | 2052 // active window. |
| 2053 ui_test_utils::NavigateToURL(browser2, GURL(chrome::kAboutBlankURL)); | 2053 ui_test_utils::NavigateToURL(browser2, GURL(chrome::kAboutBlankURL)); |
| 2054 | 2054 |
| 2055 // Generally, |browser2| will be the active window. However, if the | 2055 // Generally, |browser2| will be the active window. However, if the |
| 2056 // original browser window lost focus before creating the new one, such as | 2056 // original browser window lost focus before creating the new one, such as |
| 2057 // when running multiple tests at once, the original browser window may | 2057 // when running multiple tests at once, the original browser window may |
| 2058 // remain the profile's active window. | 2058 // remain the profile's active window. |
| 2059 Browser* active_browser = | 2059 Browser* active_browser = |
| 2060 browser::FindTabbedBrowser(browser()->profile(), true); | 2060 browser::FindTabbedBrowser(browser()->profile(), true, |
| 2061 browser()->host_desktop_type()); |
| 2061 Browser* inactive_browser; | 2062 Browser* inactive_browser; |
| 2062 if (active_browser == browser2) { | 2063 if (active_browser == browser2) { |
| 2063 // When only one test is running at a time, the new browser will probably be | 2064 // When only one test is running at a time, the new browser will probably be |
| 2064 // on top, but when multiple tests are running at once, this is not | 2065 // on top, but when multiple tests are running at once, this is not |
| 2065 // guaranteed. | 2066 // guaranteed. |
| 2066 inactive_browser = browser(); | 2067 inactive_browser = browser(); |
| 2067 } else { | 2068 } else { |
| 2068 ASSERT_EQ(active_browser, browser()); | 2069 ASSERT_EQ(active_browser, browser()); |
| 2069 inactive_browser = browser2; | 2070 inactive_browser = browser2; |
| 2070 } | 2071 } |
| 2071 | 2072 |
| 2072 CaptivePortalObserver portal_observer(browser()->profile()); | 2073 CaptivePortalObserver portal_observer(browser()->profile()); |
| 2073 MultiNavigationObserver navigation_observer; | 2074 MultiNavigationObserver navigation_observer; |
| 2074 | 2075 |
| 2075 // Navigate the tab in the inactive browser to an SSL timeout. Have to use | 2076 // Navigate the tab in the inactive browser to an SSL timeout. Have to use |
| 2076 // chrome::NavigateParams and NEW_BACKGROUND_TAB to avoid activating the | 2077 // chrome::NavigateParams and NEW_BACKGROUND_TAB to avoid activating the |
| 2077 // window. | 2078 // window. |
| 2078 chrome::NavigateParams params(inactive_browser, | 2079 chrome::NavigateParams params(inactive_browser, |
| 2079 GURL(kMockHttpsQuickTimeoutUrl), | 2080 GURL(kMockHttpsQuickTimeoutUrl), |
| 2080 content::PAGE_TRANSITION_TYPED); | 2081 content::PAGE_TRANSITION_TYPED); |
| 2081 params.disposition = NEW_BACKGROUND_TAB; | 2082 params.disposition = NEW_BACKGROUND_TAB; |
| 2082 params.window_action = chrome::NavigateParams::NO_ACTION; | 2083 params.window_action = chrome::NavigateParams::NO_ACTION; |
| 2083 ui_test_utils::NavigateToURL(¶ms); | 2084 ui_test_utils::NavigateToURL(¶ms); |
| 2084 navigation_observer.WaitForNavigations(2); | 2085 navigation_observer.WaitForNavigations(2); |
| 2085 | 2086 |
| 2086 // Make sure the active window hasn't changed, and its new tab is | 2087 // Make sure the active window hasn't changed, and its new tab is |
| 2087 // active. | 2088 // active. |
| 2088 ASSERT_EQ(active_browser, | 2089 ASSERT_EQ(active_browser, |
| 2089 browser::FindTabbedBrowser(browser()->profile(), true)); | 2090 browser::FindTabbedBrowser(browser()->profile(), true, |
| 2091 browser()->host_desktop_type())); |
| 2090 ASSERT_EQ(1, active_browser->active_index()); | 2092 ASSERT_EQ(1, active_browser->active_index()); |
| 2091 | 2093 |
| 2092 // Check that the only two navigated tabs were the new error tab in the | 2094 // Check that the only two navigated tabs were the new error tab in the |
| 2093 // backround windows, and the login tab in the active window. | 2095 // backround windows, and the login tab in the active window. |
| 2094 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( | 2096 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( |
| 2095 chrome::GetWebContentsAt(inactive_browser, 1))); | 2097 chrome::GetWebContentsAt(inactive_browser, 1))); |
| 2096 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( | 2098 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( |
| 2097 chrome::GetWebContentsAt(active_browser, 1))); | 2099 chrome::GetWebContentsAt(active_browser, 1))); |
| 2098 EXPECT_EQ(0, NumLoadingTabs()); | 2100 EXPECT_EQ(0, NumLoadingTabs()); |
| 2099 | 2101 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 base::Bind(&AddHstsHost, | 2181 base::Bind(&AddHstsHost, |
| 2180 make_scoped_refptr(browser()->profile()->GetRequestContext()), | 2182 make_scoped_refptr(browser()->profile()->GetRequestContext()), |
| 2181 http_timeout_url.host())); | 2183 http_timeout_url.host())); |
| 2182 | 2184 |
| 2183 SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1); | 2185 SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1); |
| 2184 Login(browser(), 1, 0); | 2186 Login(browser(), 1, 0); |
| 2185 FailLoadsAfterLogin(browser(), 1); | 2187 FailLoadsAfterLogin(browser(), 1); |
| 2186 } | 2188 } |
| 2187 | 2189 |
| 2188 } // namespace captive_portal | 2190 } // namespace captive_portal |
| OLD | NEW |