| 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 "chrome/browser/ui/browser_navigator_browsertest.h" | 5 #include "chrome/browser/ui/browser_navigator_browsertest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 chrome::NavigateParams params(browser, GetGoogleURL(), | 85 chrome::NavigateParams params(browser, GetGoogleURL(), |
| 86 ui::PAGE_TRANSITION_LINK); | 86 ui::PAGE_TRANSITION_LINK); |
| 87 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 87 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 88 return params; | 88 return params; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool BrowserNavigatorTest::OpenPOSTURLInNewForegroundTabAndGetTitle( | 91 bool BrowserNavigatorTest::OpenPOSTURLInNewForegroundTabAndGetTitle( |
| 92 const GURL& url, const std::string& post_data, bool is_browser_initiated, | 92 const GURL& url, const std::string& post_data, bool is_browser_initiated, |
| 93 base::string16* title) { | 93 base::string16* title) { |
| 94 chrome::NavigateParams param(MakeNavigateParams()); | 94 chrome::NavigateParams param(MakeNavigateParams()); |
| 95 param.disposition = NEW_FOREGROUND_TAB; | 95 param.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 96 param.url = url; | 96 param.url = url; |
| 97 param.is_renderer_initiated = !is_browser_initiated; | 97 param.is_renderer_initiated = !is_browser_initiated; |
| 98 param.uses_post = true; | 98 param.uses_post = true; |
| 99 param.post_data = content::ResourceRequestBody::CreateFromBytes( | 99 param.post_data = content::ResourceRequestBody::CreateFromBytes( |
| 100 post_data.data(), post_data.size()); | 100 post_data.data(), post_data.size()); |
| 101 | 101 |
| 102 ui_test_utils::NavigateToURL(¶m); | 102 ui_test_utils::NavigateToURL(¶m); |
| 103 if (!param.target_contents) | 103 if (!param.target_contents) |
| 104 return false; | 104 return false; |
| 105 | 105 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { | 158 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { |
| 159 Browser* incognito_browser = CreateIncognitoBrowser(); | 159 Browser* incognito_browser = CreateIncognitoBrowser(); |
| 160 | 160 |
| 161 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 161 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 162 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 162 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 163 EXPECT_EQ(1, incognito_browser->tab_strip_model()->count()); | 163 EXPECT_EQ(1, incognito_browser->tab_strip_model()->count()); |
| 164 | 164 |
| 165 // Navigate to the page. | 165 // Navigate to the page. |
| 166 chrome::NavigateParams params(MakeNavigateParams(incognito_browser)); | 166 chrome::NavigateParams params(MakeNavigateParams(incognito_browser)); |
| 167 params.disposition = SINGLETON_TAB; | 167 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 168 params.url = url; | 168 params.url = url; |
| 169 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 169 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 170 chrome::Navigate(¶ms); | 170 chrome::Navigate(¶ms); |
| 171 | 171 |
| 172 // This page should be opened in browser() window. | 172 // This page should be opened in browser() window. |
| 173 EXPECT_NE(incognito_browser, params.browser); | 173 EXPECT_NE(incognito_browser, params.browser); |
| 174 EXPECT_EQ(browser(), params.browser); | 174 EXPECT_EQ(browser(), params.browser); |
| 175 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 175 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 176 EXPECT_EQ(url, | 176 EXPECT_EQ(url, |
| 177 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 177 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest( | 180 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest( |
| 181 const GURL& url) { | 181 const GURL& url) { |
| 182 Browser* browser = CreateIncognitoBrowser(); | 182 Browser* browser = CreateIncognitoBrowser(); |
| 183 | 183 |
| 184 // Set kIncognitoModeAvailability to FORCED. | 184 // Set kIncognitoModeAvailability to FORCED. |
| 185 PrefService* prefs1 = browser->profile()->GetPrefs(); | 185 PrefService* prefs1 = browser->profile()->GetPrefs(); |
| 186 prefs1->SetInteger(prefs::kIncognitoModeAvailability, | 186 prefs1->SetInteger(prefs::kIncognitoModeAvailability, |
| 187 IncognitoModePrefs::FORCED); | 187 IncognitoModePrefs::FORCED); |
| 188 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs(); | 188 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs(); |
| 189 prefs2->SetInteger(prefs::kIncognitoModeAvailability, | 189 prefs2->SetInteger(prefs::kIncognitoModeAvailability, |
| 190 IncognitoModePrefs::FORCED); | 190 IncognitoModePrefs::FORCED); |
| 191 | 191 |
| 192 // Navigate to the page. | 192 // Navigate to the page. |
| 193 chrome::NavigateParams params(MakeNavigateParams(browser)); | 193 chrome::NavigateParams params(MakeNavigateParams(browser)); |
| 194 params.disposition = OFF_THE_RECORD; | 194 params.disposition = WindowOpenDisposition::OFF_THE_RECORD; |
| 195 params.url = url; | 195 params.url = url; |
| 196 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 196 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 197 chrome::Navigate(¶ms); | 197 chrome::Navigate(¶ms); |
| 198 | 198 |
| 199 // The page should not be opened. | 199 // The page should not be opened. |
| 200 EXPECT_EQ(browser, params.browser); | 200 EXPECT_EQ(browser, params.browser); |
| 201 EXPECT_EQ(1, browser->tab_strip_model()->count()); | 201 EXPECT_EQ(1, browser->tab_strip_model()->count()); |
| 202 EXPECT_EQ(GURL(url::kAboutBlankURL), | 202 EXPECT_EQ(GURL(url::kAboutBlankURL), |
| 203 browser->tab_strip_model()->GetActiveWebContents()->GetURL()); | 203 browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 204 } | 204 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 255 |
| 256 // We should have one browser with 3 tabs, the 3rd selected. | 256 // We should have one browser with 3 tabs, the 3rd selected. |
| 257 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 257 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 258 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 258 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
| 259 | 259 |
| 260 unsigned int previous_tab_contents_count = | 260 unsigned int previous_tab_contents_count = |
| 261 created_tab_contents_count_ = 0; | 261 created_tab_contents_count_ = 0; |
| 262 | 262 |
| 263 // Navigate to singleton_url1. | 263 // Navigate to singleton_url1. |
| 264 chrome::NavigateParams params(MakeNavigateParams()); | 264 chrome::NavigateParams params(MakeNavigateParams()); |
| 265 params.disposition = SINGLETON_TAB; | 265 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 266 params.url = singleton_url1; | 266 params.url = singleton_url1; |
| 267 chrome::Navigate(¶ms); | 267 chrome::Navigate(¶ms); |
| 268 | 268 |
| 269 // The middle tab should now be selected. | 269 // The middle tab should now be selected. |
| 270 EXPECT_EQ(browser(), params.browser); | 270 EXPECT_EQ(browser(), params.browser); |
| 271 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 271 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 272 | 272 |
| 273 // No tab contents should have been created | 273 // No tab contents should have been created |
| 274 EXPECT_EQ(previous_tab_contents_count, | 274 EXPECT_EQ(previous_tab_contents_count, |
| 275 created_tab_contents_count_); | 275 created_tab_contents_count_); |
| 276 } | 276 } |
| 277 | 277 |
| 278 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 278 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 279 Disposition_SingletonTabRespectingRef) { | 279 Disposition_SingletonTabRespectingRef) { |
| 280 GURL singleton_ref_url1("http://maps.google.com/#a"); | 280 GURL singleton_ref_url1("http://maps.google.com/#a"); |
| 281 GURL singleton_ref_url2("http://maps.google.com/#b"); | 281 GURL singleton_ref_url2("http://maps.google.com/#b"); |
| 282 GURL singleton_ref_url3("http://maps.google.com/"); | 282 GURL singleton_ref_url3("http://maps.google.com/"); |
| 283 | 283 |
| 284 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, | 284 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, |
| 285 ui::PAGE_TRANSITION_LINK); | 285 ui::PAGE_TRANSITION_LINK); |
| 286 | 286 |
| 287 // We should have one browser with 2 tabs, 2nd selected. | 287 // We should have one browser with 2 tabs, 2nd selected. |
| 288 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 288 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 289 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 289 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 290 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 290 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 291 | 291 |
| 292 // Navigate to singleton_url2. | 292 // Navigate to singleton_url2. |
| 293 chrome::NavigateParams params(MakeNavigateParams()); | 293 chrome::NavigateParams params(MakeNavigateParams()); |
| 294 params.disposition = SINGLETON_TAB; | 294 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 295 params.url = singleton_ref_url2; | 295 params.url = singleton_ref_url2; |
| 296 chrome::Navigate(¶ms); | 296 chrome::Navigate(¶ms); |
| 297 | 297 |
| 298 // We should now have 2 tabs, the 2nd one selected. | 298 // We should now have 2 tabs, the 2nd one selected. |
| 299 EXPECT_EQ(browser(), params.browser); | 299 EXPECT_EQ(browser(), params.browser); |
| 300 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 300 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 301 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 301 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 302 | 302 |
| 303 // Navigate to singleton_url2, but with respect ref set. | 303 // Navigate to singleton_url2, but with respect ref set. |
| 304 params = MakeNavigateParams(); | 304 params = MakeNavigateParams(); |
| 305 params.disposition = SINGLETON_TAB; | 305 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 306 params.url = singleton_ref_url2; | 306 params.url = singleton_ref_url2; |
| 307 params.ref_behavior = chrome::NavigateParams::RESPECT_REF; | 307 params.ref_behavior = chrome::NavigateParams::RESPECT_REF; |
| 308 chrome::Navigate(¶ms); | 308 chrome::Navigate(¶ms); |
| 309 | 309 |
| 310 // We should now have 3 tabs, the 3th one selected. | 310 // We should now have 3 tabs, the 3th one selected. |
| 311 EXPECT_EQ(browser(), params.browser); | 311 EXPECT_EQ(browser(), params.browser); |
| 312 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 312 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 313 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 313 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
| 314 | 314 |
| 315 // Navigate to singleton_url3. | 315 // Navigate to singleton_url3. |
| 316 params = MakeNavigateParams(); | 316 params = MakeNavigateParams(); |
| 317 params.disposition = SINGLETON_TAB; | 317 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 318 params.url = singleton_ref_url3; | 318 params.url = singleton_ref_url3; |
| 319 params.ref_behavior = chrome::NavigateParams::RESPECT_REF; | 319 params.ref_behavior = chrome::NavigateParams::RESPECT_REF; |
| 320 chrome::Navigate(¶ms); | 320 chrome::Navigate(¶ms); |
| 321 | 321 |
| 322 // We should now have 4 tabs, the 4th one selected. | 322 // We should now have 4 tabs, the 4th one selected. |
| 323 EXPECT_EQ(browser(), params.browser); | 323 EXPECT_EQ(browser(), params.browser); |
| 324 EXPECT_EQ(4, browser()->tab_strip_model()->count()); | 324 EXPECT_EQ(4, browser()->tab_strip_model()->count()); |
| 325 EXPECT_EQ(3, browser()->tab_strip_model()->active_index()); | 325 EXPECT_EQ(3, browser()->tab_strip_model()->active_index()); |
| 326 } | 326 } |
| 327 | 327 |
| 328 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 328 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 329 Disposition_SingletonTabNoneExisting) { | 329 Disposition_SingletonTabNoneExisting) { |
| 330 GURL singleton_url1("http://maps.google.com/"); | 330 GURL singleton_url1("http://maps.google.com/"); |
| 331 | 331 |
| 332 // We should have one browser with 1 tab. | 332 // We should have one browser with 1 tab. |
| 333 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 333 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 334 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 334 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 335 | 335 |
| 336 // Navigate to singleton_url1. | 336 // Navigate to singleton_url1. |
| 337 chrome::NavigateParams params(MakeNavigateParams()); | 337 chrome::NavigateParams params(MakeNavigateParams()); |
| 338 params.disposition = SINGLETON_TAB; | 338 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 339 params.url = singleton_url1; | 339 params.url = singleton_url1; |
| 340 chrome::Navigate(¶ms); | 340 chrome::Navigate(¶ms); |
| 341 | 341 |
| 342 // We should now have 2 tabs, the 2nd one selected. | 342 // We should now have 2 tabs, the 2nd one selected. |
| 343 EXPECT_EQ(browser(), params.browser); | 343 EXPECT_EQ(browser(), params.browser); |
| 344 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 344 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 345 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 345 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 346 } | 346 } |
| 347 | 347 |
| 348 // This test verifies that when a navigation results in a foreground tab, the | 348 // This test verifies that when a navigation results in a foreground tab, the |
| 349 // tab count of the Browser increases and the selected tab shifts to the new | 349 // tab count of the Browser increases and the selected tab shifts to the new |
| 350 // foreground tab. | 350 // foreground tab. |
| 351 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { | 351 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { |
| 352 WebContents* old_contents = | 352 WebContents* old_contents = |
| 353 browser()->tab_strip_model()->GetActiveWebContents(); | 353 browser()->tab_strip_model()->GetActiveWebContents(); |
| 354 chrome::NavigateParams params(MakeNavigateParams()); | 354 chrome::NavigateParams params(MakeNavigateParams()); |
| 355 params.disposition = NEW_FOREGROUND_TAB; | 355 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 356 chrome::Navigate(¶ms); | 356 chrome::Navigate(¶ms); |
| 357 EXPECT_NE(old_contents, | 357 EXPECT_NE(old_contents, |
| 358 browser()->tab_strip_model()->GetActiveWebContents()); | 358 browser()->tab_strip_model()->GetActiveWebContents()); |
| 359 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), | 359 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), |
| 360 params.target_contents); | 360 params.target_contents); |
| 361 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 361 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // This test verifies that when a navigation results in a background tab, the | 364 // This test verifies that when a navigation results in a background tab, the |
| 365 // tab count of the Browser increases but the selected tab remains the same. | 365 // tab count of the Browser increases but the selected tab remains the same. |
| 366 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { | 366 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { |
| 367 WebContents* old_contents = | 367 WebContents* old_contents = |
| 368 browser()->tab_strip_model()->GetActiveWebContents(); | 368 browser()->tab_strip_model()->GetActiveWebContents(); |
| 369 chrome::NavigateParams params(MakeNavigateParams()); | 369 chrome::NavigateParams params(MakeNavigateParams()); |
| 370 params.disposition = NEW_BACKGROUND_TAB; | 370 params.disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB; |
| 371 chrome::Navigate(¶ms); | 371 chrome::Navigate(¶ms); |
| 372 WebContents* new_contents = | 372 WebContents* new_contents = |
| 373 browser()->tab_strip_model()->GetActiveWebContents(); | 373 browser()->tab_strip_model()->GetActiveWebContents(); |
| 374 // The selected tab should have remained unchanged, since the new tab was | 374 // The selected tab should have remained unchanged, since the new tab was |
| 375 // opened in the background. | 375 // opened in the background. |
| 376 EXPECT_EQ(old_contents, new_contents); | 376 EXPECT_EQ(old_contents, new_contents); |
| 377 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 377 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 378 } | 378 } |
| 379 | 379 |
| 380 // This test verifies that when a navigation requiring a new foreground tab | 380 // This test verifies that when a navigation requiring a new foreground tab |
| 381 // occurs in a Browser that cannot host multiple tabs, the new foreground tab | 381 // occurs in a Browser that cannot host multiple tabs, the new foreground tab |
| 382 // is created in an existing compatible Browser. | 382 // is created in an existing compatible Browser. |
| 383 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 383 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 384 Disposition_IncompatibleWindow_Existing) { | 384 Disposition_IncompatibleWindow_Existing) { |
| 385 // Open a foreground tab in a window that cannot open popups when there is an | 385 // Open a foreground tab in a window that cannot open popups when there is an |
| 386 // existing compatible window somewhere else that they can be opened within. | 386 // existing compatible window somewhere else that they can be opened within. |
| 387 Browser* popup = CreateEmptyBrowserForType(Browser::TYPE_POPUP, | 387 Browser* popup = CreateEmptyBrowserForType(Browser::TYPE_POPUP, |
| 388 browser()->profile()); | 388 browser()->profile()); |
| 389 chrome::NavigateParams params(MakeNavigateParams(popup)); | 389 chrome::NavigateParams params(MakeNavigateParams(popup)); |
| 390 params.disposition = NEW_FOREGROUND_TAB; | 390 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 391 chrome::Navigate(¶ms); | 391 chrome::Navigate(¶ms); |
| 392 | 392 |
| 393 // Navigate() should have opened the tab in a different browser since the | 393 // Navigate() should have opened the tab in a different browser since the |
| 394 // one we supplied didn't support additional tabs. | 394 // one we supplied didn't support additional tabs. |
| 395 EXPECT_NE(popup, params.browser); | 395 EXPECT_NE(popup, params.browser); |
| 396 | 396 |
| 397 // Since browser() is an existing compatible tabbed browser, it should have | 397 // Since browser() is an existing compatible tabbed browser, it should have |
| 398 // opened the tab there. | 398 // opened the tab there. |
| 399 EXPECT_EQ(browser(), params.browser); | 399 EXPECT_EQ(browser(), params.browser); |
| 400 | 400 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 413 // We want to simulate not being able to find an existing window compatible | 413 // We want to simulate not being able to find an existing window compatible |
| 414 // with our non-tabbed browser window so Navigate() is forced to create a | 414 // with our non-tabbed browser window so Navigate() is forced to create a |
| 415 // new compatible window. Because browser() supplied by the in-process | 415 // new compatible window. Because browser() supplied by the in-process |
| 416 // browser testing framework is compatible with browser()->profile(), we | 416 // browser testing framework is compatible with browser()->profile(), we |
| 417 // need a different profile, and creating a popup window with an incognito | 417 // need a different profile, and creating a popup window with an incognito |
| 418 // profile is a quick and dirty way of achieving this. | 418 // profile is a quick and dirty way of achieving this. |
| 419 Browser* popup = CreateEmptyBrowserForType( | 419 Browser* popup = CreateEmptyBrowserForType( |
| 420 Browser::TYPE_POPUP, | 420 Browser::TYPE_POPUP, |
| 421 browser()->profile()->GetOffTheRecordProfile()); | 421 browser()->profile()->GetOffTheRecordProfile()); |
| 422 chrome::NavigateParams params(MakeNavigateParams(popup)); | 422 chrome::NavigateParams params(MakeNavigateParams(popup)); |
| 423 params.disposition = NEW_FOREGROUND_TAB; | 423 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 424 chrome::Navigate(¶ms); | 424 chrome::Navigate(¶ms); |
| 425 | 425 |
| 426 // Navigate() should have opened the tab in a different browser since the | 426 // Navigate() should have opened the tab in a different browser since the |
| 427 // one we supplied didn't support additional tabs. | 427 // one we supplied didn't support additional tabs. |
| 428 EXPECT_NE(popup, params.browser); | 428 EXPECT_NE(popup, params.browser); |
| 429 | 429 |
| 430 // This time, browser() is _not_ compatible with popup since it is not an | 430 // This time, browser() is _not_ compatible with popup since it is not an |
| 431 // incognito window. | 431 // incognito window. |
| 432 EXPECT_NE(browser(), params.browser); | 432 EXPECT_NE(browser(), params.browser); |
| 433 | 433 |
| 434 // We should have three windows, each with one tab: | 434 // We should have three windows, each with one tab: |
| 435 // 1. the browser() provided by the framework (unchanged in this test) | 435 // 1. the browser() provided by the framework (unchanged in this test) |
| 436 // 2. the incognito popup we created originally | 436 // 2. the incognito popup we created originally |
| 437 // 3. the new incognito tabbed browser that was created by Navigate(). | 437 // 3. the new incognito tabbed browser that was created by Navigate(). |
| 438 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); | 438 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); |
| 439 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 439 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 440 EXPECT_EQ(1, popup->tab_strip_model()->count()); | 440 EXPECT_EQ(1, popup->tab_strip_model()->count()); |
| 441 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); | 441 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); |
| 442 EXPECT_TRUE(params.browser->is_type_tabbed()); | 442 EXPECT_TRUE(params.browser->is_type_tabbed()); |
| 443 } | 443 } |
| 444 | 444 |
| 445 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 445 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 446 // from a normal Browser results in a new Browser with TYPE_POPUP. | 446 // from a normal Browser results in a new Browser with TYPE_POPUP. |
| 447 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { | 447 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { |
| 448 chrome::NavigateParams params(MakeNavigateParams()); | 448 chrome::NavigateParams params(MakeNavigateParams()); |
| 449 params.disposition = NEW_POPUP; | 449 params.disposition = WindowOpenDisposition::NEW_POPUP; |
| 450 params.window_bounds = gfx::Rect(0, 0, 200, 200); | 450 params.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 451 // Wait for new popup to to load and gain focus. | 451 // Wait for new popup to to load and gain focus. |
| 452 ui_test_utils::NavigateToURL(¶ms); | 452 ui_test_utils::NavigateToURL(¶ms); |
| 453 | 453 |
| 454 // Navigate() should have opened a new, focused popup window. | 454 // Navigate() should have opened a new, focused popup window. |
| 455 EXPECT_NE(browser(), params.browser); | 455 EXPECT_NE(browser(), params.browser); |
| 456 #if 0 | 456 #if 0 |
| 457 // TODO(stevenjb): Enable this test. See: crbug.com/79493 | 457 // TODO(stevenjb): Enable this test. See: crbug.com/79493 |
| 458 EXPECT_TRUE(browser->window()->IsActive()); | 458 EXPECT_TRUE(browser->window()->IsActive()); |
| 459 #endif | 459 #endif |
| 460 EXPECT_TRUE(params.browser->is_type_popup()); | 460 EXPECT_TRUE(params.browser->is_type_popup()); |
| 461 EXPECT_FALSE(params.browser->is_app()); | 461 EXPECT_FALSE(params.browser->is_app()); |
| 462 | 462 |
| 463 // We should have two windows, the browser() provided by the framework and the | 463 // We should have two windows, the browser() provided by the framework and the |
| 464 // new popup window. | 464 // new popup window. |
| 465 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 465 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 466 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 466 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 467 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); | 467 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); |
| 468 } | 468 } |
| 469 | 469 |
| 470 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 470 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 471 // from a normal Browser results in a new Browser with is_app() true. | 471 // from a normal Browser results in a new Browser with is_app() true. |
| 472 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) { | 472 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) { |
| 473 chrome::NavigateParams params(MakeNavigateParams()); | 473 chrome::NavigateParams params(MakeNavigateParams()); |
| 474 params.disposition = NEW_POPUP; | 474 params.disposition = WindowOpenDisposition::NEW_POPUP; |
| 475 params.extension_app_id = "extensionappid"; | 475 params.extension_app_id = "extensionappid"; |
| 476 params.window_bounds = gfx::Rect(0, 0, 200, 200); | 476 params.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 477 // Wait for new popup to to load and gain focus. | 477 // Wait for new popup to to load and gain focus. |
| 478 ui_test_utils::NavigateToURL(¶ms); | 478 ui_test_utils::NavigateToURL(¶ms); |
| 479 | 479 |
| 480 // Navigate() should have opened a new, focused popup window. | 480 // Navigate() should have opened a new, focused popup window. |
| 481 EXPECT_NE(browser(), params.browser); | 481 EXPECT_NE(browser(), params.browser); |
| 482 EXPECT_TRUE(params.browser->is_type_popup()); | 482 EXPECT_TRUE(params.browser->is_type_popup()); |
| 483 EXPECT_TRUE(params.browser->is_app()); | 483 EXPECT_TRUE(params.browser->is_app()); |
| 484 | 484 |
| 485 // We should have two windows, the browser() provided by the framework and the | 485 // We should have two windows, the browser() provided by the framework and the |
| 486 // new popup window. | 486 // new popup window. |
| 487 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 487 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 488 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 488 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 489 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); | 489 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); |
| 490 } | 490 } |
| 491 | 491 |
| 492 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 492 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 493 // from a normal popup results in a new Browser with TYPE_POPUP. | 493 // from a normal popup results in a new Browser with TYPE_POPUP. |
| 494 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { | 494 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { |
| 495 // Open a popup. | 495 // Open a popup. |
| 496 chrome::NavigateParams params1(MakeNavigateParams()); | 496 chrome::NavigateParams params1(MakeNavigateParams()); |
| 497 params1.disposition = NEW_POPUP; | 497 params1.disposition = WindowOpenDisposition::NEW_POPUP; |
| 498 params1.window_bounds = gfx::Rect(0, 0, 200, 200); | 498 params1.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 499 chrome::Navigate(¶ms1); | 499 chrome::Navigate(¶ms1); |
| 500 // Open another popup. | 500 // Open another popup. |
| 501 chrome::NavigateParams params2(MakeNavigateParams(params1.browser)); | 501 chrome::NavigateParams params2(MakeNavigateParams(params1.browser)); |
| 502 params2.disposition = NEW_POPUP; | 502 params2.disposition = WindowOpenDisposition::NEW_POPUP; |
| 503 params2.window_bounds = gfx::Rect(0, 0, 200, 200); | 503 params2.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 504 chrome::Navigate(¶ms2); | 504 chrome::Navigate(¶ms2); |
| 505 | 505 |
| 506 // Navigate() should have opened a new normal popup window. | 506 // Navigate() should have opened a new normal popup window. |
| 507 EXPECT_NE(params1.browser, params2.browser); | 507 EXPECT_NE(params1.browser, params2.browser); |
| 508 EXPECT_TRUE(params2.browser->is_type_popup()); | 508 EXPECT_TRUE(params2.browser->is_type_popup()); |
| 509 EXPECT_FALSE(params2.browser->is_app()); | 509 EXPECT_FALSE(params2.browser->is_app()); |
| 510 | 510 |
| 511 // We should have three windows, the browser() provided by the framework, | 511 // We should have three windows, the browser() provided by the framework, |
| 512 // the first popup window, and the second popup window. | 512 // the first popup window, and the second popup window. |
| 513 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); | 513 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); |
| 514 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 514 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 515 EXPECT_EQ(1, params1.browser->tab_strip_model()->count()); | 515 EXPECT_EQ(1, params1.browser->tab_strip_model()->count()); |
| 516 EXPECT_EQ(1, params2.browser->tab_strip_model()->count()); | 516 EXPECT_EQ(1, params2.browser->tab_strip_model()->count()); |
| 517 } | 517 } |
| 518 | 518 |
| 519 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 519 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 520 // from an app frame results in a new Browser with TYPE_POPUP. | 520 // from an app frame results in a new Browser with TYPE_POPUP. |
| 521 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 521 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 522 Disposition_NewPopupFromAppWindow) { | 522 Disposition_NewPopupFromAppWindow) { |
| 523 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile()); | 523 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile()); |
| 524 chrome::NavigateParams params(MakeNavigateParams(app_browser)); | 524 chrome::NavigateParams params(MakeNavigateParams(app_browser)); |
| 525 params.disposition = NEW_POPUP; | 525 params.disposition = WindowOpenDisposition::NEW_POPUP; |
| 526 params.window_bounds = gfx::Rect(0, 0, 200, 200); | 526 params.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 527 chrome::Navigate(¶ms); | 527 chrome::Navigate(¶ms); |
| 528 | 528 |
| 529 // Navigate() should have opened a new popup app window. | 529 // Navigate() should have opened a new popup app window. |
| 530 EXPECT_NE(app_browser, params.browser); | 530 EXPECT_NE(app_browser, params.browser); |
| 531 EXPECT_NE(browser(), params.browser); | 531 EXPECT_NE(browser(), params.browser); |
| 532 EXPECT_TRUE(params.browser->is_type_popup()); | 532 EXPECT_TRUE(params.browser->is_type_popup()); |
| 533 EXPECT_TRUE(params.browser->is_app()); | 533 EXPECT_TRUE(params.browser->is_app()); |
| 534 | 534 |
| 535 // We should now have three windows, the app window, the app popup it created, | 535 // We should now have three windows, the app window, the app popup it created, |
| 536 // and the original browser() provided by the framework. | 536 // and the original browser() provided by the framework. |
| 537 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); | 537 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); |
| 538 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 538 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 539 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); | 539 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); |
| 540 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); | 540 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); |
| 541 } | 541 } |
| 542 | 542 |
| 543 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 543 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 544 // from an app popup results in a new Browser also of TYPE_POPUP. | 544 // from an app popup results in a new Browser also of TYPE_POPUP. |
| 545 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 545 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 546 Disposition_NewPopupFromAppPopup) { | 546 Disposition_NewPopupFromAppPopup) { |
| 547 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile()); | 547 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile()); |
| 548 // Open an app popup. | 548 // Open an app popup. |
| 549 chrome::NavigateParams params1(MakeNavigateParams(app_browser)); | 549 chrome::NavigateParams params1(MakeNavigateParams(app_browser)); |
| 550 params1.disposition = NEW_POPUP; | 550 params1.disposition = WindowOpenDisposition::NEW_POPUP; |
| 551 params1.window_bounds = gfx::Rect(0, 0, 200, 200); | 551 params1.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 552 chrome::Navigate(¶ms1); | 552 chrome::Navigate(¶ms1); |
| 553 // Now open another app popup. | 553 // Now open another app popup. |
| 554 chrome::NavigateParams params2(MakeNavigateParams(params1.browser)); | 554 chrome::NavigateParams params2(MakeNavigateParams(params1.browser)); |
| 555 params2.disposition = NEW_POPUP; | 555 params2.disposition = WindowOpenDisposition::NEW_POPUP; |
| 556 params2.window_bounds = gfx::Rect(0, 0, 200, 200); | 556 params2.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 557 chrome::Navigate(¶ms2); | 557 chrome::Navigate(¶ms2); |
| 558 | 558 |
| 559 // Navigate() should have opened a new popup app window. | 559 // Navigate() should have opened a new popup app window. |
| 560 EXPECT_NE(browser(), params1.browser); | 560 EXPECT_NE(browser(), params1.browser); |
| 561 EXPECT_NE(params1.browser, params2.browser); | 561 EXPECT_NE(params1.browser, params2.browser); |
| 562 EXPECT_TRUE(params2.browser->is_type_popup()); | 562 EXPECT_TRUE(params2.browser->is_type_popup()); |
| 563 EXPECT_TRUE(params2.browser->is_app()); | 563 EXPECT_TRUE(params2.browser->is_app()); |
| 564 | 564 |
| 565 // We should now have four windows, the app window, the first app popup, | 565 // We should now have four windows, the app window, the first app popup, |
| 566 // the second app popup, and the original browser() provided by the framework. | 566 // the second app popup, and the original browser() provided by the framework. |
| 567 EXPECT_EQ(4u, chrome::GetTotalBrowserCount()); | 567 EXPECT_EQ(4u, chrome::GetTotalBrowserCount()); |
| 568 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 568 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 569 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); | 569 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); |
| 570 EXPECT_EQ(1, params1.browser->tab_strip_model()->count()); | 570 EXPECT_EQ(1, params1.browser->tab_strip_model()->count()); |
| 571 EXPECT_EQ(1, params2.browser->tab_strip_model()->count()); | 571 EXPECT_EQ(1, params2.browser->tab_strip_model()->count()); |
| 572 } | 572 } |
| 573 | 573 |
| 574 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 574 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 575 // from an extension app tab results in a new Browser with TYPE_APP_POPUP. | 575 // from an extension app tab results in a new Browser with TYPE_APP_POPUP. |
| 576 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 576 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 577 Disposition_NewPopupFromExtensionApp) { | 577 Disposition_NewPopupFromExtensionApp) { |
| 578 // TODO(beng): TBD. | 578 // TODO(beng): TBD. |
| 579 } | 579 } |
| 580 | 580 |
| 581 // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE | 581 // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE |
| 582 // does not focus a new new popup window. | 582 // does not focus a new new popup window. |
| 583 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) { | 583 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) { |
| 584 chrome::NavigateParams params(MakeNavigateParams()); | 584 chrome::NavigateParams params(MakeNavigateParams()); |
| 585 params.disposition = NEW_POPUP; | 585 params.disposition = WindowOpenDisposition::NEW_POPUP; |
| 586 params.window_bounds = gfx::Rect(0, 0, 200, 200); | 586 params.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 587 params.window_action = chrome::NavigateParams::SHOW_WINDOW_INACTIVE; | 587 params.window_action = chrome::NavigateParams::SHOW_WINDOW_INACTIVE; |
| 588 // Wait for new popup to load (and gain focus if the test fails). | 588 // Wait for new popup to load (and gain focus if the test fails). |
| 589 ui_test_utils::NavigateToURL(¶ms); | 589 ui_test_utils::NavigateToURL(¶ms); |
| 590 | 590 |
| 591 // Navigate() should have opened a new, unfocused, popup window. | 591 // Navigate() should have opened a new, unfocused, popup window. |
| 592 EXPECT_NE(browser(), params.browser); | 592 EXPECT_NE(browser(), params.browser); |
| 593 EXPECT_EQ(Browser::TYPE_POPUP, params.browser->type()); | 593 EXPECT_EQ(Browser::TYPE_POPUP, params.browser->type()); |
| 594 #if 0 | 594 #if 0 |
| 595 // TODO(stevenjb): Enable this test. See: crbug.com/79493 | 595 // TODO(stevenjb): Enable this test. See: crbug.com/79493 |
| 596 EXPECT_FALSE(p.browser->window()->IsActive()); | 596 EXPECT_FALSE(p.browser->window()->IsActive()); |
| 597 #endif | 597 #endif |
| 598 } | 598 } |
| 599 | 599 |
| 600 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP | 600 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 601 // and trusted_source = true results in a new Browser where is_trusted_source() | 601 // and trusted_source = true results in a new Browser where is_trusted_source() |
| 602 // is true. | 602 // is true. |
| 603 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupTrusted) { | 603 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupTrusted) { |
| 604 chrome::NavigateParams params(MakeNavigateParams()); | 604 chrome::NavigateParams params(MakeNavigateParams()); |
| 605 params.disposition = NEW_POPUP; | 605 params.disposition = WindowOpenDisposition::NEW_POPUP; |
| 606 params.trusted_source = true; | 606 params.trusted_source = true; |
| 607 params.window_bounds = gfx::Rect(0, 0, 200, 200); | 607 params.window_bounds = gfx::Rect(0, 0, 200, 200); |
| 608 // Wait for new popup to to load and gain focus. | 608 // Wait for new popup to to load and gain focus. |
| 609 ui_test_utils::NavigateToURL(¶ms); | 609 ui_test_utils::NavigateToURL(¶ms); |
| 610 | 610 |
| 611 // Navigate() should have opened a new popup window of TYPE_TRUSTED_POPUP. | 611 // Navigate() should have opened a new popup window of TYPE_TRUSTED_POPUP. |
| 612 EXPECT_NE(browser(), params.browser); | 612 EXPECT_NE(browser(), params.browser); |
| 613 EXPECT_TRUE(params.browser->is_type_popup()); | 613 EXPECT_TRUE(params.browser->is_type_popup()); |
| 614 EXPECT_TRUE(params.browser->is_trusted_source()); | 614 EXPECT_TRUE(params.browser->is_trusted_source()); |
| 615 } | 615 } |
| 616 | 616 |
| 617 | 617 |
| 618 // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW | 618 // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW |
| 619 // always opens a new window. | 619 // always opens a new window. |
| 620 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) { | 620 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) { |
| 621 chrome::NavigateParams params(MakeNavigateParams()); | 621 chrome::NavigateParams params(MakeNavigateParams()); |
| 622 params.disposition = NEW_WINDOW; | 622 params.disposition = WindowOpenDisposition::NEW_WINDOW; |
| 623 chrome::Navigate(¶ms); | 623 chrome::Navigate(¶ms); |
| 624 | 624 |
| 625 // Navigate() should have opened a new toplevel window. | 625 // Navigate() should have opened a new toplevel window. |
| 626 EXPECT_NE(browser(), params.browser); | 626 EXPECT_NE(browser(), params.browser); |
| 627 EXPECT_TRUE(params.browser->is_type_tabbed()); | 627 EXPECT_TRUE(params.browser->is_type_tabbed()); |
| 628 | 628 |
| 629 // We should now have two windows, the browser() provided by the framework and | 629 // We should now have two windows, the browser() provided by the framework and |
| 630 // the new normal window. | 630 // the new normal window. |
| 631 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 631 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 632 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 632 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 633 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); | 633 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); |
| 634 } | 634 } |
| 635 | 635 |
| 636 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO | 636 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO |
| 637 // opens a new incognito window if no existing incognito window is present. | 637 // opens a new incognito window if no existing incognito window is present. |
| 638 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { | 638 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { |
| 639 chrome::NavigateParams params(MakeNavigateParams()); | 639 chrome::NavigateParams params(MakeNavigateParams()); |
| 640 params.disposition = OFF_THE_RECORD; | 640 params.disposition = WindowOpenDisposition::OFF_THE_RECORD; |
| 641 chrome::Navigate(¶ms); | 641 chrome::Navigate(¶ms); |
| 642 | 642 |
| 643 // Navigate() should have opened a new toplevel incognito window. | 643 // Navigate() should have opened a new toplevel incognito window. |
| 644 EXPECT_NE(browser(), params.browser); | 644 EXPECT_NE(browser(), params.browser); |
| 645 EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(), | 645 EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(), |
| 646 params.browser->profile()); | 646 params.browser->profile()); |
| 647 | 647 |
| 648 // |source_contents| should be set to NULL because the profile for the new | 648 // |source_contents| should be set to NULL because the profile for the new |
| 649 // page is different from the originating page. | 649 // page is different from the originating page. |
| 650 EXPECT_EQ(NULL, params.source_contents); | 650 EXPECT_EQ(NULL, params.source_contents); |
| 651 | 651 |
| 652 // We should now have two windows, the browser() provided by the framework and | 652 // We should now have two windows, the browser() provided by the framework and |
| 653 // the new incognito window. | 653 // the new incognito window. |
| 654 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 654 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 655 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 655 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 656 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); | 656 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); |
| 657 } | 657 } |
| 658 | 658 |
| 659 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO | 659 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO |
| 660 // reuses an existing incognito window when possible. | 660 // reuses an existing incognito window when possible. |
| 661 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { | 661 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { |
| 662 Browser* incognito_browser = | 662 Browser* incognito_browser = |
| 663 CreateEmptyBrowserForType(Browser::TYPE_TABBED, | 663 CreateEmptyBrowserForType(Browser::TYPE_TABBED, |
| 664 browser()->profile()->GetOffTheRecordProfile()); | 664 browser()->profile()->GetOffTheRecordProfile()); |
| 665 chrome::NavigateParams params(MakeNavigateParams()); | 665 chrome::NavigateParams params(MakeNavigateParams()); |
| 666 params.disposition = OFF_THE_RECORD; | 666 params.disposition = WindowOpenDisposition::OFF_THE_RECORD; |
| 667 chrome::Navigate(¶ms); | 667 chrome::Navigate(¶ms); |
| 668 | 668 |
| 669 // Navigate() should have opened a new tab in the existing incognito window. | 669 // Navigate() should have opened a new tab in the existing incognito window. |
| 670 EXPECT_NE(browser(), params.browser); | 670 EXPECT_NE(browser(), params.browser); |
| 671 EXPECT_EQ(params.browser, incognito_browser); | 671 EXPECT_EQ(params.browser, incognito_browser); |
| 672 | 672 |
| 673 // We should now have two windows, the browser() provided by the framework and | 673 // We should now have two windows, the browser() provided by the framework and |
| 674 // the incognito window we opened earlier. | 674 // the incognito window we opened earlier. |
| 675 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 675 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
| 676 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 676 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 677 EXPECT_EQ(2, incognito_browser->tab_strip_model()->count()); | 677 EXPECT_EQ(2, incognito_browser->tab_strip_model()->count()); |
| 678 } | 678 } |
| 679 | 679 |
| 680 // This test verifies that no navigation action occurs when | 680 // This test verifies that no navigation action occurs when |
| 681 // WindowOpenDisposition = SAVE_TO_DISK. | 681 // WindowOpenDisposition = SAVE_TO_DISK. |
| 682 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) { | 682 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) { |
| 683 RunSuppressTest(SAVE_TO_DISK); | 683 RunSuppressTest(WindowOpenDisposition::SAVE_TO_DISK); |
| 684 } | 684 } |
| 685 | 685 |
| 686 // This test verifies that no navigation action occurs when | 686 // This test verifies that no navigation action occurs when |
| 687 // WindowOpenDisposition = IGNORE_ACTION. | 687 // WindowOpenDisposition = IGNORE_ACTION. |
| 688 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) { | 688 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) { |
| 689 RunSuppressTest(IGNORE_ACTION); | 689 RunSuppressTest(WindowOpenDisposition::IGNORE_ACTION); |
| 690 } | 690 } |
| 691 | 691 |
| 692 // This tests adding a foreground tab with a predefined WebContents. | 692 // This tests adding a foreground tab with a predefined WebContents. |
| 693 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { | 693 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { |
| 694 chrome::NavigateParams params(MakeNavigateParams()); | 694 chrome::NavigateParams params(MakeNavigateParams()); |
| 695 params.disposition = NEW_FOREGROUND_TAB; | 695 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 696 params.target_contents = CreateWebContents(false); | 696 params.target_contents = CreateWebContents(false); |
| 697 chrome::Navigate(¶ms); | 697 chrome::Navigate(¶ms); |
| 698 | 698 |
| 699 // Navigate() should have opened the contents in a new foreground tab in the | 699 // Navigate() should have opened the contents in a new foreground tab in the |
| 700 // current Browser. | 700 // current Browser. |
| 701 EXPECT_EQ(browser(), params.browser); | 701 EXPECT_EQ(browser(), params.browser); |
| 702 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), | 702 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), |
| 703 params.target_contents); | 703 params.target_contents); |
| 704 | 704 |
| 705 // We should have one window, with two tabs. | 705 // We should have one window, with two tabs. |
| 706 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 706 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 707 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 707 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 708 } | 708 } |
| 709 | 709 |
| 710 #if defined(OS_WIN) | 710 #if defined(OS_WIN) |
| 711 // This tests adding a popup with a predefined WebContents. | 711 // This tests adding a popup with a predefined WebContents. |
| 712 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { | 712 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { |
| 713 chrome::NavigateParams params(MakeNavigateParams()); | 713 chrome::NavigateParams params(MakeNavigateParams()); |
| 714 params.disposition = NEW_POPUP; | 714 params.disposition = WindowOpenDisposition::NEW_POPUP; |
| 715 params.target_contents = CreateWebContents(false); | 715 params.target_contents = CreateWebContents(false); |
| 716 params.window_bounds = gfx::Rect(10, 10, 500, 500); | 716 params.window_bounds = gfx::Rect(10, 10, 500, 500); |
| 717 chrome::Navigate(¶ms); | 717 chrome::Navigate(¶ms); |
| 718 | 718 |
| 719 // Navigate() should have opened a new popup window. | 719 // Navigate() should have opened a new popup window. |
| 720 EXPECT_NE(browser(), params.browser); | 720 EXPECT_NE(browser(), params.browser); |
| 721 EXPECT_TRUE(params.browser->is_type_popup()); | 721 EXPECT_TRUE(params.browser->is_type_popup()); |
| 722 EXPECT_FALSE(params.browser->is_app()); | 722 EXPECT_FALSE(params.browser->is_app()); |
| 723 | 723 |
| 724 // The web platform is weird. The window bounds specified in | 724 // The web platform is weird. The window bounds specified in |
| (...skipping 19 matching lines...) Expand all Loading... |
| 744 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 744 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 745 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); | 745 EXPECT_EQ(1, params.browser->tab_strip_model()->count()); |
| 746 } | 746 } |
| 747 #endif | 747 #endif |
| 748 | 748 |
| 749 // This test checks that we can create WebContents with renderer process and | 749 // This test checks that we can create WebContents with renderer process and |
| 750 // RenderFrame without navigating it. | 750 // RenderFrame without navigating it. |
| 751 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 751 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 752 CreateWebContentsWithRendererProcess) { | 752 CreateWebContentsWithRendererProcess) { |
| 753 chrome::NavigateParams params(MakeNavigateParams()); | 753 chrome::NavigateParams params(MakeNavigateParams()); |
| 754 params.disposition = NEW_FOREGROUND_TAB; | 754 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 755 params.target_contents = CreateWebContents(true); | 755 params.target_contents = CreateWebContents(true); |
| 756 ASSERT_TRUE(params.target_contents); | 756 ASSERT_TRUE(params.target_contents); |
| 757 | 757 |
| 758 // There is no navigation (to about:blank or something like that). | 758 // There is no navigation (to about:blank or something like that). |
| 759 EXPECT_FALSE(params.target_contents->IsLoading()); | 759 EXPECT_FALSE(params.target_contents->IsLoading()); |
| 760 | 760 |
| 761 ASSERT_TRUE(params.target_contents->GetMainFrame()); | 761 ASSERT_TRUE(params.target_contents->GetMainFrame()); |
| 762 EXPECT_TRUE(params.target_contents->GetMainFrame()->IsRenderFrameLive()); | 762 EXPECT_TRUE(params.target_contents->GetMainFrame()->IsRenderFrameLive()); |
| 763 EXPECT_TRUE( | 763 EXPECT_TRUE( |
| 764 params.target_contents->GetController().IsInitialBlankNavigation()); | 764 params.target_contents->GetController().IsInitialBlankNavigation()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 786 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 786 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 787 } | 787 } |
| 788 | 788 |
| 789 // This tests adding a tab at a specific index. | 789 // This tests adding a tab at a specific index. |
| 790 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) { | 790 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) { |
| 791 // This is not meant to be a comprehensive test of whether or not the tab | 791 // This is not meant to be a comprehensive test of whether or not the tab |
| 792 // implementation of the browser observes the insertion index. That is | 792 // implementation of the browser observes the insertion index. That is |
| 793 // covered by the unit tests for TabStripModel. This merely verifies that | 793 // covered by the unit tests for TabStripModel. This merely verifies that |
| 794 // insertion index preference is reflected in common cases. | 794 // insertion index preference is reflected in common cases. |
| 795 chrome::NavigateParams params(MakeNavigateParams()); | 795 chrome::NavigateParams params(MakeNavigateParams()); |
| 796 params.disposition = NEW_FOREGROUND_TAB; | 796 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 797 params.tabstrip_index = 0; | 797 params.tabstrip_index = 0; |
| 798 params.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; | 798 params.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; |
| 799 chrome::Navigate(¶ms); | 799 chrome::Navigate(¶ms); |
| 800 | 800 |
| 801 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. | 801 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. |
| 802 EXPECT_EQ(browser(), params.browser); | 802 EXPECT_EQ(browser(), params.browser); |
| 803 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfWebContents( | 803 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfWebContents( |
| 804 static_cast<const WebContents*>(params.target_contents))); | 804 static_cast<const WebContents*>(params.target_contents))); |
| 805 | 805 |
| 806 // We should have one window - the browser() provided by the framework. | 806 // We should have one window - the browser() provided by the framework. |
| 807 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 807 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 808 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 808 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 809 } | 809 } |
| 810 | 810 |
| 811 // This test verifies that constructing params with disposition = SINGLETON_TAB | 811 // This test verifies that constructing params with disposition = SINGLETON_TAB |
| 812 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if | 812 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if |
| 813 // no previous tab with that URL (minus the path) exists. | 813 // no previous tab with that URL (minus the path) exists. |
| 814 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 814 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 815 Disposition_SingletonTabNew_IgnorePath) { | 815 Disposition_SingletonTabNew_IgnorePath) { |
| 816 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 816 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
| 817 ui::PAGE_TRANSITION_LINK); | 817 ui::PAGE_TRANSITION_LINK); |
| 818 | 818 |
| 819 // We should have one browser with 2 tabs, the 2nd selected. | 819 // We should have one browser with 2 tabs, the 2nd selected. |
| 820 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 820 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 821 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 821 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 822 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 822 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 823 | 823 |
| 824 // Navigate to a new singleton tab with a sub-page. | 824 // Navigate to a new singleton tab with a sub-page. |
| 825 chrome::NavigateParams params(MakeNavigateParams()); | 825 chrome::NavigateParams params(MakeNavigateParams()); |
| 826 params.disposition = SINGLETON_TAB; | 826 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 827 params.url = GetContentSettingsURL(); | 827 params.url = GetContentSettingsURL(); |
| 828 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 828 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 829 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 829 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
| 830 chrome::Navigate(¶ms); | 830 chrome::Navigate(¶ms); |
| 831 | 831 |
| 832 // The last tab should now be selected and navigated to the sub-page of the | 832 // The last tab should now be selected and navigated to the sub-page of the |
| 833 // URL. | 833 // URL. |
| 834 EXPECT_EQ(browser(), params.browser); | 834 EXPECT_EQ(browser(), params.browser); |
| 835 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 835 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 836 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 836 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 850 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 850 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
| 851 ui::PAGE_TRANSITION_LINK); | 851 ui::PAGE_TRANSITION_LINK); |
| 852 | 852 |
| 853 // We should have one browser with 3 tabs, the 3rd selected. | 853 // We should have one browser with 3 tabs, the 3rd selected. |
| 854 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 854 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 855 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 855 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 856 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 856 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
| 857 | 857 |
| 858 // Navigate to singleton_url1. | 858 // Navigate to singleton_url1. |
| 859 chrome::NavigateParams params(MakeNavigateParams()); | 859 chrome::NavigateParams params(MakeNavigateParams()); |
| 860 params.disposition = SINGLETON_TAB; | 860 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 861 params.url = GetContentSettingsURL(); | 861 params.url = GetContentSettingsURL(); |
| 862 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 862 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 863 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 863 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
| 864 chrome::Navigate(¶ms); | 864 chrome::Navigate(¶ms); |
| 865 | 865 |
| 866 // The middle tab should now be selected and navigated to the sub-page of the | 866 // The middle tab should now be selected and navigated to the sub-page of the |
| 867 // URL. | 867 // URL. |
| 868 EXPECT_EQ(browser(), params.browser); | 868 EXPECT_EQ(browser(), params.browser); |
| 869 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 869 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 870 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 870 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 884 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 884 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
| 885 ui::PAGE_TRANSITION_LINK); | 885 ui::PAGE_TRANSITION_LINK); |
| 886 | 886 |
| 887 // We should have one browser with 3 tabs, the 3rd selected. | 887 // We should have one browser with 3 tabs, the 3rd selected. |
| 888 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 888 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 889 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 889 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 890 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 890 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
| 891 | 891 |
| 892 // Navigate to singleton_url1. | 892 // Navigate to singleton_url1. |
| 893 chrome::NavigateParams params(MakeNavigateParams()); | 893 chrome::NavigateParams params(MakeNavigateParams()); |
| 894 params.disposition = SINGLETON_TAB; | 894 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 895 params.url = GetClearBrowsingDataURL(); | 895 params.url = GetClearBrowsingDataURL(); |
| 896 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 896 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 897 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 897 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
| 898 chrome::Navigate(¶ms); | 898 chrome::Navigate(¶ms); |
| 899 | 899 |
| 900 // The middle tab should now be selected and navigated to the sub-page of the | 900 // The middle tab should now be selected and navigated to the sub-page of the |
| 901 // URL. | 901 // URL. |
| 902 EXPECT_EQ(browser(), params.browser); | 902 EXPECT_EQ(browser(), params.browser); |
| 903 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 903 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 904 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 904 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 918 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), | 918 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), |
| 919 ui::PAGE_TRANSITION_LINK); | 919 ui::PAGE_TRANSITION_LINK); |
| 920 | 920 |
| 921 // We should have one browser with 3 tabs, the 3rd selected. | 921 // We should have one browser with 3 tabs, the 3rd selected. |
| 922 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 922 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 923 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 923 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 924 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 924 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
| 925 | 925 |
| 926 // Navigate to singleton_url1. | 926 // Navigate to singleton_url1. |
| 927 chrome::NavigateParams params(MakeNavigateParams()); | 927 chrome::NavigateParams params(MakeNavigateParams()); |
| 928 params.disposition = SINGLETON_TAB; | 928 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 929 params.url = GetClearBrowsingDataURL(); | 929 params.url = GetClearBrowsingDataURL(); |
| 930 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 930 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 931 params.path_behavior = chrome::NavigateParams::IGNORE_AND_STAY_PUT; | 931 params.path_behavior = chrome::NavigateParams::IGNORE_AND_STAY_PUT; |
| 932 chrome::Navigate(¶ms); | 932 chrome::Navigate(¶ms); |
| 933 | 933 |
| 934 // The middle tab should now be selected. | 934 // The middle tab should now be selected. |
| 935 EXPECT_EQ(browser(), params.browser); | 935 EXPECT_EQ(browser(), params.browser); |
| 936 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 936 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 937 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 937 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 938 EXPECT_EQ(singleton_url1, | 938 EXPECT_EQ(singleton_url1, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 950 ui::PAGE_TRANSITION_LINK); | 950 ui::PAGE_TRANSITION_LINK); |
| 951 | 951 |
| 952 // We should have one browser with 2 tabs, the 2nd selected. | 952 // We should have one browser with 2 tabs, the 2nd selected. |
| 953 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 953 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 954 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 954 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 955 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 955 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 956 | 956 |
| 957 // Navigate to a different settings path. | 957 // Navigate to a different settings path. |
| 958 GURL singleton_url_target(GetClearBrowsingDataURL()); | 958 GURL singleton_url_target(GetClearBrowsingDataURL()); |
| 959 chrome::NavigateParams params(MakeNavigateParams()); | 959 chrome::NavigateParams params(MakeNavigateParams()); |
| 960 params.disposition = SINGLETON_TAB; | 960 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 961 params.url = singleton_url_target; | 961 params.url = singleton_url_target; |
| 962 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 962 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 963 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 963 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
| 964 chrome::Navigate(¶ms); | 964 chrome::Navigate(¶ms); |
| 965 | 965 |
| 966 // The second tab should still be selected, but navigated to the new path. | 966 // The second tab should still be selected, but navigated to the new path. |
| 967 EXPECT_EQ(browser(), params.browser); | 967 EXPECT_EQ(browser(), params.browser); |
| 968 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 968 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 969 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 969 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 970 EXPECT_EQ(singleton_url_target, | 970 EXPECT_EQ(singleton_url_target, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 983 ui::PAGE_TRANSITION_LINK); | 983 ui::PAGE_TRANSITION_LINK); |
| 984 | 984 |
| 985 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count()); | 985 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count()); |
| 986 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index()); | 986 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index()); |
| 987 | 987 |
| 988 // Navigate to a different settings path. | 988 // Navigate to a different settings path. |
| 989 GURL singleton_url_target( | 989 GURL singleton_url_target( |
| 990 "chrome://settings/internet?" | 990 "chrome://settings/internet?" |
| 991 "guid=ethernet_00aa00aa00aa&networkType=1"); | 991 "guid=ethernet_00aa00aa00aa&networkType=1"); |
| 992 chrome::NavigateParams params(MakeNavigateParams()); | 992 chrome::NavigateParams params(MakeNavigateParams()); |
| 993 params.disposition = SINGLETON_TAB; | 993 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 994 params.url = singleton_url_target; | 994 params.url = singleton_url_target; |
| 995 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 995 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 996 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 996 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
| 997 chrome::Navigate(¶ms); | 997 chrome::Navigate(¶ms); |
| 998 | 998 |
| 999 // Last tab should still be selected. | 999 // Last tab should still be selected. |
| 1000 EXPECT_EQ(browser(), params.browser); | 1000 EXPECT_EQ(browser(), params.browser); |
| 1001 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count()); | 1001 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count()); |
| 1002 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index()); | 1002 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index()); |
| 1003 } | 1003 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1032 RunUseNonIncognitoWindowTest(GURL(view_source)); | 1032 RunUseNonIncognitoWindowTest(GURL(view_source)); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 // This test verifies that the settings page isn't opened in the incognito | 1035 // This test verifies that the settings page isn't opened in the incognito |
| 1036 // window from a non-incognito window (bookmark open-in-incognito trigger). | 1036 // window from a non-incognito window (bookmark open-in-incognito trigger). |
| 1037 // Disabled until fixed for uber settings: http://crbug.com/111243 | 1037 // Disabled until fixed for uber settings: http://crbug.com/111243 |
| 1038 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1038 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1039 DISABLED_Disposition_Settings_UseNonIncognitoWindowForBookmark) { | 1039 DISABLED_Disposition_Settings_UseNonIncognitoWindowForBookmark) { |
| 1040 chrome::NavigateParams params(browser(), GetSettingsURL(), | 1040 chrome::NavigateParams params(browser(), GetSettingsURL(), |
| 1041 ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 1041 ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 1042 params.disposition = OFF_THE_RECORD; | 1042 params.disposition = WindowOpenDisposition::OFF_THE_RECORD; |
| 1043 { | 1043 { |
| 1044 content::WindowedNotificationObserver observer( | 1044 content::WindowedNotificationObserver observer( |
| 1045 content::NOTIFICATION_LOAD_STOP, | 1045 content::NOTIFICATION_LOAD_STOP, |
| 1046 content::NotificationService::AllSources()); | 1046 content::NotificationService::AllSources()); |
| 1047 chrome::Navigate(¶ms); | 1047 chrome::Navigate(¶ms); |
| 1048 observer.Wait(); | 1048 observer.Wait(); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1051 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 1052 EXPECT_EQ(GetSettingsURL(), | 1052 EXPECT_EQ(GetSettingsURL(), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 // We should have one browser with 2 tabs, the 2nd selected. | 1091 // We should have one browser with 2 tabs, the 2nd selected. |
| 1092 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1092 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
| 1093 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 1093 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 1094 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 1094 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 1095 | 1095 |
| 1096 // Kill the singleton tab. | 1096 // Kill the singleton tab. |
| 1097 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 1097 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
| 1098 EXPECT_TRUE(web_contents->IsCrashed()); | 1098 EXPECT_TRUE(web_contents->IsCrashed()); |
| 1099 | 1099 |
| 1100 chrome::NavigateParams params(MakeNavigateParams()); | 1100 chrome::NavigateParams params(MakeNavigateParams()); |
| 1101 params.disposition = SINGLETON_TAB; | 1101 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 1102 params.url = singleton_url; | 1102 params.url = singleton_url; |
| 1103 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 1103 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 1104 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 1104 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
| 1105 ui_test_utils::NavigateToURL(¶ms); | 1105 ui_test_utils::NavigateToURL(¶ms); |
| 1106 | 1106 |
| 1107 // The tab should not be sad anymore. | 1107 // The tab should not be sad anymore. |
| 1108 EXPECT_FALSE(web_contents->IsCrashed()); | 1108 EXPECT_FALSE(web_contents->IsCrashed()); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1111 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 chrome::kChromeUIVersionURL; | 1369 chrome::kChromeUIVersionURL; |
| 1370 | 1370 |
| 1371 chrome::NavigateParams viewsource_params(browser(), | 1371 chrome::NavigateParams viewsource_params(browser(), |
| 1372 GURL(viewsource_ntp_url), | 1372 GURL(viewsource_ntp_url), |
| 1373 ui::PAGE_TRANSITION_LINK); | 1373 ui::PAGE_TRANSITION_LINK); |
| 1374 ui_test_utils::NavigateToURL(&viewsource_params); | 1374 ui_test_utils::NavigateToURL(&viewsource_params); |
| 1375 | 1375 |
| 1376 chrome::NavigateParams singleton_params(browser(), | 1376 chrome::NavigateParams singleton_params(browser(), |
| 1377 GURL(chrome::kChromeUIVersionURL), | 1377 GURL(chrome::kChromeUIVersionURL), |
| 1378 ui::PAGE_TRANSITION_LINK); | 1378 ui::PAGE_TRANSITION_LINK); |
| 1379 singleton_params.disposition = SINGLETON_TAB; | 1379 singleton_params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
| 1380 EXPECT_EQ(-1, chrome::GetIndexOfSingletonTab(&singleton_params)); | 1380 EXPECT_EQ(-1, chrome::GetIndexOfSingletonTab(&singleton_params)); |
| 1381 } | 1381 } |
| 1382 | 1382 |
| 1383 // This test verifies that browser initiated navigations can send requests | 1383 // This test verifies that browser initiated navigations can send requests |
| 1384 // using POST. | 1384 // using POST. |
| 1385 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 1385 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1386 SendBrowserInitiatedRequestUsingPOST) { | 1386 SendBrowserInitiatedRequestUsingPOST) { |
| 1387 // Uses a test sever to verify POST request. | 1387 // Uses a test sever to verify POST request. |
| 1388 ASSERT_TRUE(embedded_test_server()->Start()); | 1388 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1389 | 1389 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 std::string data_url = "data:text/html;charset=utf-8,<html><title>" + | 1426 std::string data_url = "data:text/html;charset=utf-8,<html><title>" + |
| 1427 unescaped_title + "</title></html>"; | 1427 unescaped_title + "</title></html>"; |
| 1428 // BiDi control chars in URLs are always escaped, so the expected URL should | 1428 // BiDi control chars in URLs are always escaped, so the expected URL should |
| 1429 // have the title with the escaped RTL mark. | 1429 // have the title with the escaped RTL mark. |
| 1430 std::string escaped_title = "%E2%80%8F" + text; | 1430 std::string escaped_title = "%E2%80%8F" + text; |
| 1431 std::string expected_url = "data:text/html;charset=utf-8,<html><title>" + | 1431 std::string expected_url = "data:text/html;charset=utf-8,<html><title>" + |
| 1432 escaped_title + "</title></html>"; | 1432 escaped_title + "</title></html>"; |
| 1433 | 1433 |
| 1434 // Navigate to the page. | 1434 // Navigate to the page. |
| 1435 chrome::NavigateParams params(MakeNavigateParams()); | 1435 chrome::NavigateParams params(MakeNavigateParams()); |
| 1436 params.disposition = NEW_FOREGROUND_TAB; | 1436 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 1437 params.url = GURL(data_url); | 1437 params.url = GURL(data_url); |
| 1438 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 1438 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 1439 ui_test_utils::NavigateToURL(¶ms); | 1439 ui_test_utils::NavigateToURL(¶ms); |
| 1440 | 1440 |
| 1441 base::string16 expected_title(base::UTF8ToUTF16(unescaped_title)); | 1441 base::string16 expected_title(base::UTF8ToUTF16(unescaped_title)); |
| 1442 EXPECT_TRUE(params.target_contents); | 1442 EXPECT_TRUE(params.target_contents); |
| 1443 EXPECT_EQ(expected_title, params.target_contents->GetTitle()); | 1443 EXPECT_EQ(expected_title, params.target_contents->GetTitle()); |
| 1444 // GURL always keeps non-ASCII characters escaped, but check them anyways. | 1444 // GURL always keeps non-ASCII characters escaped, but check them anyways. |
| 1445 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec()); | 1445 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec()); |
| 1446 // Check the omnibox text. It should have escaped RTL with unescaped text. | 1446 // Check the omnibox text. It should have escaped RTL with unescaped text. |
| 1447 LocationBar* location_bar = browser()->window()->GetLocationBar(); | 1447 LocationBar* location_bar = browser()->window()->GetLocationBar(); |
| 1448 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 1448 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
| 1449 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText()); | 1449 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText()); |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 } // namespace | 1452 } // namespace |
| OLD | NEW |