[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 5 | #include "chrome/browser/ui/browser_navigator_browsertest.h" |
| 6 | |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 7 | #include "base/command_line.h" |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 8 | #include "chrome/app/chrome_command_ids.h" |
| 9 | #include "chrome/browser/autocomplete/autocomplete_edit.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 10 | #include "chrome/browser/profiles/profile.h" |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 11 | #include "chrome/browser/tabs/tab_strip_model.h" |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 12 | #include "chrome/browser/ui/browser_list.h" |
[email protected] | 339d6dd | 2010-11-12 00:41:58 | [diff] [blame] | 13 | #include "chrome/browser/ui/browser_navigator.h" |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 14 | #include "chrome/browser/ui/browser_window.h" |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 15 | #include "chrome/browser/ui/omnibox/location_bar.h" |
| 16 | #include "chrome/browser/ui/omnibox/omnibox_view.h" |
[email protected] | 6a3ec231 | 2010-12-02 19:30:19 | [diff] [blame] | 17 | #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 18 | #include "chrome/common/chrome_switches.h" |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 19 | #include "chrome/common/url_constants.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 20 | #include "chrome/test/base/ui_test_utils.h" |
[email protected] | 299425b | 2011-03-02 07:45:20 | [diff] [blame] | 21 | #include "content/browser/tab_contents/tab_contents.h" |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 22 | #include "content/browser/tab_contents/tab_contents_view.h" |
[email protected] | 0d6e9bd | 2011-10-18 04:29:16 | [diff] [blame] | 23 | #include "content/public/browser/notification_types.h" |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 24 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 25 | namespace { |
| 26 | |
| 27 | GURL GetGoogleURL() { |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 28 | return GURL("http://www.google.com/"); |
| 29 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 30 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 31 | GURL GetSettingsURL() { |
| 32 | return GURL(chrome::kChromeUISettingsURL); |
| 33 | } |
| 34 | |
| 35 | GURL GetSettingsAdvancedURL() { |
| 36 | return GURL(chrome::kChromeUISettingsURL).Resolve( |
| 37 | chrome::kAdvancedOptionsSubPage); |
| 38 | } |
| 39 | |
| 40 | GURL GetSettingsBrowserURL() { |
| 41 | return GURL(chrome::kChromeUISettingsURL).Resolve( |
| 42 | chrome::kBrowserOptionsSubPage); |
| 43 | } |
| 44 | |
| 45 | GURL GetSettingsPersonalURL() { |
| 46 | return GURL(chrome::kChromeUISettingsURL).Resolve( |
| 47 | chrome::kPersonalOptionsSubPage); |
| 48 | } |
| 49 | |
| 50 | } // namespace |
| 51 | |
| 52 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 53 | browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const { |
| 54 | return MakeNavigateParams(browser()); |
| 55 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 56 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 57 | browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams( |
| 58 | Browser* browser) const { |
| 59 | browser::NavigateParams params(browser, GetGoogleURL(), |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 60 | content::PAGE_TRANSITION_LINK); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 61 | params.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 62 | return params; |
| 63 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 64 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 65 | Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type, |
| 66 | Profile* profile) { |
| 67 | Browser* browser = Browser::CreateForType(type, profile); |
| 68 | browser->AddBlankTab(true); |
| 69 | return browser; |
| 70 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 71 | |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 72 | Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type, |
| 73 | Profile* profile) { |
| 74 | Browser* browser = Browser::CreateForApp(Browser::TYPE_POPUP, "Test", |
[email protected] | 5c20924 | 2011-06-06 20:36:17 | [diff] [blame] | 75 | gfx::Rect(), profile); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 76 | browser->AddBlankTab(true); |
| 77 | return browser; |
| 78 | } |
| 79 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 80 | TabContentsWrapper* BrowserNavigatorTest::CreateTabContents() { |
| 81 | return Browser::TabContentsFactory( |
| 82 | browser()->profile(), |
| 83 | NULL, |
| 84 | MSG_ROUTING_NONE, |
| 85 | browser()->GetSelectedTabContents(), |
| 86 | NULL); |
| 87 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 88 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 89 | void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { |
| 90 | GURL old_url = browser()->GetSelectedTabContents()->GetURL(); |
| 91 | browser::NavigateParams p(MakeNavigateParams()); |
| 92 | p.disposition = disposition; |
| 93 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 94 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 95 | // Nothing should have happened as a result of Navigate(); |
| 96 | EXPECT_EQ(1, browser()->tab_count()); |
| 97 | EXPECT_EQ(1u, BrowserList::size()); |
| 98 | EXPECT_EQ(old_url, browser()->GetSelectedTabContents()->GetURL()); |
| 99 | } |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 100 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame^] | 101 | void BrowserNavigatorTest::Observe( |
| 102 | int type, |
| 103 | const content::NotificationSource& source, |
| 104 | const content::NotificationDetails& details) { |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 105 | switch (type) { |
| 106 | case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 107 | ++this->created_tab_contents_count_; |
| 108 | break; |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 109 | } |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 110 | default: |
| 111 | break; |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 112 | } |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 113 | } |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 114 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 115 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 116 | namespace { |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 117 | |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 118 | // This test verifies that when a navigation occurs within a tab, the tab count |
| 119 | // of the Browser remains the same and the current tab bears the loaded URL. |
| 120 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 121 | ui_test_utils::NavigateToURL(browser(), GetGoogleURL()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 122 | EXPECT_EQ(GetGoogleURL(), browser()->GetSelectedTabContents()->GetURL()); |
| 123 | // We should have one window with one tab. |
| 124 | EXPECT_EQ(1u, BrowserList::size()); |
| 125 | EXPECT_EQ(1, browser()->tab_count()); |
| 126 | } |
| 127 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 128 | // This test verifies that a singleton tab is refocused if one is already opened |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 129 | // in another or an existing window, or added if it is not. |
| 130 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 131 | GURL singleton_url1("http://maps.google.com/"); |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 132 | |
| 133 | // Register for a notification if an additional tab_contents was instantiated. |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 134 | // Opening a Singleton tab that is already opened should not be opening a new |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 135 | // tab nor be creating a new TabContents object |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame^] | 136 | content::NotificationRegistrar registrar; |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 137 | |
| 138 | // As the registrar object goes out of scope, this will get unregistered |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 139 | registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 140 | NotificationService::AllSources()); |
| 141 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 142 | browser()->AddSelectedTabWithURL( |
| 143 | singleton_url1, content::PAGE_TRANSITION_LINK); |
| 144 | browser()->AddSelectedTabWithURL( |
| 145 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 146 | |
| 147 | // We should have one browser with 3 tabs, the 3rd selected. |
| 148 | EXPECT_EQ(1u, BrowserList::size()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 149 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 150 | |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 151 | unsigned int previous_tab_contents_count = |
| 152 | created_tab_contents_count_ = 0; |
| 153 | |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 154 | // Navigate to singleton_url1. |
| 155 | browser::NavigateParams p(MakeNavigateParams()); |
| 156 | p.disposition = SINGLETON_TAB; |
| 157 | p.url = singleton_url1; |
| 158 | browser::Navigate(&p); |
| 159 | |
| 160 | // The middle tab should now be selected. |
| 161 | EXPECT_EQ(browser(), p.browser); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 162 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 163 | |
| 164 | // No tab contents should have been created |
| 165 | EXPECT_EQ(previous_tab_contents_count, |
| 166 | created_tab_contents_count_); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
[email protected] | 578c696 | 2011-08-24 22:06:40 | [diff] [blame] | 170 | Disposition_SingletonTabRespectingRef) { |
| 171 | GURL singleton_ref_url1("http://maps.google.com/#a"); |
| 172 | GURL singleton_ref_url2("http://maps.google.com/#b"); |
| 173 | GURL singleton_ref_url3("http://maps.google.com/"); |
| 174 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 175 | browser()->AddSelectedTabWithURL( |
| 176 | singleton_ref_url1, content::PAGE_TRANSITION_LINK); |
[email protected] | 578c696 | 2011-08-24 22:06:40 | [diff] [blame] | 177 | |
| 178 | // We should have one browser with 2 tabs, 2nd selected. |
| 179 | EXPECT_EQ(1u, BrowserList::size()); |
| 180 | EXPECT_EQ(2, browser()->tab_count()); |
| 181 | EXPECT_EQ(1, browser()->active_index()); |
| 182 | |
| 183 | // Navigate to singleton_url2. |
| 184 | browser::NavigateParams p(MakeNavigateParams()); |
| 185 | p.disposition = SINGLETON_TAB; |
| 186 | p.url = singleton_ref_url2; |
| 187 | browser::Navigate(&p); |
| 188 | |
| 189 | // We should now have 2 tabs, the 2nd one selected. |
| 190 | EXPECT_EQ(browser(), p.browser); |
| 191 | EXPECT_EQ(2, browser()->tab_count()); |
| 192 | EXPECT_EQ(1, browser()->active_index()); |
| 193 | |
| 194 | // Navigate to singleton_url2, but with respect ref set. |
| 195 | p = MakeNavigateParams(); |
| 196 | p.disposition = SINGLETON_TAB; |
| 197 | p.url = singleton_ref_url2; |
| 198 | p.ref_behavior = browser::NavigateParams::RESPECT_REF; |
| 199 | browser::Navigate(&p); |
| 200 | |
| 201 | // We should now have 3 tabs, the 3th one selected. |
| 202 | EXPECT_EQ(browser(), p.browser); |
| 203 | EXPECT_EQ(3, browser()->tab_count()); |
| 204 | EXPECT_EQ(2, browser()->active_index()); |
| 205 | |
| 206 | // Navigate to singleton_url3. |
| 207 | p = MakeNavigateParams(); |
| 208 | p.disposition = SINGLETON_TAB; |
| 209 | p.url = singleton_ref_url3; |
| 210 | p.ref_behavior = browser::NavigateParams::RESPECT_REF; |
| 211 | browser::Navigate(&p); |
| 212 | |
| 213 | // We should now have 4 tabs, the 4th one selected. |
| 214 | EXPECT_EQ(browser(), p.browser); |
| 215 | EXPECT_EQ(4, browser()->tab_count()); |
| 216 | EXPECT_EQ(3, browser()->active_index()); |
| 217 | } |
| 218 | |
| 219 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 220 | Disposition_SingletonTabNoneExisting) { |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 221 | GURL singleton_url1("http://maps.google.com/"); |
| 222 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 223 | // We should have one browser with 1 tab. |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 224 | EXPECT_EQ(1u, BrowserList::size()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 225 | EXPECT_EQ(0, browser()->active_index()); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 226 | |
| 227 | // Navigate to singleton_url1. |
| 228 | browser::NavigateParams p(MakeNavigateParams()); |
| 229 | p.disposition = SINGLETON_TAB; |
| 230 | p.url = singleton_url1; |
| 231 | browser::Navigate(&p); |
| 232 | |
| 233 | // We should now have 2 tabs, the 2nd one selected. |
| 234 | EXPECT_EQ(browser(), p.browser); |
| 235 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 236 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | // This test verifies that when a navigation results in a foreground tab, the |
| 240 | // tab count of the Browser increases and the selected tab shifts to the new |
| 241 | // foreground tab. |
| 242 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { |
| 243 | TabContents* old_contents = browser()->GetSelectedTabContents(); |
| 244 | browser::NavigateParams p(MakeNavigateParams()); |
| 245 | p.disposition = NEW_FOREGROUND_TAB; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 246 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 247 | EXPECT_NE(old_contents, browser()->GetSelectedTabContents()); |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 248 | EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 249 | EXPECT_EQ(2, browser()->tab_count()); |
| 250 | } |
| 251 | |
| 252 | // This test verifies that when a navigation results in a background tab, the |
| 253 | // tab count of the Browser increases but the selected tab remains the same. |
| 254 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { |
| 255 | TabContents* old_contents = browser()->GetSelectedTabContents(); |
| 256 | browser::NavigateParams p(MakeNavigateParams()); |
| 257 | p.disposition = NEW_BACKGROUND_TAB; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 258 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 259 | TabContents* new_contents = browser()->GetSelectedTabContents(); |
| 260 | // The selected tab should have remained unchanged, since the new tab was |
| 261 | // opened in the background. |
| 262 | EXPECT_EQ(old_contents, new_contents); |
| 263 | EXPECT_EQ(2, browser()->tab_count()); |
| 264 | } |
| 265 | |
| 266 | // This test verifies that when a navigation requiring a new foreground tab |
| 267 | // occurs in a Browser that cannot host multiple tabs, the new foreground tab |
| 268 | // is created in an existing compatible Browser. |
| 269 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 270 | Disposition_IncompatibleWindow_Existing) { |
| 271 | // Open a foreground tab in a window that cannot open popups when there is an |
| 272 | // existing compatible window somewhere else that they can be opened within. |
| 273 | Browser* popup = CreateEmptyBrowserForType(Browser::TYPE_POPUP, |
| 274 | browser()->profile()); |
| 275 | browser::NavigateParams p(MakeNavigateParams(popup)); |
| 276 | p.disposition = NEW_FOREGROUND_TAB; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 277 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 278 | |
| 279 | // Navigate() should have opened the tab in a different browser since the |
| 280 | // one we supplied didn't support additional tabs. |
| 281 | EXPECT_NE(popup, p.browser); |
| 282 | |
| 283 | // Since browser() is an existing compatible tabbed browser, it should have |
| 284 | // opened the tab there. |
| 285 | EXPECT_EQ(browser(), p.browser); |
| 286 | |
| 287 | // We should be left with 2 windows, the popup with one tab and the browser() |
| 288 | // provided by the framework with two. |
| 289 | EXPECT_EQ(2u, BrowserList::size()); |
| 290 | EXPECT_EQ(1, popup->tab_count()); |
| 291 | EXPECT_EQ(2, browser()->tab_count()); |
| 292 | } |
| 293 | |
| 294 | // This test verifies that when a navigation requiring a new foreground tab |
| 295 | // occurs in a Browser that cannot host multiple tabs and no compatible Browser |
| 296 | // that can is open, a compatible Browser is created. |
| 297 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 298 | Disposition_IncompatibleWindow_NoExisting) { |
| 299 | // We want to simulate not being able to find an existing window compatible |
| 300 | // with our non-tabbed browser window so Navigate() is forced to create a |
| 301 | // new compatible window. Because browser() supplied by the in-process |
| 302 | // browser testing framework is compatible with browser()->profile(), we |
| 303 | // need a different profile, and creating a popup window with an incognito |
| 304 | // profile is a quick and dirty way of achieving this. |
| 305 | Browser* popup = CreateEmptyBrowserForType( |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 306 | Browser::TYPE_POPUP, |
| 307 | browser()->profile()->GetOffTheRecordProfile()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 308 | browser::NavigateParams p(MakeNavigateParams(popup)); |
| 309 | p.disposition = NEW_FOREGROUND_TAB; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 310 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 311 | |
| 312 | // Navigate() should have opened the tab in a different browser since the |
| 313 | // one we supplied didn't support additional tabs. |
| 314 | EXPECT_NE(popup, p.browser); |
| 315 | |
| 316 | // This time, browser() is _not_ compatible with popup since it is not an |
| 317 | // incognito window. |
| 318 | EXPECT_NE(browser(), p.browser); |
| 319 | |
| 320 | // We should have three windows, each with one tab: |
| 321 | // 1. the browser() provided by the framework (unchanged in this test) |
| 322 | // 2. the incognito popup we created originally |
| 323 | // 3. the new incognito tabbed browser that was created by Navigate(). |
| 324 | EXPECT_EQ(3u, BrowserList::size()); |
| 325 | EXPECT_EQ(1, browser()->tab_count()); |
| 326 | EXPECT_EQ(1, popup->tab_count()); |
| 327 | EXPECT_EQ(1, p.browser->tab_count()); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 328 | EXPECT_TRUE(p.browser->is_type_tabbed()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 332 | // from a normal Browser results in a new Browser with TYPE_POPUP. |
| 333 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { |
| 334 | browser::NavigateParams p(MakeNavigateParams()); |
| 335 | p.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 336 | p.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 337 | // Wait for new popup to to load and gain focus. |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 338 | ui_test_utils::NavigateToURL(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 339 | |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 340 | // Navigate() should have opened a new, focused popup window. |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 341 | EXPECT_NE(browser(), p.browser); |
[email protected] | 9db263a | 2011-04-15 20:53:47 | [diff] [blame] | 342 | #if 0 |
| 343 | // TODO(stevenjb): Enable this test. See: crbug.com/79493 |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 344 | EXPECT_TRUE(p.browser->window()->IsActive()); |
| 345 | #endif |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 346 | EXPECT_TRUE(p.browser->is_type_popup()); |
| 347 | EXPECT_FALSE(p.browser->is_app()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 348 | |
| 349 | // We should have two windows, the browser() provided by the framework and the |
| 350 | // new popup window. |
| 351 | EXPECT_EQ(2u, BrowserList::size()); |
| 352 | EXPECT_EQ(1, browser()->tab_count()); |
| 353 | EXPECT_EQ(1, p.browser->tab_count()); |
| 354 | } |
| 355 | |
| 356 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 357 | // from a normal Browser results in a new Browser with is_app() true. |
| 358 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) { |
| 359 | browser::NavigateParams p(MakeNavigateParams()); |
| 360 | p.disposition = NEW_POPUP; |
| 361 | p.extension_app_id = "extensionappid"; |
| 362 | p.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 363 | // Wait for new popup to to load and gain focus. |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 364 | ui_test_utils::NavigateToURL(&p); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 365 | |
| 366 | // Navigate() should have opened a new, focused popup window. |
| 367 | EXPECT_NE(browser(), p.browser); |
| 368 | EXPECT_TRUE(p.browser->is_type_popup()); |
| 369 | EXPECT_TRUE(p.browser->is_app()); |
| 370 | |
| 371 | // We should have two windows, the browser() provided by the framework and the |
| 372 | // new popup window. |
| 373 | EXPECT_EQ(2u, BrowserList::size()); |
| 374 | EXPECT_EQ(1, browser()->tab_count()); |
| 375 | EXPECT_EQ(1, p.browser->tab_count()); |
| 376 | } |
| 377 | |
| 378 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 379 | // from a normal popup results in a new Browser with TYPE_POPUP. |
| 380 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { |
| 381 | // Open a popup. |
| 382 | browser::NavigateParams p1(MakeNavigateParams()); |
| 383 | p1.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 384 | p1.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 385 | browser::Navigate(&p1); |
| 386 | // Open another popup. |
| 387 | browser::NavigateParams p2(MakeNavigateParams(p1.browser)); |
| 388 | p2.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 389 | p2.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 390 | browser::Navigate(&p2); |
| 391 | |
| 392 | // Navigate() should have opened a new normal popup window. |
| 393 | EXPECT_NE(p1.browser, p2.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 394 | EXPECT_TRUE(p2.browser->is_type_popup()); |
| 395 | EXPECT_FALSE(p2.browser->is_app()); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 396 | |
| 397 | // We should have three windows, the browser() provided by the framework, |
| 398 | // the first popup window, and the second popup window. |
| 399 | EXPECT_EQ(3u, BrowserList::size()); |
| 400 | EXPECT_EQ(1, browser()->tab_count()); |
| 401 | EXPECT_EQ(1, p1.browser->tab_count()); |
| 402 | EXPECT_EQ(1, p2.browser->tab_count()); |
| 403 | } |
| 404 | |
| 405 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 406 | // from an app frame results in a new Browser with TYPE_APP_POPUP. |
| 407 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 408 | Disposition_NewPopupFromAppWindow) { |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 409 | Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, |
| 410 | browser()->profile()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 411 | browser::NavigateParams p(MakeNavigateParams(app_browser)); |
| 412 | p.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 413 | p.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 414 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 415 | |
| 416 | // Navigate() should have opened a new popup app window. |
| 417 | EXPECT_NE(app_browser, p.browser); |
| 418 | EXPECT_NE(browser(), p.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 419 | EXPECT_TRUE(p.browser->is_type_popup()); |
| 420 | EXPECT_TRUE(p.browser->is_app()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 421 | |
| 422 | // We should now have three windows, the app window, the app popup it created, |
| 423 | // and the original browser() provided by the framework. |
| 424 | EXPECT_EQ(3u, BrowserList::size()); |
| 425 | EXPECT_EQ(1, browser()->tab_count()); |
| 426 | EXPECT_EQ(1, app_browser->tab_count()); |
| 427 | EXPECT_EQ(1, p.browser->tab_count()); |
| 428 | } |
| 429 | |
| 430 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 431 | // from an app popup results in a new Browser also of TYPE_APP_POPUP. |
| 432 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 433 | Disposition_NewPopupFromAppPopup) { |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 434 | Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, |
| 435 | browser()->profile()); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 436 | // Open an app popup. |
| 437 | browser::NavigateParams p1(MakeNavigateParams(app_browser)); |
| 438 | p1.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 439 | p1.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 440 | browser::Navigate(&p1); |
| 441 | // Now open another app popup. |
| 442 | browser::NavigateParams p2(MakeNavigateParams(p1.browser)); |
| 443 | p2.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 444 | p2.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 445 | browser::Navigate(&p2); |
| 446 | |
| 447 | // Navigate() should have opened a new popup app window. |
| 448 | EXPECT_NE(browser(), p1.browser); |
| 449 | EXPECT_NE(p1.browser, p2.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 450 | EXPECT_TRUE(p2.browser->is_type_popup()); |
| 451 | EXPECT_TRUE(p2.browser->is_app()); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 452 | |
| 453 | // We should now have four windows, the app window, the first app popup, |
| 454 | // the second app popup, and the original browser() provided by the framework. |
| 455 | EXPECT_EQ(4u, BrowserList::size()); |
| 456 | EXPECT_EQ(1, browser()->tab_count()); |
| 457 | EXPECT_EQ(1, app_browser->tab_count()); |
| 458 | EXPECT_EQ(1, p1.browser->tab_count()); |
| 459 | EXPECT_EQ(1, p2.browser->tab_count()); |
| 460 | } |
| 461 | |
| 462 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 463 | // from an extension app tab results in a new Browser with TYPE_APP_POPUP. |
| 464 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 465 | Disposition_NewPopupFromExtensionApp) { |
| 466 | // TODO(beng): TBD. |
| 467 | } |
| 468 | |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 469 | // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE |
| 470 | // does not focus a new new popup window. |
| 471 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) { |
| 472 | browser::NavigateParams p(MakeNavigateParams()); |
| 473 | p.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 474 | p.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 475 | p.window_action = browser::NavigateParams::SHOW_WINDOW_INACTIVE; |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 476 | // Wait for new popup to load (and gain focus if the test fails). |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 477 | ui_test_utils::NavigateToURL(&p); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 478 | |
| 479 | // Navigate() should have opened a new, unfocused, popup window. |
| 480 | EXPECT_NE(browser(), p.browser); |
| 481 | EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); |
[email protected] | 9db263a | 2011-04-15 20:53:47 | [diff] [blame] | 482 | #if 0 |
| 483 | // TODO(stevenjb): Enable this test. See: crbug.com/79493 |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 484 | EXPECT_FALSE(p.browser->window()->IsActive()); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 485 | #endif |
[email protected] | 9db263a | 2011-04-15 20:53:47 | [diff] [blame] | 486 | } |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 487 | |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 488 | // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW |
| 489 | // always opens a new window. |
| 490 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) { |
| 491 | browser::NavigateParams p(MakeNavigateParams()); |
| 492 | p.disposition = NEW_WINDOW; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 493 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 494 | |
| 495 | // Navigate() should have opened a new toplevel window. |
| 496 | EXPECT_NE(browser(), p.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 497 | EXPECT_TRUE(p.browser->is_type_tabbed()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 498 | |
| 499 | // We should now have two windows, the browser() provided by the framework and |
| 500 | // the new normal window. |
| 501 | EXPECT_EQ(2u, BrowserList::size()); |
| 502 | EXPECT_EQ(1, browser()->tab_count()); |
| 503 | EXPECT_EQ(1, p.browser->tab_count()); |
| 504 | } |
| 505 | |
| 506 | // This test verifies that navigating with WindowOpenDisposition = INCOGNITO |
| 507 | // opens a new incognito window if no existing incognito window is present. |
| 508 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { |
| 509 | browser::NavigateParams p(MakeNavigateParams()); |
| 510 | p.disposition = OFF_THE_RECORD; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 511 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 512 | |
| 513 | // Navigate() should have opened a new toplevel incognito window. |
| 514 | EXPECT_NE(browser(), p.browser); |
| 515 | EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(), |
| 516 | p.browser->profile()); |
| 517 | |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 518 | // |source_contents| should be set to NULL because the profile for the new |
| 519 | // page is different from the originating page. |
| 520 | EXPECT_EQ(NULL, p.source_contents); |
| 521 | |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 522 | // We should now have two windows, the browser() provided by the framework and |
| 523 | // the new incognito window. |
| 524 | EXPECT_EQ(2u, BrowserList::size()); |
| 525 | EXPECT_EQ(1, browser()->tab_count()); |
| 526 | EXPECT_EQ(1, p.browser->tab_count()); |
| 527 | } |
| 528 | |
| 529 | // This test verifies that navigating with WindowOpenDisposition = INCOGNITO |
| 530 | // reuses an existing incognito window when possible. |
| 531 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { |
| 532 | Browser* incognito_browser = |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 533 | CreateEmptyBrowserForType(Browser::TYPE_TABBED, |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 534 | browser()->profile()->GetOffTheRecordProfile()); |
| 535 | browser::NavigateParams p(MakeNavigateParams()); |
| 536 | p.disposition = OFF_THE_RECORD; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 537 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 538 | |
| 539 | // Navigate() should have opened a new tab in the existing incognito window. |
| 540 | EXPECT_NE(browser(), p.browser); |
| 541 | EXPECT_EQ(p.browser, incognito_browser); |
| 542 | |
| 543 | // We should now have two windows, the browser() provided by the framework and |
| 544 | // the incognito window we opened earlier. |
| 545 | EXPECT_EQ(2u, BrowserList::size()); |
| 546 | EXPECT_EQ(1, browser()->tab_count()); |
| 547 | EXPECT_EQ(2, incognito_browser->tab_count()); |
| 548 | } |
| 549 | |
| 550 | // This test verifies that no navigation action occurs when |
| 551 | // WindowOpenDisposition = SUPPRESS_OPEN. |
| 552 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SuppressOpen) { |
| 553 | RunSuppressTest(SUPPRESS_OPEN); |
| 554 | } |
| 555 | |
| 556 | // This test verifies that no navigation action occurs when |
| 557 | // WindowOpenDisposition = SAVE_TO_DISK. |
| 558 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) { |
| 559 | RunSuppressTest(SAVE_TO_DISK); |
| 560 | } |
| 561 | |
| 562 | // This test verifies that no navigation action occurs when |
| 563 | // WindowOpenDisposition = IGNORE_ACTION. |
| 564 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) { |
| 565 | RunSuppressTest(IGNORE_ACTION); |
| 566 | } |
| 567 | |
| 568 | // This tests adding a foreground tab with a predefined TabContents. |
| 569 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { |
| 570 | browser::NavigateParams p(MakeNavigateParams()); |
| 571 | p.disposition = NEW_FOREGROUND_TAB; |
| 572 | p.target_contents = CreateTabContents(); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 573 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 574 | |
| 575 | // Navigate() should have opened the contents in a new foreground in the |
| 576 | // current Browser. |
| 577 | EXPECT_EQ(browser(), p.browser); |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 578 | EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 579 | |
| 580 | // We should have one window, with two tabs. |
| 581 | EXPECT_EQ(1u, BrowserList::size()); |
| 582 | EXPECT_EQ(2, browser()->tab_count()); |
| 583 | } |
| 584 | |
| 585 | #if defined(OS_WIN) |
| 586 | // This tests adding a popup with a predefined TabContents. |
[email protected] | 76edb67 | 2011-03-04 21:48:39 | [diff] [blame] | 587 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 588 | browser::NavigateParams p(MakeNavigateParams()); |
| 589 | p.disposition = NEW_POPUP; |
| 590 | p.target_contents = CreateTabContents(); |
| 591 | p.window_bounds = gfx::Rect(10, 10, 500, 500); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 592 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 593 | |
| 594 | // Navigate() should have opened a new popup window. |
| 595 | EXPECT_NE(browser(), p.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 596 | EXPECT_TRUE(p.browser->is_type_popup()); |
| 597 | EXPECT_FALSE(p.browser->is_app()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 598 | |
| 599 | // The web platform is weird. The window bounds specified in |
| 600 | // |p.window_bounds| are used as follows: |
| 601 | // - the origin is used to position the window |
| 602 | // - the size is used to size the TabContents of the window. |
| 603 | // As such the position of the resulting window will always match |
| 604 | // p.window_bounds.origin(), but its size will not. We need to match |
| 605 | // the size against the selected tab's view's container size. |
| 606 | // Only Windows positions the window according to |p.window_bounds.origin()| - |
| 607 | // on Mac the window is offset from the opener and on Linux it always opens |
| 608 | // at 0,0. |
| 609 | EXPECT_EQ(p.window_bounds.origin(), |
| 610 | p.browser->window()->GetRestoredBounds().origin()); |
| 611 | // All platforms should respect size however provided width > 400 (Mac has a |
| 612 | // minimum window width of 400). |
| 613 | EXPECT_EQ(p.window_bounds.size(), |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 614 | p.target_contents->tab_contents()->view()->GetContainerSize()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 615 | |
| 616 | // We should have two windows, the new popup and the browser() provided by the |
| 617 | // framework. |
| 618 | EXPECT_EQ(2u, BrowserList::size()); |
| 619 | EXPECT_EQ(1, browser()->tab_count()); |
| 620 | EXPECT_EQ(1, p.browser->tab_count()); |
| 621 | } |
| 622 | #endif |
| 623 | |
| 624 | // This tests adding a tab at a specific index. |
| 625 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) { |
| 626 | // This is not meant to be a comprehensive test of whether or not the tab |
| 627 | // implementation of the browser observes the insertion index. That is |
| 628 | // covered by the unit tests for TabStripModel. This merely verifies that |
| 629 | // insertion index preference is reflected in common cases. |
| 630 | browser::NavigateParams p(MakeNavigateParams()); |
| 631 | p.disposition = NEW_FOREGROUND_TAB; |
| 632 | p.tabstrip_index = 0; |
| 633 | p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 634 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 635 | |
| 636 | // Navigate() should have inserted a new tab at slot 0 in the tabstrip. |
| 637 | EXPECT_EQ(browser(), p.browser); |
| 638 | EXPECT_EQ(0, browser()->tabstrip_model()->GetIndexOfTabContents( |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 639 | static_cast<const TabContentsWrapper*>(p.target_contents))); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 640 | |
| 641 | // We should have one window - the browser() provided by the framework. |
| 642 | EXPECT_EQ(1u, BrowserList::size()); |
| 643 | EXPECT_EQ(2, browser()->tab_count()); |
| 644 | } |
| 645 | |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 646 | // This test verifies that constructing params with a NULL browser has |
| 647 | // the same result as navigating to a new foreground tab in the (only) |
| 648 | // active browser. Tests are the same as for Disposition_NewForegroundTab. |
| 649 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) { |
| 650 | TabContents* old_contents = browser()->GetSelectedTabContents(); |
| 651 | // Navigate with a NULL browser. |
| 652 | browser::NavigateParams p(MakeNavigateParams(NULL)); |
| 653 | p.disposition = NEW_FOREGROUND_TAB; |
| 654 | p.profile = browser()->profile(); |
| 655 | browser::Navigate(&p); |
| 656 | |
| 657 | // Navigate() should have found browser() and create a new tab. |
| 658 | EXPECT_EQ(browser(), p.browser); |
| 659 | EXPECT_NE(old_contents, browser()->GetSelectedTabContents()); |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 660 | EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 661 | EXPECT_EQ(2, browser()->tab_count()); |
| 662 | } |
| 663 | |
| 664 | // This test verifies that constructing params with a NULL browser and |
| 665 | // a specific profile matches the specified profile. |
[email protected] | c8a31a7 | 2011-09-30 01:53:32 | [diff] [blame] | 666 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) { |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 667 | // Create a new browser with using the incognito profile. |
| 668 | Browser* incognito = |
| 669 | Browser::Create(browser()->profile()->GetOffTheRecordProfile()); |
| 670 | |
| 671 | // Navigate with a NULL browser and the incognito profile. |
| 672 | browser::NavigateParams p(MakeNavigateParams(NULL)); |
| 673 | p.disposition = NEW_FOREGROUND_TAB; |
| 674 | p.profile = incognito->profile(); |
| 675 | browser::Navigate(&p); |
| 676 | |
| 677 | // Navigate() should have found incognito, not browser(). |
| 678 | EXPECT_EQ(incognito, p.browser); |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 679 | EXPECT_EQ(incognito->GetSelectedTabContentsWrapper(), p.target_contents); |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 680 | EXPECT_EQ(1, incognito->tab_count()); |
| 681 | } |
| 682 | |
| 683 | // This test verifies that constructing params with a NULL browser and |
| 684 | // disposition = NEW_WINDOW always opens exactly one new window. |
| 685 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { |
| 686 | browser::NavigateParams p(MakeNavigateParams(NULL)); |
| 687 | p.disposition = NEW_WINDOW; |
| 688 | p.profile = browser()->profile(); |
| 689 | browser::Navigate(&p); |
| 690 | |
| 691 | // Navigate() should have created a new browser. |
| 692 | EXPECT_NE(browser(), p.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 693 | EXPECT_TRUE( p.browser->is_type_tabbed()); |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 694 | |
| 695 | // We should now have two windows, the browser() provided by the framework and |
| 696 | // the new normal window. |
| 697 | EXPECT_EQ(2u, BrowserList::size()); |
| 698 | EXPECT_EQ(1, browser()->tab_count()); |
| 699 | EXPECT_EQ(1, p.browser->tab_count()); |
| 700 | } |
| 701 | |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 702 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 703 | // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if |
[email protected] | 67ed83e | 2011-01-07 22:54:00 | [diff] [blame] | 704 | // no previous tab with that URL (minus the path) exists. |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 705 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 706 | Disposition_SingletonTabNew_IgnorePath) { |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 707 | browser()->AddSelectedTabWithURL( |
| 708 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 709 | |
| 710 | // We should have one browser with 2 tabs, the 2nd selected. |
| 711 | EXPECT_EQ(1u, BrowserList::size()); |
| 712 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 713 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 714 | |
| 715 | // Navigate to a new singleton tab with a sub-page. |
| 716 | browser::NavigateParams p(MakeNavigateParams()); |
| 717 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 718 | p.url = GetSettingsAdvancedURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 719 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 720 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 721 | browser::Navigate(&p); |
| 722 | |
| 723 | // The last tab should now be selected and navigated to the sub-page of the |
| 724 | // URL. |
| 725 | EXPECT_EQ(browser(), p.browser); |
| 726 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 727 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 728 | EXPECT_EQ(GetSettingsAdvancedURL(), |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 729 | browser()->GetSelectedTabContents()->GetURL()); |
| 730 | } |
| 731 | |
| 732 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 733 | // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 734 | // the path) which is navigated to the specified URL. |
| 735 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 736 | Disposition_SingletonTabExisting_IgnorePath) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 737 | GURL singleton_url1(GetSettingsURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 738 | browser()->AddSelectedTabWithURL( |
| 739 | singleton_url1, content::PAGE_TRANSITION_LINK); |
| 740 | browser()->AddSelectedTabWithURL( |
| 741 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 742 | |
| 743 | // We should have one browser with 3 tabs, the 3rd selected. |
| 744 | EXPECT_EQ(1u, BrowserList::size()); |
| 745 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 746 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 747 | |
| 748 | // Navigate to singleton_url1. |
| 749 | browser::NavigateParams p(MakeNavigateParams()); |
| 750 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 751 | p.url = GetSettingsAdvancedURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 752 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 753 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 754 | browser::Navigate(&p); |
| 755 | |
| 756 | // The middle tab should now be selected and navigated to the sub-page of the |
| 757 | // URL. |
| 758 | EXPECT_EQ(browser(), p.browser); |
| 759 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 760 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 761 | EXPECT_EQ(GetSettingsAdvancedURL(), |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 762 | browser()->GetSelectedTabContents()->GetURL()); |
| 763 | } |
| 764 | |
| 765 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 766 | // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 767 | // the path) which is navigated to the specified URL. |
| 768 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 769 | Disposition_SingletonTabExistingSubPath_IgnorePath) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 770 | GURL singleton_url1(GetSettingsAdvancedURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 771 | browser()->AddSelectedTabWithURL( |
| 772 | singleton_url1, content::PAGE_TRANSITION_LINK); |
| 773 | browser()->AddSelectedTabWithURL( |
| 774 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 775 | |
| 776 | // We should have one browser with 3 tabs, the 3rd selected. |
| 777 | EXPECT_EQ(1u, BrowserList::size()); |
| 778 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 779 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 780 | |
| 781 | // Navigate to singleton_url1. |
| 782 | browser::NavigateParams p(MakeNavigateParams()); |
| 783 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 784 | p.url = GetSettingsPersonalURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 785 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 786 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 787 | browser::Navigate(&p); |
| 788 | |
| 789 | // The middle tab should now be selected and navigated to the sub-page of the |
| 790 | // URL. |
| 791 | EXPECT_EQ(browser(), p.browser); |
| 792 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 793 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 794 | EXPECT_EQ(GetSettingsPersonalURL(), |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 795 | browser()->GetSelectedTabContents()->GetURL()); |
| 796 | } |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 797 | |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 798 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 799 | // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus |
| 800 | // the path). |
| 801 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 802 | Disposition_SingletonTabExistingSubPath_IgnorePath2) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 803 | GURL singleton_url1(GetSettingsAdvancedURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 804 | browser()->AddSelectedTabWithURL( |
| 805 | singleton_url1, content::PAGE_TRANSITION_LINK); |
| 806 | browser()->AddSelectedTabWithURL( |
| 807 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 808 | |
| 809 | // We should have one browser with 3 tabs, the 3rd selected. |
| 810 | EXPECT_EQ(1u, BrowserList::size()); |
| 811 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 812 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 813 | |
| 814 | // Navigate to singleton_url1. |
| 815 | browser::NavigateParams p(MakeNavigateParams()); |
| 816 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 817 | p.url = GetSettingsPersonalURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 818 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 819 | p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT; |
| 820 | browser::Navigate(&p); |
| 821 | |
| 822 | // The middle tab should now be selected. |
| 823 | EXPECT_EQ(browser(), p.browser); |
| 824 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 825 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 826 | EXPECT_EQ(singleton_url1, |
| 827 | browser()->GetSelectedTabContents()->GetURL()); |
| 828 | } |
| 829 | |
| 830 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
| 831 | // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 832 | // selected tab is a match but has a different path. |
| 833 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 834 | Disposition_SingletonTabFocused_IgnorePath) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 835 | GURL singleton_url_current(GetSettingsAdvancedURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 836 | browser()->AddSelectedTabWithURL( |
| 837 | singleton_url_current, content::PAGE_TRANSITION_LINK); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 838 | |
| 839 | // We should have one browser with 2 tabs, the 2nd selected. |
| 840 | EXPECT_EQ(1u, BrowserList::size()); |
| 841 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 842 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 843 | |
| 844 | // Navigate to a different settings path. |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 845 | GURL singleton_url_target(GetSettingsPersonalURL()); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 846 | browser::NavigateParams p(MakeNavigateParams()); |
| 847 | p.disposition = SINGLETON_TAB; |
| 848 | p.url = singleton_url_target; |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 849 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 850 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 851 | browser::Navigate(&p); |
| 852 | |
| 853 | // The second tab should still be selected, but navigated to the new path. |
| 854 | EXPECT_EQ(browser(), p.browser); |
| 855 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 856 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 857 | EXPECT_EQ(singleton_url_target, |
| 858 | browser()->GetSelectedTabContents()->GetURL()); |
| 859 | } |
| 860 | |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 861 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 862 | // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different |
| 863 | // query. |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 864 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 865 | Disposition_SingletonTabExisting_IgnoreQuery) { |
| 866 | int initial_tab_count = browser()->tab_count(); |
| 867 | GURL singleton_url_current("chrome://settings/internet"); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 868 | browser()->AddSelectedTabWithURL( |
| 869 | singleton_url_current, content::PAGE_TRANSITION_LINK); |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 870 | |
| 871 | EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 872 | EXPECT_EQ(initial_tab_count, browser()->active_index()); |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 873 | |
| 874 | // Navigate to a different settings path. |
| 875 | GURL singleton_url_target( |
| 876 | "chrome://settings/internet?" |
| 877 | "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); |
| 878 | browser::NavigateParams p(MakeNavigateParams()); |
| 879 | p.disposition = SINGLETON_TAB; |
| 880 | p.url = singleton_url_target; |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 881 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 882 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 883 | browser::Navigate(&p); |
| 884 | |
| 885 | // Last tab should still be selected. |
| 886 | EXPECT_EQ(browser(), p.browser); |
| 887 | EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 888 | EXPECT_EQ(initial_tab_count, browser()->active_index()); |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 889 | } |
| 890 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 891 | // This test verifies that the settings page isn't opened in the incognito |
| 892 | // window. |
| 893 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 894 | Disposition_Settings_UseNonIncognitoWindow) { |
| 895 | Browser* incognito_browser = CreateIncognitoBrowser(); |
| 896 | |
| 897 | EXPECT_EQ(2u, BrowserList::size()); |
| 898 | EXPECT_EQ(1, browser()->tab_count()); |
| 899 | EXPECT_EQ(1, incognito_browser->tab_count()); |
| 900 | |
| 901 | // Navigate to the settings page. |
| 902 | browser::NavigateParams p(MakeNavigateParams(incognito_browser)); |
| 903 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 904 | p.url = GetSettingsURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 905 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 906 | browser::Navigate(&p); |
| 907 | |
| 908 | // The settings page should be opened in browser() window. |
| 909 | EXPECT_NE(incognito_browser, p.browser); |
| 910 | EXPECT_EQ(browser(), p.browser); |
| 911 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 912 | EXPECT_EQ(GetSettingsURL(), |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 913 | browser()->GetSelectedTabContents()->GetURL()); |
| 914 | } |
| 915 | |
[email protected] | 82404cd | 2011-07-12 19:55:14 | [diff] [blame] | 916 | // This test verifies that the settings page isn't opened in the incognito |
| 917 | // window from a non-incognito window (bookmark open-in-incognito trigger). |
| 918 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 919 | Disposition_Settings_UseNonIncognitoWindowForBookmark) { |
| 920 | browser::NavigateParams params(browser(), GURL("chrome://settings"), |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 921 | content::PAGE_TRANSITION_AUTO_BOOKMARK); |
[email protected] | 82404cd | 2011-07-12 19:55:14 | [diff] [blame] | 922 | params.disposition = OFF_THE_RECORD; |
| 923 | { |
| 924 | ui_test_utils::WindowedNotificationObserver observer( |
| 925 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 926 | browser::Navigate(¶ms); |
| 927 | observer.Wait(); |
| 928 | } |
| 929 | |
| 930 | EXPECT_EQ(1u, BrowserList::size()); |
| 931 | EXPECT_EQ(GURL("chrome://settings"), |
| 932 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
| 933 | } |
| 934 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 935 | // This test verifies that the bookmarks page isn't opened in the incognito |
| 936 | // window. |
| 937 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 938 | Disposition_Bookmarks_UseNonIncognitoWindow) { |
| 939 | Browser* incognito_browser = CreateIncognitoBrowser(); |
| 940 | |
| 941 | EXPECT_EQ(2u, BrowserList::size()); |
| 942 | EXPECT_EQ(1, browser()->tab_count()); |
| 943 | EXPECT_EQ(1, incognito_browser->tab_count()); |
| 944 | |
| 945 | // Navigate to the settings page. |
| 946 | browser::NavigateParams p(MakeNavigateParams(incognito_browser)); |
| 947 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 948 | p.url = GURL(chrome::kChromeUIBookmarksURL); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 949 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 950 | browser::Navigate(&p); |
| 951 | |
| 952 | // The bookmarks page should be opened in browser() window. |
| 953 | EXPECT_NE(incognito_browser, p.browser); |
| 954 | EXPECT_EQ(browser(), p.browser); |
| 955 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 956 | EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 957 | browser()->GetSelectedTabContents()->GetURL()); |
| 958 | } |
| 959 | |
[email protected] | 7de53c6 | 2011-05-13 06:44:16 | [diff] [blame] | 960 | // This test makes sure a crashed singleton tab reloads from a new navigation. |
| 961 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 962 | NavigateToCrashedSingletonTab) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 963 | GURL singleton_url(GetSettingsAdvancedURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 964 | TabContentsWrapper* wrapper = browser()->AddSelectedTabWithURL( |
| 965 | singleton_url, content::PAGE_TRANSITION_LINK); |
[email protected] | 7de53c6 | 2011-05-13 06:44:16 | [diff] [blame] | 966 | TabContents* tab_contents = wrapper->tab_contents(); |
| 967 | |
| 968 | // We should have one browser with 2 tabs, the 2nd selected. |
| 969 | EXPECT_EQ(1u, BrowserList::size()); |
| 970 | EXPECT_EQ(2, browser()->tab_count()); |
| 971 | EXPECT_EQ(1, browser()->active_index()); |
| 972 | |
| 973 | // Kill the singleton tab. |
| 974 | tab_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
| 975 | EXPECT_TRUE(tab_contents->is_crashed()); |
| 976 | |
| 977 | browser::NavigateParams p(MakeNavigateParams()); |
| 978 | p.disposition = SINGLETON_TAB; |
| 979 | p.url = singleton_url; |
| 980 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
| 981 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 982 | ui_test_utils::NavigateToURL(&p); |
[email protected] | 7de53c6 | 2011-05-13 06:44:16 | [diff] [blame] | 983 | |
| 984 | // The tab should not be sad anymore. |
| 985 | EXPECT_FALSE(tab_contents->is_crashed()); |
| 986 | } |
| 987 | |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 988 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 989 | NavigateFromDefaultToOptionsInSameTab) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 990 | { |
| 991 | ui_test_utils::WindowedNotificationObserver observer( |
| 992 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 993 | browser()->OpenOptionsDialog(); |
| 994 | observer.Wait(); |
| 995 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 996 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 997 | EXPECT_EQ(GetSettingsURL(), |
| 998 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1002 | NavigateFromBlankToOptionsInSameTab) { |
| 1003 | browser::NavigateParams p(MakeNavigateParams()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1004 | p.url = GURL(chrome::kAboutBlankURL); |
| 1005 | ui_test_utils::NavigateToURL(&p); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1006 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1007 | { |
| 1008 | ui_test_utils::WindowedNotificationObserver observer( |
| 1009 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1010 | browser()->OpenOptionsDialog(); |
| 1011 | observer.Wait(); |
| 1012 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1013 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1014 | EXPECT_EQ(GetSettingsURL(), |
| 1015 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1016 | } |
| 1017 | |
| 1018 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1019 | NavigateFromNTPToOptionsInSameTab) { |
| 1020 | browser::NavigateParams p(MakeNavigateParams()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1021 | p.url = GURL(chrome::kChromeUINewTabURL); |
| 1022 | ui_test_utils::NavigateToURL(&p); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1023 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1024 | EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1025 | browser()->GetSelectedTabContents()->GetURL()); |
| 1026 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1027 | { |
| 1028 | ui_test_utils::WindowedNotificationObserver observer( |
| 1029 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1030 | browser()->OpenOptionsDialog(); |
| 1031 | observer.Wait(); |
| 1032 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1033 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1034 | EXPECT_EQ(GetSettingsURL(), |
| 1035 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1039 | NavigateFromPageToOptionsInNewTab) { |
| 1040 | browser::NavigateParams p(MakeNavigateParams()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1041 | ui_test_utils::NavigateToURL(&p); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1042 | EXPECT_EQ(GetGoogleURL(), browser()->GetSelectedTabContents()->GetURL()); |
| 1043 | EXPECT_EQ(1u, BrowserList::size()); |
| 1044 | EXPECT_EQ(1, browser()->tab_count()); |
| 1045 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1046 | { |
| 1047 | ui_test_utils::WindowedNotificationObserver observer( |
| 1048 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1049 | browser()->OpenOptionsDialog(); |
| 1050 | observer.Wait(); |
| 1051 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1052 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1053 | EXPECT_EQ(GetSettingsURL(), |
| 1054 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1058 | NavigateFromNTPToOptionsSingleton) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1059 | { |
| 1060 | ui_test_utils::WindowedNotificationObserver observer( |
| 1061 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1062 | browser()->OpenOptionsDialog(); |
| 1063 | observer.Wait(); |
| 1064 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1065 | EXPECT_EQ(1, browser()->tab_count()); |
| 1066 | |
| 1067 | browser()->NewTab(); |
| 1068 | EXPECT_EQ(2, browser()->tab_count()); |
| 1069 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1070 | { |
| 1071 | ui_test_utils::WindowedNotificationObserver observer( |
| 1072 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1073 | browser()->OpenOptionsDialog(); |
| 1074 | observer.Wait(); |
| 1075 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1076 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1077 | EXPECT_EQ(GetSettingsURL(), |
| 1078 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1079 | } |
| 1080 | |
| 1081 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1082 | NavigateFromNTPToOptionsPageInSameTab) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1083 | { |
| 1084 | ui_test_utils::WindowedNotificationObserver observer( |
| 1085 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1086 | browser()->ShowOptionsTab(chrome::kPersonalOptionsSubPage); |
| 1087 | observer.Wait(); |
| 1088 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1089 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1090 | EXPECT_EQ(GetSettingsPersonalURL(), |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1091 | browser()->GetSelectedTabContents()->GetURL()); |
| 1092 | |
| 1093 | browser()->NewTab(); |
| 1094 | EXPECT_EQ(2, browser()->tab_count()); |
| 1095 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1096 | { |
| 1097 | ui_test_utils::WindowedNotificationObserver observer( |
| 1098 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1099 | browser()->ShowOptionsTab(chrome::kPersonalOptionsSubPage); |
| 1100 | observer.Wait(); |
| 1101 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1102 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1103 | EXPECT_EQ(GetSettingsPersonalURL(), |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1104 | browser()->GetSelectedTabContents()->GetURL()); |
| 1105 | } |
| 1106 | |
| 1107 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1108 | NavigateFromOtherTabToSingletonOptions) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1109 | { |
| 1110 | ui_test_utils::WindowedNotificationObserver observer( |
| 1111 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1112 | browser()->OpenOptionsDialog(); |
| 1113 | observer.Wait(); |
| 1114 | } |
| 1115 | { |
| 1116 | ui_test_utils::WindowedNotificationObserver observer( |
| 1117 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1118 | browser()->AddSelectedTabWithURL( |
| 1119 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1120 | observer.Wait(); |
| 1121 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1122 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1123 | { |
| 1124 | ui_test_utils::WindowedNotificationObserver observer( |
| 1125 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1126 | browser()->OpenOptionsDialog(); |
| 1127 | observer.Wait(); |
| 1128 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1129 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1130 | EXPECT_EQ(GetSettingsURL(), |
| 1131 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1132 | } |
| 1133 | |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 1134 | // Tests that when a new tab is opened from the omnibox, the focus is moved from |
| 1135 | // the omnibox for the current tab. |
| 1136 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1137 | NavigateFromOmniboxIntoNewTab) { |
| 1138 | GURL url("http://www.google.com/"); |
| 1139 | GURL url2("http://maps.google.com/"); |
| 1140 | |
| 1141 | // Navigate to url. |
| 1142 | browser::NavigateParams p(MakeNavigateParams()); |
| 1143 | p.disposition = CURRENT_TAB; |
| 1144 | p.url = url; |
| 1145 | browser::Navigate(&p); |
| 1146 | |
| 1147 | // Focus the omnibox. |
| 1148 | browser()->FocusLocationBar(); |
| 1149 | |
| 1150 | AutocompleteEditController* controller = |
| 1151 | browser()->window()->GetLocationBar()->location_entry()->model()-> |
| 1152 | controller(); |
| 1153 | |
| 1154 | // Simulate an alt-enter. |
| 1155 | controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB, |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1156 | content::PAGE_TRANSITION_TYPED, GURL()); |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 1157 | |
| 1158 | // Make sure the second tab is selected. |
| 1159 | EXPECT_EQ(1, browser()->active_index()); |
| 1160 | |
| 1161 | // The tab contents should have the focus in the second tab. |
| 1162 | EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1163 | VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 1164 | |
| 1165 | // Go back to the first tab. The focus should not be in the omnibox. |
| 1166 | browser()->SelectPreviousTab(); |
| 1167 | EXPECT_EQ(0, browser()->active_index()); |
| 1168 | EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), |
| 1169 | VIEW_ID_LOCATION_BAR)); |
| 1170 | } |
| 1171 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1172 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1173 | NavigateFromDefaultToHistoryInSameTab) { |
| 1174 | { |
| 1175 | ui_test_utils::WindowedNotificationObserver observer( |
| 1176 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1177 | browser()->ShowHistoryTab(); |
| 1178 | observer.Wait(); |
| 1179 | } |
| 1180 | EXPECT_EQ(1, browser()->tab_count()); |
| 1181 | EXPECT_EQ(GURL(chrome::kChromeUIHistoryURL), |
| 1182 | browser()->GetSelectedTabContents()->GetURL()); |
| 1183 | } |
| 1184 | |
| 1185 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1186 | NavigateFromDefaultToBookmarksInSameTab) { |
| 1187 | { |
| 1188 | ui_test_utils::WindowedNotificationObserver observer( |
| 1189 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
[email protected] | 0af8f13 | 2011-07-16 01:37:02 | [diff] [blame] | 1190 | browser()->OpenBookmarkManager(); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1191 | observer.Wait(); |
| 1192 | } |
| 1193 | EXPECT_EQ(1, browser()->tab_count()); |
| 1194 | EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), |
| 1195 | browser()->GetSelectedTabContents()->GetURL()); |
| 1196 | } |
| 1197 | |
| 1198 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1199 | NavigateFromDefaultToDownloadsInSameTab) { |
| 1200 | { |
| 1201 | ui_test_utils::WindowedNotificationObserver observer( |
| 1202 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1203 | browser()->ShowDownloadsTab(); |
| 1204 | observer.Wait(); |
| 1205 | } |
| 1206 | EXPECT_EQ(1, browser()->tab_count()); |
| 1207 | EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), |
| 1208 | browser()->GetSelectedTabContents()->GetURL()); |
| 1209 | } |
| 1210 | |
| 1211 | } // namespace |