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

Side by Side Diff: chrome/browser/ui/browser_navigator_browsertest.cc

Issue 643963004: Unescape BiDi control chars while parsing data urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove BIDI_CONTROL_CHARS flag Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/base/data_url_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" 12 #include "chrome/browser/prefs/incognito_mode_prefs.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/browser_finder.h" 16 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/browser_navigator.h" 17 #include "chrome/browser/ui/browser_navigator.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 18 #include "chrome/browser/ui/browser_tabstrip.h"
19 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/chrome_pages.h" 20 #include "chrome/browser/ui/chrome_pages.h"
21 #include "chrome/browser/ui/location_bar/location_bar.h"
22 #include "chrome/browser/ui/omnibox/omnibox_view.h"
21 #include "chrome/browser/ui/singleton_tabs.h" 23 #include "chrome/browser/ui/singleton_tabs.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
26 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
27 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/notification_types.h" 30 #include "content/public/browser/notification_types.h"
29 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
30 32
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 browser()->tab_strip_model()->GetActiveWebContents(); 132 browser()->tab_strip_model()->GetActiveWebContents();
131 if (base_web_contents) { 133 if (base_web_contents) {
132 create_params.initial_size = 134 create_params.initial_size =
133 base_web_contents->GetContainerBounds().size(); 135 base_web_contents->GetContainerBounds().size();
134 } 136 }
135 return WebContents::Create(create_params); 137 return WebContents::Create(create_params);
136 } 138 }
137 139
138 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { 140 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) {
139 GURL old_url = browser()->tab_strip_model()->GetActiveWebContents()->GetURL(); 141 GURL old_url = browser()->tab_strip_model()->GetActiveWebContents()->GetURL();
140 chrome::NavigateParams p(MakeNavigateParams()); 142 chrome::NavigateParams params(MakeNavigateParams());
141 p.disposition = disposition; 143 params.disposition = disposition;
142 chrome::Navigate(&p); 144 chrome::Navigate(&params);
143 145
144 // Nothing should have happened as a result of Navigate(); 146 // Nothing should have happened as a result of Navigate();
145 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 147 EXPECT_EQ(1, browser()->tab_strip_model()->count());
146 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 148 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
147 EXPECT_EQ(old_url, 149 EXPECT_EQ(old_url,
148 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 150 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
149 } 151 }
150 152
151 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { 153 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) {
152 Browser* incognito_browser = CreateIncognitoBrowser(); 154 Browser* incognito_browser = CreateIncognitoBrowser();
153 155
154 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 156 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
155 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 157 EXPECT_EQ(1, browser()->tab_strip_model()->count());
156 EXPECT_EQ(1, incognito_browser->tab_strip_model()->count()); 158 EXPECT_EQ(1, incognito_browser->tab_strip_model()->count());
157 159
158 // Navigate to the page. 160 // Navigate to the page.
159 chrome::NavigateParams p(MakeNavigateParams(incognito_browser)); 161 chrome::NavigateParams params(MakeNavigateParams(incognito_browser));
160 p.disposition = SINGLETON_TAB; 162 params.disposition = SINGLETON_TAB;
161 p.url = url; 163 params.url = url;
162 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 164 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
163 chrome::Navigate(&p); 165 chrome::Navigate(&params);
164 166
165 // This page should be opened in browser() window. 167 // This page should be opened in browser() window.
166 EXPECT_NE(incognito_browser, p.browser); 168 EXPECT_NE(incognito_browser, params.browser);
167 EXPECT_EQ(browser(), p.browser); 169 EXPECT_EQ(browser(), params.browser);
168 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 170 EXPECT_EQ(2, browser()->tab_strip_model()->count());
169 EXPECT_EQ(url, 171 EXPECT_EQ(url,
170 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 172 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
171 } 173 }
172 174
173 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest( 175 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest(
174 const GURL& url) { 176 const GURL& url) {
175 Browser* browser = CreateIncognitoBrowser(); 177 Browser* browser = CreateIncognitoBrowser();
176 178
177 // Set kIncognitoModeAvailability to FORCED. 179 // Set kIncognitoModeAvailability to FORCED.
178 PrefService* prefs1 = browser->profile()->GetPrefs(); 180 PrefService* prefs1 = browser->profile()->GetPrefs();
179 prefs1->SetInteger(prefs::kIncognitoModeAvailability, 181 prefs1->SetInteger(prefs::kIncognitoModeAvailability,
180 IncognitoModePrefs::FORCED); 182 IncognitoModePrefs::FORCED);
181 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs(); 183 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs();
182 prefs2->SetInteger(prefs::kIncognitoModeAvailability, 184 prefs2->SetInteger(prefs::kIncognitoModeAvailability,
183 IncognitoModePrefs::FORCED); 185 IncognitoModePrefs::FORCED);
184 186
185 // Navigate to the page. 187 // Navigate to the page.
186 chrome::NavigateParams p(MakeNavigateParams(browser)); 188 chrome::NavigateParams params(MakeNavigateParams(browser));
187 p.disposition = OFF_THE_RECORD; 189 params.disposition = OFF_THE_RECORD;
188 p.url = url; 190 params.url = url;
189 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 191 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
190 chrome::Navigate(&p); 192 chrome::Navigate(&params);
191 193
192 // The page should not be opened. 194 // The page should not be opened.
193 EXPECT_EQ(browser, p.browser); 195 EXPECT_EQ(browser, params.browser);
194 EXPECT_EQ(1, browser->tab_strip_model()->count()); 196 EXPECT_EQ(1, browser->tab_strip_model()->count());
195 EXPECT_EQ(GURL(url::kAboutBlankURL), 197 EXPECT_EQ(GURL(url::kAboutBlankURL),
196 browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 198 browser->tab_strip_model()->GetActiveWebContents()->GetURL());
197 } 199 }
198 200
199 void BrowserNavigatorTest::SetUpCommandLine(base::CommandLine* command_line) { 201 void BrowserNavigatorTest::SetUpCommandLine(base::CommandLine* command_line) {
200 // Disable settings-in-a-window so that we can use the settings page and 202 // Disable settings-in-a-window so that we can use the settings page and
201 // sub-pages to test browser navigation. 203 // sub-pages to test browser navigation.
202 command_line->AppendSwitch(::switches::kDisableSettingsWindow); 204 command_line->AppendSwitch(::switches::kDisableSettingsWindow);
203 } 205 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ui::PAGE_TRANSITION_LINK); 255 ui::PAGE_TRANSITION_LINK);
254 256
255 // We should have one browser with 3 tabs, the 3rd selected. 257 // We should have one browser with 3 tabs, the 3rd selected.
256 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 258 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
257 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 259 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
258 260
259 unsigned int previous_tab_contents_count = 261 unsigned int previous_tab_contents_count =
260 created_tab_contents_count_ = 0; 262 created_tab_contents_count_ = 0;
261 263
262 // Navigate to singleton_url1. 264 // Navigate to singleton_url1.
263 chrome::NavigateParams p(MakeNavigateParams()); 265 chrome::NavigateParams params(MakeNavigateParams());
264 p.disposition = SINGLETON_TAB; 266 params.disposition = SINGLETON_TAB;
265 p.url = singleton_url1; 267 params.url = singleton_url1;
266 chrome::Navigate(&p); 268 chrome::Navigate(&params);
267 269
268 // The middle tab should now be selected. 270 // The middle tab should now be selected.
269 EXPECT_EQ(browser(), p.browser); 271 EXPECT_EQ(browser(), params.browser);
270 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 272 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
271 273
272 // No tab contents should have been created 274 // No tab contents should have been created
273 EXPECT_EQ(previous_tab_contents_count, 275 EXPECT_EQ(previous_tab_contents_count,
274 created_tab_contents_count_); 276 created_tab_contents_count_);
275 } 277 }
276 278
277 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 279 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
278 Disposition_SingletonTabRespectingRef) { 280 Disposition_SingletonTabRespectingRef) {
279 GURL singleton_ref_url1("http://maps.google.com/#a"); 281 GURL singleton_ref_url1("http://maps.google.com/#a");
280 GURL singleton_ref_url2("http://maps.google.com/#b"); 282 GURL singleton_ref_url2("http://maps.google.com/#b");
281 GURL singleton_ref_url3("http://maps.google.com/"); 283 GURL singleton_ref_url3("http://maps.google.com/");
282 284
283 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, 285 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1,
284 ui::PAGE_TRANSITION_LINK); 286 ui::PAGE_TRANSITION_LINK);
285 287
286 // We should have one browser with 2 tabs, 2nd selected. 288 // We should have one browser with 2 tabs, 2nd selected.
287 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 289 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
288 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 290 EXPECT_EQ(2, browser()->tab_strip_model()->count());
289 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 291 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
290 292
291 // Navigate to singleton_url2. 293 // Navigate to singleton_url2.
292 chrome::NavigateParams p(MakeNavigateParams()); 294 chrome::NavigateParams params(MakeNavigateParams());
293 p.disposition = SINGLETON_TAB; 295 params.disposition = SINGLETON_TAB;
294 p.url = singleton_ref_url2; 296 params.url = singleton_ref_url2;
295 chrome::Navigate(&p); 297 chrome::Navigate(&params);
296 298
297 // We should now have 2 tabs, the 2nd one selected. 299 // We should now have 2 tabs, the 2nd one selected.
298 EXPECT_EQ(browser(), p.browser); 300 EXPECT_EQ(browser(), params.browser);
299 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 301 EXPECT_EQ(2, browser()->tab_strip_model()->count());
300 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 302 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
301 303
302 // Navigate to singleton_url2, but with respect ref set. 304 // Navigate to singleton_url2, but with respect ref set.
303 p = MakeNavigateParams(); 305 params = MakeNavigateParams();
304 p.disposition = SINGLETON_TAB; 306 params.disposition = SINGLETON_TAB;
305 p.url = singleton_ref_url2; 307 params.url = singleton_ref_url2;
306 p.ref_behavior = chrome::NavigateParams::RESPECT_REF; 308 params.ref_behavior = chrome::NavigateParams::RESPECT_REF;
307 chrome::Navigate(&p); 309 chrome::Navigate(&params);
308 310
309 // We should now have 3 tabs, the 3th one selected. 311 // We should now have 3 tabs, the 3th one selected.
310 EXPECT_EQ(browser(), p.browser); 312 EXPECT_EQ(browser(), params.browser);
311 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 313 EXPECT_EQ(3, browser()->tab_strip_model()->count());
312 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 314 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
313 315
314 // Navigate to singleton_url3. 316 // Navigate to singleton_url3.
315 p = MakeNavigateParams(); 317 params = MakeNavigateParams();
316 p.disposition = SINGLETON_TAB; 318 params.disposition = SINGLETON_TAB;
317 p.url = singleton_ref_url3; 319 params.url = singleton_ref_url3;
318 p.ref_behavior = chrome::NavigateParams::RESPECT_REF; 320 params.ref_behavior = chrome::NavigateParams::RESPECT_REF;
319 chrome::Navigate(&p); 321 chrome::Navigate(&params);
320 322
321 // We should now have 4 tabs, the 4th one selected. 323 // We should now have 4 tabs, the 4th one selected.
322 EXPECT_EQ(browser(), p.browser); 324 EXPECT_EQ(browser(), params.browser);
323 EXPECT_EQ(4, browser()->tab_strip_model()->count()); 325 EXPECT_EQ(4, browser()->tab_strip_model()->count());
324 EXPECT_EQ(3, browser()->tab_strip_model()->active_index()); 326 EXPECT_EQ(3, browser()->tab_strip_model()->active_index());
325 } 327 }
326 328
327 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 329 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
328 Disposition_SingletonTabNoneExisting) { 330 Disposition_SingletonTabNoneExisting) {
329 GURL singleton_url1("http://maps.google.com/"); 331 GURL singleton_url1("http://maps.google.com/");
330 332
331 // We should have one browser with 1 tab. 333 // We should have one browser with 1 tab.
332 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 334 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
333 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 335 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
334 336
335 // Navigate to singleton_url1. 337 // Navigate to singleton_url1.
336 chrome::NavigateParams p(MakeNavigateParams()); 338 chrome::NavigateParams params(MakeNavigateParams());
337 p.disposition = SINGLETON_TAB; 339 params.disposition = SINGLETON_TAB;
338 p.url = singleton_url1; 340 params.url = singleton_url1;
339 chrome::Navigate(&p); 341 chrome::Navigate(&params);
340 342
341 // We should now have 2 tabs, the 2nd one selected. 343 // We should now have 2 tabs, the 2nd one selected.
342 EXPECT_EQ(browser(), p.browser); 344 EXPECT_EQ(browser(), params.browser);
343 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 345 EXPECT_EQ(2, browser()->tab_strip_model()->count());
344 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 346 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
345 } 347 }
346 348
347 // This test verifies that when a navigation results in a foreground tab, the 349 // This test verifies that when a navigation results in a foreground tab, the
348 // tab count of the Browser increases and the selected tab shifts to the new 350 // tab count of the Browser increases and the selected tab shifts to the new
349 // foreground tab. 351 // foreground tab.
350 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { 352 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) {
351 WebContents* old_contents = 353 WebContents* old_contents =
352 browser()->tab_strip_model()->GetActiveWebContents(); 354 browser()->tab_strip_model()->GetActiveWebContents();
353 chrome::NavigateParams p(MakeNavigateParams()); 355 chrome::NavigateParams params(MakeNavigateParams());
354 p.disposition = NEW_FOREGROUND_TAB; 356 params.disposition = NEW_FOREGROUND_TAB;
355 chrome::Navigate(&p); 357 chrome::Navigate(&params);
356 EXPECT_NE(old_contents, 358 EXPECT_NE(old_contents,
357 browser()->tab_strip_model()->GetActiveWebContents()); 359 browser()->tab_strip_model()->GetActiveWebContents());
358 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), 360 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(),
359 p.target_contents); 361 params.target_contents);
360 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 362 EXPECT_EQ(2, browser()->tab_strip_model()->count());
361 } 363 }
362 364
363 // This test verifies that when a navigation results in a background tab, the 365 // This test verifies that when a navigation results in a background tab, the
364 // tab count of the Browser increases but the selected tab remains the same. 366 // tab count of the Browser increases but the selected tab remains the same.
365 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { 367 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) {
366 WebContents* old_contents = 368 WebContents* old_contents =
367 browser()->tab_strip_model()->GetActiveWebContents(); 369 browser()->tab_strip_model()->GetActiveWebContents();
368 chrome::NavigateParams p(MakeNavigateParams()); 370 chrome::NavigateParams params(MakeNavigateParams());
369 p.disposition = NEW_BACKGROUND_TAB; 371 params.disposition = NEW_BACKGROUND_TAB;
370 chrome::Navigate(&p); 372 chrome::Navigate(&params);
371 WebContents* new_contents = 373 WebContents* new_contents =
372 browser()->tab_strip_model()->GetActiveWebContents(); 374 browser()->tab_strip_model()->GetActiveWebContents();
373 // The selected tab should have remained unchanged, since the new tab was 375 // The selected tab should have remained unchanged, since the new tab was
374 // opened in the background. 376 // opened in the background.
375 EXPECT_EQ(old_contents, new_contents); 377 EXPECT_EQ(old_contents, new_contents);
376 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 378 EXPECT_EQ(2, browser()->tab_strip_model()->count());
377 } 379 }
378 380
379 // This test verifies that when a navigation requiring a new foreground tab 381 // This test verifies that when a navigation requiring a new foreground tab
380 // occurs in a Browser that cannot host multiple tabs, the new foreground tab 382 // occurs in a Browser that cannot host multiple tabs, the new foreground tab
381 // is created in an existing compatible Browser. 383 // is created in an existing compatible Browser.
382 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 384 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
383 Disposition_IncompatibleWindow_Existing) { 385 Disposition_IncompatibleWindow_Existing) {
384 // Open a foreground tab in a window that cannot open popups when there is an 386 // Open a foreground tab in a window that cannot open popups when there is an
385 // existing compatible window somewhere else that they can be opened within. 387 // existing compatible window somewhere else that they can be opened within.
386 Browser* popup = CreateEmptyBrowserForType(Browser::TYPE_POPUP, 388 Browser* popup = CreateEmptyBrowserForType(Browser::TYPE_POPUP,
387 browser()->profile()); 389 browser()->profile());
388 chrome::NavigateParams p(MakeNavigateParams(popup)); 390 chrome::NavigateParams params(MakeNavigateParams(popup));
389 p.disposition = NEW_FOREGROUND_TAB; 391 params.disposition = NEW_FOREGROUND_TAB;
390 chrome::Navigate(&p); 392 chrome::Navigate(&params);
391 393
392 // Navigate() should have opened the tab in a different browser since the 394 // Navigate() should have opened the tab in a different browser since the
393 // one we supplied didn't support additional tabs. 395 // one we supplied didn't support additional tabs.
394 EXPECT_NE(popup, p.browser); 396 EXPECT_NE(popup, params.browser);
395 397
396 // Since browser() is an existing compatible tabbed browser, it should have 398 // Since browser() is an existing compatible tabbed browser, it should have
397 // opened the tab there. 399 // opened the tab there.
398 EXPECT_EQ(browser(), p.browser); 400 EXPECT_EQ(browser(), params.browser);
399 401
400 // We should be left with 2 windows, the popup with one tab and the browser() 402 // We should be left with 2 windows, the popup with one tab and the browser()
401 // provided by the framework with two. 403 // provided by the framework with two.
402 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 404 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
403 EXPECT_EQ(1, popup->tab_strip_model()->count()); 405 EXPECT_EQ(1, popup->tab_strip_model()->count());
404 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 406 EXPECT_EQ(2, browser()->tab_strip_model()->count());
405 } 407 }
406 408
407 // This test verifies that when a navigation requiring a new foreground tab 409 // This test verifies that when a navigation requiring a new foreground tab
408 // occurs in a Browser that cannot host multiple tabs and no compatible Browser 410 // occurs in a Browser that cannot host multiple tabs and no compatible Browser
409 // that can is open, a compatible Browser is created. 411 // that can is open, a compatible Browser is created.
410 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 412 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
411 Disposition_IncompatibleWindow_NoExisting) { 413 Disposition_IncompatibleWindow_NoExisting) {
412 // We want to simulate not being able to find an existing window compatible 414 // We want to simulate not being able to find an existing window compatible
413 // with our non-tabbed browser window so Navigate() is forced to create a 415 // with our non-tabbed browser window so Navigate() is forced to create a
414 // new compatible window. Because browser() supplied by the in-process 416 // new compatible window. Because browser() supplied by the in-process
415 // browser testing framework is compatible with browser()->profile(), we 417 // browser testing framework is compatible with browser()->profile(), we
416 // need a different profile, and creating a popup window with an incognito 418 // need a different profile, and creating a popup window with an incognito
417 // profile is a quick and dirty way of achieving this. 419 // profile is a quick and dirty way of achieving this.
418 Browser* popup = CreateEmptyBrowserForType( 420 Browser* popup = CreateEmptyBrowserForType(
419 Browser::TYPE_POPUP, 421 Browser::TYPE_POPUP,
420 browser()->profile()->GetOffTheRecordProfile()); 422 browser()->profile()->GetOffTheRecordProfile());
421 chrome::NavigateParams p(MakeNavigateParams(popup)); 423 chrome::NavigateParams params(MakeNavigateParams(popup));
422 p.disposition = NEW_FOREGROUND_TAB; 424 params.disposition = NEW_FOREGROUND_TAB;
423 chrome::Navigate(&p); 425 chrome::Navigate(&params);
424 426
425 // Navigate() should have opened the tab in a different browser since the 427 // Navigate() should have opened the tab in a different browser since the
426 // one we supplied didn't support additional tabs. 428 // one we supplied didn't support additional tabs.
427 EXPECT_NE(popup, p.browser); 429 EXPECT_NE(popup, params.browser);
428 430
429 // This time, browser() is _not_ compatible with popup since it is not an 431 // This time, browser() is _not_ compatible with popup since it is not an
430 // incognito window. 432 // incognito window.
431 EXPECT_NE(browser(), p.browser); 433 EXPECT_NE(browser(), params.browser);
432 434
433 // We should have three windows, each with one tab: 435 // We should have three windows, each with one tab:
434 // 1. the browser() provided by the framework (unchanged in this test) 436 // 1. the browser() provided by the framework (unchanged in this test)
435 // 2. the incognito popup we created originally 437 // 2. the incognito popup we created originally
436 // 3. the new incognito tabbed browser that was created by Navigate(). 438 // 3. the new incognito tabbed browser that was created by Navigate().
437 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); 439 EXPECT_EQ(3u, chrome::GetTotalBrowserCount());
438 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 440 EXPECT_EQ(1, browser()->tab_strip_model()->count());
439 EXPECT_EQ(1, popup->tab_strip_model()->count()); 441 EXPECT_EQ(1, popup->tab_strip_model()->count());
440 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); 442 EXPECT_EQ(1, params.browser->tab_strip_model()->count());
441 EXPECT_TRUE(p.browser->is_type_tabbed()); 443 EXPECT_TRUE(params.browser->is_type_tabbed());
442 } 444 }
443 445
444 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 446 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
445 // from a normal Browser results in a new Browser with TYPE_POPUP. 447 // from a normal Browser results in a new Browser with TYPE_POPUP.
446 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { 448 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) {
447 chrome::NavigateParams p(MakeNavigateParams()); 449 chrome::NavigateParams params(MakeNavigateParams());
448 p.disposition = NEW_POPUP; 450 params.disposition = NEW_POPUP;
449 p.window_bounds = gfx::Rect(0, 0, 200, 200); 451 params.window_bounds = gfx::Rect(0, 0, 200, 200);
450 // Wait for new popup to to load and gain focus. 452 // Wait for new popup to to load and gain focus.
451 ui_test_utils::NavigateToURL(&p); 453 ui_test_utils::NavigateToURL(&params);
452 454
453 // Navigate() should have opened a new, focused popup window. 455 // Navigate() should have opened a new, focused popup window.
454 EXPECT_NE(browser(), p.browser); 456 EXPECT_NE(browser(), params.browser);
455 #if 0 457 #if 0
456 // TODO(stevenjb): Enable this test. See: crbug.com/79493 458 // TODO(stevenjb): Enable this test. See: crbug.com/79493
457 EXPECT_TRUE(p.browser->window()->IsActive()); 459 EXPECT_TRUE(browser->window()->IsActive());
458 #endif 460 #endif
459 EXPECT_TRUE(p.browser->is_type_popup()); 461 EXPECT_TRUE(params.browser->is_type_popup());
460 EXPECT_FALSE(p.browser->is_app()); 462 EXPECT_FALSE(params.browser->is_app());
461 463
462 // We should have two windows, the browser() provided by the framework and the 464 // We should have two windows, the browser() provided by the framework and the
463 // new popup window. 465 // new popup window.
464 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 466 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
465 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 467 EXPECT_EQ(1, browser()->tab_strip_model()->count());
466 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); 468 EXPECT_EQ(1, params.browser->tab_strip_model()->count());
467 } 469 }
468 470
469 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 471 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
470 // from a normal Browser results in a new Browser with is_app() true. 472 // from a normal Browser results in a new Browser with is_app() true.
471 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) { 473 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) {
472 chrome::NavigateParams p(MakeNavigateParams()); 474 chrome::NavigateParams params(MakeNavigateParams());
473 p.disposition = NEW_POPUP; 475 params.disposition = NEW_POPUP;
474 p.extension_app_id = "extensionappid"; 476 params.extension_app_id = "extensionappid";
475 p.window_bounds = gfx::Rect(0, 0, 200, 200); 477 params.window_bounds = gfx::Rect(0, 0, 200, 200);
476 // Wait for new popup to to load and gain focus. 478 // Wait for new popup to to load and gain focus.
477 ui_test_utils::NavigateToURL(&p); 479 ui_test_utils::NavigateToURL(&params);
478 480
479 // Navigate() should have opened a new, focused popup window. 481 // Navigate() should have opened a new, focused popup window.
480 EXPECT_NE(browser(), p.browser); 482 EXPECT_NE(browser(), params.browser);
481 EXPECT_TRUE(p.browser->is_type_popup()); 483 EXPECT_TRUE(params.browser->is_type_popup());
482 EXPECT_TRUE(p.browser->is_app()); 484 EXPECT_TRUE(params.browser->is_app());
483 485
484 // We should have two windows, the browser() provided by the framework and the 486 // We should have two windows, the browser() provided by the framework and the
485 // new popup window. 487 // new popup window.
486 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 488 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
487 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 489 EXPECT_EQ(1, browser()->tab_strip_model()->count());
488 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); 490 EXPECT_EQ(1, params.browser->tab_strip_model()->count());
489 } 491 }
490 492
491 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 493 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
492 // from a normal popup results in a new Browser with TYPE_POPUP. 494 // from a normal popup results in a new Browser with TYPE_POPUP.
493 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { 495 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) {
494 // Open a popup. 496 // Open a popup.
495 chrome::NavigateParams p1(MakeNavigateParams()); 497 chrome::NavigateParams params1(MakeNavigateParams());
496 p1.disposition = NEW_POPUP; 498 params1.disposition = NEW_POPUP;
497 p1.window_bounds = gfx::Rect(0, 0, 200, 200); 499 params1.window_bounds = gfx::Rect(0, 0, 200, 200);
498 chrome::Navigate(&p1); 500 chrome::Navigate(&params1);
499 // Open another popup. 501 // Open another popup.
500 chrome::NavigateParams p2(MakeNavigateParams(p1.browser)); 502 chrome::NavigateParams params2(MakeNavigateParams(params1.browser));
501 p2.disposition = NEW_POPUP; 503 params2.disposition = NEW_POPUP;
502 p2.window_bounds = gfx::Rect(0, 0, 200, 200); 504 params2.window_bounds = gfx::Rect(0, 0, 200, 200);
503 chrome::Navigate(&p2); 505 chrome::Navigate(&params2);
504 506
505 // Navigate() should have opened a new normal popup window. 507 // Navigate() should have opened a new normal popup window.
506 EXPECT_NE(p1.browser, p2.browser); 508 EXPECT_NE(params1.browser, params2.browser);
507 EXPECT_TRUE(p2.browser->is_type_popup()); 509 EXPECT_TRUE(params2.browser->is_type_popup());
508 EXPECT_FALSE(p2.browser->is_app()); 510 EXPECT_FALSE(params2.browser->is_app());
509 511
510 // We should have three windows, the browser() provided by the framework, 512 // We should have three windows, the browser() provided by the framework,
511 // the first popup window, and the second popup window. 513 // the first popup window, and the second popup window.
512 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); 514 EXPECT_EQ(3u, chrome::GetTotalBrowserCount());
513 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 515 EXPECT_EQ(1, browser()->tab_strip_model()->count());
514 EXPECT_EQ(1, p1.browser->tab_strip_model()->count()); 516 EXPECT_EQ(1, params1.browser->tab_strip_model()->count());
515 EXPECT_EQ(1, p2.browser->tab_strip_model()->count()); 517 EXPECT_EQ(1, params2.browser->tab_strip_model()->count());
516 } 518 }
517 519
518 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 520 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
519 // from an app frame results in a new Browser with TYPE_POPUP. 521 // from an app frame results in a new Browser with TYPE_POPUP.
520 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 522 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
521 Disposition_NewPopupFromAppWindow) { 523 Disposition_NewPopupFromAppWindow) {
522 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile()); 524 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile());
523 chrome::NavigateParams p(MakeNavigateParams(app_browser)); 525 chrome::NavigateParams params(MakeNavigateParams(app_browser));
524 p.disposition = NEW_POPUP; 526 params.disposition = NEW_POPUP;
525 p.window_bounds = gfx::Rect(0, 0, 200, 200); 527 params.window_bounds = gfx::Rect(0, 0, 200, 200);
526 chrome::Navigate(&p); 528 chrome::Navigate(&params);
527 529
528 // Navigate() should have opened a new popup app window. 530 // Navigate() should have opened a new popup app window.
529 EXPECT_NE(app_browser, p.browser); 531 EXPECT_NE(app_browser, params.browser);
530 EXPECT_NE(browser(), p.browser); 532 EXPECT_NE(browser(), params.browser);
531 EXPECT_TRUE(p.browser->is_type_popup()); 533 EXPECT_TRUE(params.browser->is_type_popup());
532 EXPECT_TRUE(p.browser->is_app()); 534 EXPECT_TRUE(params.browser->is_app());
533 535
534 // We should now have three windows, the app window, the app popup it created, 536 // We should now have three windows, the app window, the app popup it created,
535 // and the original browser() provided by the framework. 537 // and the original browser() provided by the framework.
536 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); 538 EXPECT_EQ(3u, chrome::GetTotalBrowserCount());
537 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 539 EXPECT_EQ(1, browser()->tab_strip_model()->count());
538 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); 540 EXPECT_EQ(1, app_browser->tab_strip_model()->count());
539 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); 541 EXPECT_EQ(1, params.browser->tab_strip_model()->count());
540 } 542 }
541 543
542 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 544 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
543 // from an app popup results in a new Browser also of TYPE_POPUP. 545 // from an app popup results in a new Browser also of TYPE_POPUP.
544 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 546 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
545 Disposition_NewPopupFromAppPopup) { 547 Disposition_NewPopupFromAppPopup) {
546 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile()); 548 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile());
547 // Open an app popup. 549 // Open an app popup.
548 chrome::NavigateParams p1(MakeNavigateParams(app_browser)); 550 chrome::NavigateParams params1(MakeNavigateParams(app_browser));
549 p1.disposition = NEW_POPUP; 551 params1.disposition = NEW_POPUP;
550 p1.window_bounds = gfx::Rect(0, 0, 200, 200); 552 params1.window_bounds = gfx::Rect(0, 0, 200, 200);
551 chrome::Navigate(&p1); 553 chrome::Navigate(&params1);
552 // Now open another app popup. 554 // Now open another app popup.
553 chrome::NavigateParams p2(MakeNavigateParams(p1.browser)); 555 chrome::NavigateParams params2(MakeNavigateParams(params1.browser));
554 p2.disposition = NEW_POPUP; 556 params2.disposition = NEW_POPUP;
555 p2.window_bounds = gfx::Rect(0, 0, 200, 200); 557 params2.window_bounds = gfx::Rect(0, 0, 200, 200);
556 chrome::Navigate(&p2); 558 chrome::Navigate(&params2);
557 559
558 // Navigate() should have opened a new popup app window. 560 // Navigate() should have opened a new popup app window.
559 EXPECT_NE(browser(), p1.browser); 561 EXPECT_NE(browser(), params1.browser);
560 EXPECT_NE(p1.browser, p2.browser); 562 EXPECT_NE(params1.browser, params2.browser);
561 EXPECT_TRUE(p2.browser->is_type_popup()); 563 EXPECT_TRUE(params2.browser->is_type_popup());
562 EXPECT_TRUE(p2.browser->is_app()); 564 EXPECT_TRUE(params2.browser->is_app());
563 565
564 // We should now have four windows, the app window, the first app popup, 566 // We should now have four windows, the app window, the first app popup,
565 // the second app popup, and the original browser() provided by the framework. 567 // the second app popup, and the original browser() provided by the framework.
566 EXPECT_EQ(4u, chrome::GetTotalBrowserCount()); 568 EXPECT_EQ(4u, chrome::GetTotalBrowserCount());
567 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 569 EXPECT_EQ(1, browser()->tab_strip_model()->count());
568 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); 570 EXPECT_EQ(1, app_browser->tab_strip_model()->count());
569 EXPECT_EQ(1, p1.browser->tab_strip_model()->count()); 571 EXPECT_EQ(1, params1.browser->tab_strip_model()->count());
570 EXPECT_EQ(1, p2.browser->tab_strip_model()->count()); 572 EXPECT_EQ(1, params2.browser->tab_strip_model()->count());
571 } 573 }
572 574
573 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 575 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
574 // from an extension app tab results in a new Browser with TYPE_APP_POPUP. 576 // from an extension app tab results in a new Browser with TYPE_APP_POPUP.
575 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 577 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
576 Disposition_NewPopupFromExtensionApp) { 578 Disposition_NewPopupFromExtensionApp) {
577 // TODO(beng): TBD. 579 // TODO(beng): TBD.
578 } 580 }
579 581
580 // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE 582 // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE
581 // does not focus a new new popup window. 583 // does not focus a new new popup window.
582 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) { 584 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) {
583 chrome::NavigateParams p(MakeNavigateParams()); 585 chrome::NavigateParams params(MakeNavigateParams());
584 p.disposition = NEW_POPUP; 586 params.disposition = NEW_POPUP;
585 p.window_bounds = gfx::Rect(0, 0, 200, 200); 587 params.window_bounds = gfx::Rect(0, 0, 200, 200);
586 p.window_action = chrome::NavigateParams::SHOW_WINDOW_INACTIVE; 588 params.window_action = chrome::NavigateParams::SHOW_WINDOW_INACTIVE;
587 // Wait for new popup to load (and gain focus if the test fails). 589 // Wait for new popup to load (and gain focus if the test fails).
588 ui_test_utils::NavigateToURL(&p); 590 ui_test_utils::NavigateToURL(&params);
589 591
590 // Navigate() should have opened a new, unfocused, popup window. 592 // Navigate() should have opened a new, unfocused, popup window.
591 EXPECT_NE(browser(), p.browser); 593 EXPECT_NE(browser(), params.browser);
592 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); 594 EXPECT_EQ(Browser::TYPE_POPUP, params.browser->type());
593 #if 0 595 #if 0
594 // TODO(stevenjb): Enable this test. See: crbug.com/79493 596 // TODO(stevenjb): Enable this test. See: crbug.com/79493
595 EXPECT_FALSE(p.browser->window()->IsActive()); 597 EXPECT_FALSE(p.browser->window()->IsActive());
596 #endif 598 #endif
597 } 599 }
598 600
599 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 601 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
600 // and trusted_source = true results in a new Browser where is_trusted_source() 602 // and trusted_source = true results in a new Browser where is_trusted_source()
601 // is true. 603 // is true.
602 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupTrusted) { 604 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupTrusted) {
603 chrome::NavigateParams p(MakeNavigateParams()); 605 chrome::NavigateParams params(MakeNavigateParams());
604 p.disposition = NEW_POPUP; 606 params.disposition = NEW_POPUP;
605 p.trusted_source = true; 607 params.trusted_source = true;
606 p.window_bounds = gfx::Rect(0, 0, 200, 200); 608 params.window_bounds = gfx::Rect(0, 0, 200, 200);
607 // Wait for new popup to to load and gain focus. 609 // Wait for new popup to to load and gain focus.
608 ui_test_utils::NavigateToURL(&p); 610 ui_test_utils::NavigateToURL(&params);
609 611
610 // Navigate() should have opened a new popup window of TYPE_TRUSTED_POPUP. 612 // Navigate() should have opened a new popup window of TYPE_TRUSTED_POPUP.
611 EXPECT_NE(browser(), p.browser); 613 EXPECT_NE(browser(), params.browser);
612 EXPECT_TRUE(p.browser->is_type_popup()); 614 EXPECT_TRUE(params.browser->is_type_popup());
613 EXPECT_TRUE(p.browser->is_trusted_source()); 615 EXPECT_TRUE(params.browser->is_trusted_source());
614 } 616 }
615 617
616 618
617 // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW 619 // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW
618 // always opens a new window. 620 // always opens a new window.
619 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) { 621 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) {
620 chrome::NavigateParams p(MakeNavigateParams()); 622 chrome::NavigateParams params(MakeNavigateParams());
621 p.disposition = NEW_WINDOW; 623 params.disposition = NEW_WINDOW;
622 chrome::Navigate(&p); 624 chrome::Navigate(&params);
623 625
624 // Navigate() should have opened a new toplevel window. 626 // Navigate() should have opened a new toplevel window.
625 EXPECT_NE(browser(), p.browser); 627 EXPECT_NE(browser(), params.browser);
626 EXPECT_TRUE(p.browser->is_type_tabbed()); 628 EXPECT_TRUE(params.browser->is_type_tabbed());
627 629
628 // We should now have two windows, the browser() provided by the framework and 630 // We should now have two windows, the browser() provided by the framework and
629 // the new normal window. 631 // the new normal window.
630 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 632 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
631 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 633 EXPECT_EQ(1, browser()->tab_strip_model()->count());
632 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); 634 EXPECT_EQ(1, params.browser->tab_strip_model()->count());
633 } 635 }
634 636
635 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO 637 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO
636 // opens a new incognito window if no existing incognito window is present. 638 // opens a new incognito window if no existing incognito window is present.
637 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { 639 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) {
638 chrome::NavigateParams p(MakeNavigateParams()); 640 chrome::NavigateParams params(MakeNavigateParams());
639 p.disposition = OFF_THE_RECORD; 641 params.disposition = OFF_THE_RECORD;
640 chrome::Navigate(&p); 642 chrome::Navigate(&params);
641 643
642 // Navigate() should have opened a new toplevel incognito window. 644 // Navigate() should have opened a new toplevel incognito window.
643 EXPECT_NE(browser(), p.browser); 645 EXPECT_NE(browser(), params.browser);
644 EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(), 646 EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(),
645 p.browser->profile()); 647 params.browser->profile());
646 648
647 // |source_contents| should be set to NULL because the profile for the new 649 // |source_contents| should be set to NULL because the profile for the new
648 // page is different from the originating page. 650 // page is different from the originating page.
649 EXPECT_EQ(NULL, p.source_contents); 651 EXPECT_EQ(NULL, params.source_contents);
650 652
651 // We should now have two windows, the browser() provided by the framework and 653 // We should now have two windows, the browser() provided by the framework and
652 // the new incognito window. 654 // the new incognito window.
653 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 655 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
654 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 656 EXPECT_EQ(1, browser()->tab_strip_model()->count());
655 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); 657 EXPECT_EQ(1, params.browser->tab_strip_model()->count());
656 } 658 }
657 659
658 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO 660 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO
659 // reuses an existing incognito window when possible. 661 // reuses an existing incognito window when possible.
660 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { 662 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) {
661 Browser* incognito_browser = 663 Browser* incognito_browser =
662 CreateEmptyBrowserForType(Browser::TYPE_TABBED, 664 CreateEmptyBrowserForType(Browser::TYPE_TABBED,
663 browser()->profile()->GetOffTheRecordProfile()); 665 browser()->profile()->GetOffTheRecordProfile());
664 chrome::NavigateParams p(MakeNavigateParams()); 666 chrome::NavigateParams params(MakeNavigateParams());
665 p.disposition = OFF_THE_RECORD; 667 params.disposition = OFF_THE_RECORD;
666 chrome::Navigate(&p); 668 chrome::Navigate(&params);
667 669
668 // Navigate() should have opened a new tab in the existing incognito window. 670 // Navigate() should have opened a new tab in the existing incognito window.
669 EXPECT_NE(browser(), p.browser); 671 EXPECT_NE(browser(), params.browser);
670 EXPECT_EQ(p.browser, incognito_browser); 672 EXPECT_EQ(params.browser, incognito_browser);
671 673
672 // We should now have two windows, the browser() provided by the framework and 674 // We should now have two windows, the browser() provided by the framework and
673 // the incognito window we opened earlier. 675 // the incognito window we opened earlier.
674 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 676 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
675 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 677 EXPECT_EQ(1, browser()->tab_strip_model()->count());
676 EXPECT_EQ(2, incognito_browser->tab_strip_model()->count()); 678 EXPECT_EQ(2, incognito_browser->tab_strip_model()->count());
677 } 679 }
678 680
679 // This test verifies that no navigation action occurs when 681 // This test verifies that no navigation action occurs when
680 // WindowOpenDisposition = SUPPRESS_OPEN. 682 // WindowOpenDisposition = SUPPRESS_OPEN.
681 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SuppressOpen) { 683 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SuppressOpen) {
682 RunSuppressTest(SUPPRESS_OPEN); 684 RunSuppressTest(SUPPRESS_OPEN);
683 } 685 }
684 686
685 // This test verifies that no navigation action occurs when 687 // This test verifies that no navigation action occurs when
686 // WindowOpenDisposition = SAVE_TO_DISK. 688 // WindowOpenDisposition = SAVE_TO_DISK.
687 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) { 689 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) {
688 RunSuppressTest(SAVE_TO_DISK); 690 RunSuppressTest(SAVE_TO_DISK);
689 } 691 }
690 692
691 // This test verifies that no navigation action occurs when 693 // This test verifies that no navigation action occurs when
692 // WindowOpenDisposition = IGNORE_ACTION. 694 // WindowOpenDisposition = IGNORE_ACTION.
693 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) { 695 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) {
694 RunSuppressTest(IGNORE_ACTION); 696 RunSuppressTest(IGNORE_ACTION);
695 } 697 }
696 698
697 // This tests adding a foreground tab with a predefined WebContents. 699 // This tests adding a foreground tab with a predefined WebContents.
698 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { 700 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) {
699 chrome::NavigateParams p(MakeNavigateParams()); 701 chrome::NavigateParams params(MakeNavigateParams());
700 p.disposition = NEW_FOREGROUND_TAB; 702 params.disposition = NEW_FOREGROUND_TAB;
701 p.target_contents = CreateWebContents(); 703 params.target_contents = CreateWebContents();
702 chrome::Navigate(&p); 704 chrome::Navigate(&params);
703 705
704 // Navigate() should have opened the contents in a new foreground in the 706 // Navigate() should have opened the contents in a new foreground in the
705 // current Browser. 707 // current Browser.
706 EXPECT_EQ(browser(), p.browser); 708 EXPECT_EQ(browser(), params.browser);
707 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(), 709 EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(),
708 p.target_contents); 710 params.target_contents);
709 711
710 // We should have one window, with two tabs. 712 // We should have one window, with two tabs.
711 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 713 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
712 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 714 EXPECT_EQ(2, browser()->tab_strip_model()->count());
713 } 715 }
714 716
715 #if defined(OS_WIN) 717 #if defined(OS_WIN)
716 // This tests adding a popup with a predefined WebContents. 718 // This tests adding a popup with a predefined WebContents.
717 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { 719 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) {
718 chrome::NavigateParams p(MakeNavigateParams()); 720 chrome::NavigateParams params(MakeNavigateParams());
719 p.disposition = NEW_POPUP; 721 params.disposition = NEW_POPUP;
720 p.target_contents = CreateWebContents(); 722 params.target_contents = CreateWebContents();
721 p.window_bounds = gfx::Rect(10, 10, 500, 500); 723 params.window_bounds = gfx::Rect(10, 10, 500, 500);
722 chrome::Navigate(&p); 724 chrome::Navigate(&params);
723 725
724 // Navigate() should have opened a new popup window. 726 // Navigate() should have opened a new popup window.
725 EXPECT_NE(browser(), p.browser); 727 EXPECT_NE(browser(), params.browser);
726 EXPECT_TRUE(p.browser->is_type_popup()); 728 EXPECT_TRUE(params.browser->is_type_popup());
727 EXPECT_FALSE(p.browser->is_app()); 729 EXPECT_FALSE(params.browser->is_app());
728 730
729 // The web platform is weird. The window bounds specified in 731 // The web platform is weird. The window bounds specified in
730 // |p.window_bounds| are used as follows: 732 // |params.window_bounds| are used as follows:
731 // - the origin is used to position the window 733 // - the origin is used to position the window
732 // - the size is used to size the WebContents of the window. 734 // - the size is used to size the WebContents of the window.
733 // As such the position of the resulting window will always match 735 // As such the position of the resulting window will always match
734 // p.window_bounds.origin(), but its size will not. We need to match 736 // params.window_bounds.origin(), but its size will not. We need to match
735 // the size against the selected tab's view's container size. 737 // the size against the selected tab's view's container size.
736 // Only Windows positions the window according to |p.window_bounds.origin()| - 738 // Only Windows positions the window according to
737 // on Mac the window is offset from the opener and on Linux it always opens 739 // |params.window_bounds.origin()| - on Mac the window is offset from the
738 // at 0,0. 740 // opener and on Linux it always opens at 0,0.
739 EXPECT_EQ(p.window_bounds.origin(), 741 EXPECT_EQ(params.window_bounds.origin(),
740 p.browser->window()->GetRestoredBounds().origin()); 742 params.browser->window()->GetRestoredBounds().origin());
741 // All platforms should respect size however provided width > 400 (Mac has a 743 // All platforms should respect size however provided width > 400 (Mac has a
742 // minimum window width of 400). 744 // minimum window width of 400).
743 EXPECT_EQ(p.window_bounds.size(), 745 EXPECT_EQ(params.window_bounds.size(),
744 p.target_contents->GetContainerBounds().size()); 746 params.target_contents->GetContainerBounds().size());
745 747
746 // We should have two windows, the new popup and the browser() provided by the 748 // We should have two windows, the new popup and the browser() provided by the
747 // framework. 749 // framework.
748 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 750 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
749 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 751 EXPECT_EQ(1, browser()->tab_strip_model()->count());
750 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); 752 EXPECT_EQ(1, params.browser->tab_strip_model()->count());
751 } 753 }
752 #endif 754 #endif
753 755
754 // This tests adding a tab at a specific index. 756 // This tests adding a tab at a specific index.
755 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) { 757 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) {
756 // This is not meant to be a comprehensive test of whether or not the tab 758 // This is not meant to be a comprehensive test of whether or not the tab
757 // implementation of the browser observes the insertion index. That is 759 // implementation of the browser observes the insertion index. That is
758 // covered by the unit tests for TabStripModel. This merely verifies that 760 // covered by the unit tests for TabStripModel. This merely verifies that
759 // insertion index preference is reflected in common cases. 761 // insertion index preference is reflected in common cases.
760 chrome::NavigateParams p(MakeNavigateParams()); 762 chrome::NavigateParams params(MakeNavigateParams());
761 p.disposition = NEW_FOREGROUND_TAB; 763 params.disposition = NEW_FOREGROUND_TAB;
762 p.tabstrip_index = 0; 764 params.tabstrip_index = 0;
763 p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; 765 params.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX;
764 chrome::Navigate(&p); 766 chrome::Navigate(&params);
765 767
766 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. 768 // Navigate() should have inserted a new tab at slot 0 in the tabstrip.
767 EXPECT_EQ(browser(), p.browser); 769 EXPECT_EQ(browser(), params.browser);
768 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfWebContents( 770 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfWebContents(
769 static_cast<const WebContents*>(p.target_contents))); 771 static_cast<const WebContents*>(params.target_contents)));
770 772
771 // We should have one window - the browser() provided by the framework. 773 // We should have one window - the browser() provided by the framework.
772 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 774 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
773 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 775 EXPECT_EQ(2, browser()->tab_strip_model()->count());
774 } 776 }
775 777
776 // This test verifies that constructing params with disposition = SINGLETON_TAB 778 // This test verifies that constructing params with disposition = SINGLETON_TAB
777 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if 779 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if
778 // no previous tab with that URL (minus the path) exists. 780 // no previous tab with that URL (minus the path) exists.
779 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 781 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
780 Disposition_SingletonTabNew_IgnorePath) { 782 Disposition_SingletonTabNew_IgnorePath) {
781 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 783 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
782 ui::PAGE_TRANSITION_LINK); 784 ui::PAGE_TRANSITION_LINK);
783 785
784 // We should have one browser with 2 tabs, the 2nd selected. 786 // We should have one browser with 2 tabs, the 2nd selected.
785 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 787 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
786 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 788 EXPECT_EQ(2, browser()->tab_strip_model()->count());
787 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 789 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
788 790
789 // Navigate to a new singleton tab with a sub-page. 791 // Navigate to a new singleton tab with a sub-page.
790 chrome::NavigateParams p(MakeNavigateParams()); 792 chrome::NavigateParams params(MakeNavigateParams());
791 p.disposition = SINGLETON_TAB; 793 params.disposition = SINGLETON_TAB;
792 p.url = GetContentSettingsURL(); 794 params.url = GetContentSettingsURL();
793 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 795 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
794 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 796 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
795 chrome::Navigate(&p); 797 chrome::Navigate(&params);
796 798
797 // The last tab should now be selected and navigated to the sub-page of the 799 // The last tab should now be selected and navigated to the sub-page of the
798 // URL. 800 // URL.
799 EXPECT_EQ(browser(), p.browser); 801 EXPECT_EQ(browser(), params.browser);
800 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 802 EXPECT_EQ(3, browser()->tab_strip_model()->count());
801 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 803 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
802 EXPECT_EQ(GetContentSettingsURL(), 804 EXPECT_EQ(GetContentSettingsURL(),
803 ShortenUberURL(browser()->tab_strip_model()-> 805 ShortenUberURL(browser()->tab_strip_model()->
804 GetActiveWebContents()->GetURL())); 806 GetActiveWebContents()->GetURL()));
805 } 807 }
806 808
807 // This test verifies that constructing params with disposition = SINGLETON_TAB 809 // This test verifies that constructing params with disposition = SINGLETON_TAB
808 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus 810 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
809 // the path) which is navigated to the specified URL. 811 // the path) which is navigated to the specified URL.
810 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 812 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
811 Disposition_SingletonTabExisting_IgnorePath) { 813 Disposition_SingletonTabExisting_IgnorePath) {
812 GURL singleton_url1(GetSettingsURL()); 814 GURL singleton_url1(GetSettingsURL());
813 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 815 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
814 ui::PAGE_TRANSITION_LINK); 816 ui::PAGE_TRANSITION_LINK);
815 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 817 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
816 ui::PAGE_TRANSITION_LINK); 818 ui::PAGE_TRANSITION_LINK);
817 819
818 // We should have one browser with 3 tabs, the 3rd selected. 820 // We should have one browser with 3 tabs, the 3rd selected.
819 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 821 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
820 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 822 EXPECT_EQ(3, browser()->tab_strip_model()->count());
821 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 823 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
822 824
823 // Navigate to singleton_url1. 825 // Navigate to singleton_url1.
824 chrome::NavigateParams p(MakeNavigateParams()); 826 chrome::NavigateParams params(MakeNavigateParams());
825 p.disposition = SINGLETON_TAB; 827 params.disposition = SINGLETON_TAB;
826 p.url = GetContentSettingsURL(); 828 params.url = GetContentSettingsURL();
827 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 829 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
828 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 830 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
829 chrome::Navigate(&p); 831 chrome::Navigate(&params);
830 832
831 // The middle tab should now be selected and navigated to the sub-page of the 833 // The middle tab should now be selected and navigated to the sub-page of the
832 // URL. 834 // URL.
833 EXPECT_EQ(browser(), p.browser); 835 EXPECT_EQ(browser(), params.browser);
834 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 836 EXPECT_EQ(3, browser()->tab_strip_model()->count());
835 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 837 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
836 EXPECT_EQ(GetContentSettingsURL(), 838 EXPECT_EQ(GetContentSettingsURL(),
837 ShortenUberURL(browser()->tab_strip_model()-> 839 ShortenUberURL(browser()->tab_strip_model()->
838 GetActiveWebContents()->GetURL())); 840 GetActiveWebContents()->GetURL()));
839 } 841 }
840 842
841 // This test verifies that constructing params with disposition = SINGLETON_TAB 843 // This test verifies that constructing params with disposition = SINGLETON_TAB
842 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus 844 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
843 // the path) which is navigated to the specified URL. 845 // the path) which is navigated to the specified URL.
844 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 846 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
845 Disposition_SingletonTabExistingSubPath_IgnorePath) { 847 Disposition_SingletonTabExistingSubPath_IgnorePath) {
846 GURL singleton_url1(GetContentSettingsURL()); 848 GURL singleton_url1(GetContentSettingsURL());
847 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 849 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
848 ui::PAGE_TRANSITION_LINK); 850 ui::PAGE_TRANSITION_LINK);
849 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 851 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
850 ui::PAGE_TRANSITION_LINK); 852 ui::PAGE_TRANSITION_LINK);
851 853
852 // We should have one browser with 3 tabs, the 3rd selected. 854 // We should have one browser with 3 tabs, the 3rd selected.
853 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 855 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
854 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 856 EXPECT_EQ(3, browser()->tab_strip_model()->count());
855 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 857 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
856 858
857 // Navigate to singleton_url1. 859 // Navigate to singleton_url1.
858 chrome::NavigateParams p(MakeNavigateParams()); 860 chrome::NavigateParams params(MakeNavigateParams());
859 p.disposition = SINGLETON_TAB; 861 params.disposition = SINGLETON_TAB;
860 p.url = GetClearBrowsingDataURL(); 862 params.url = GetClearBrowsingDataURL();
861 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 863 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
862 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 864 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
863 chrome::Navigate(&p); 865 chrome::Navigate(&params);
864 866
865 // The middle tab should now be selected and navigated to the sub-page of the 867 // The middle tab should now be selected and navigated to the sub-page of the
866 // URL. 868 // URL.
867 EXPECT_EQ(browser(), p.browser); 869 EXPECT_EQ(browser(), params.browser);
868 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 870 EXPECT_EQ(3, browser()->tab_strip_model()->count());
869 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 871 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
870 EXPECT_EQ(GetClearBrowsingDataURL(), 872 EXPECT_EQ(GetClearBrowsingDataURL(),
871 ShortenUberURL(browser()->tab_strip_model()-> 873 ShortenUberURL(browser()->tab_strip_model()->
872 GetActiveWebContents()->GetURL())); 874 GetActiveWebContents()->GetURL()));
873 } 875 }
874 876
875 // This test verifies that constructing params with disposition = SINGLETON_TAB 877 // This test verifies that constructing params with disposition = SINGLETON_TAB
876 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus 878 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus
877 // the path). 879 // the path).
878 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 880 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
879 Disposition_SingletonTabExistingSubPath_IgnorePath2) { 881 Disposition_SingletonTabExistingSubPath_IgnorePath2) {
880 GURL singleton_url1(GetContentSettingsURL()); 882 GURL singleton_url1(GetContentSettingsURL());
881 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 883 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
882 ui::PAGE_TRANSITION_LINK); 884 ui::PAGE_TRANSITION_LINK);
883 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 885 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
884 ui::PAGE_TRANSITION_LINK); 886 ui::PAGE_TRANSITION_LINK);
885 887
886 // We should have one browser with 3 tabs, the 3rd selected. 888 // We should have one browser with 3 tabs, the 3rd selected.
887 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 889 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
888 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 890 EXPECT_EQ(3, browser()->tab_strip_model()->count());
889 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 891 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
890 892
891 // Navigate to singleton_url1. 893 // Navigate to singleton_url1.
892 chrome::NavigateParams p(MakeNavigateParams()); 894 chrome::NavigateParams params(MakeNavigateParams());
893 p.disposition = SINGLETON_TAB; 895 params.disposition = SINGLETON_TAB;
894 p.url = GetClearBrowsingDataURL(); 896 params.url = GetClearBrowsingDataURL();
895 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 897 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
896 p.path_behavior = chrome::NavigateParams::IGNORE_AND_STAY_PUT; 898 params.path_behavior = chrome::NavigateParams::IGNORE_AND_STAY_PUT;
897 chrome::Navigate(&p); 899 chrome::Navigate(&params);
898 900
899 // The middle tab should now be selected. 901 // The middle tab should now be selected.
900 EXPECT_EQ(browser(), p.browser); 902 EXPECT_EQ(browser(), params.browser);
901 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 903 EXPECT_EQ(3, browser()->tab_strip_model()->count());
902 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 904 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
903 EXPECT_EQ(singleton_url1, 905 EXPECT_EQ(singleton_url1,
904 ShortenUberURL(browser()->tab_strip_model()-> 906 ShortenUberURL(browser()->tab_strip_model()->
905 GetActiveWebContents()->GetURL())); 907 GetActiveWebContents()->GetURL()));
906 } 908 }
907 909
908 // This test verifies that constructing params with disposition = SINGLETON_TAB 910 // This test verifies that constructing params with disposition = SINGLETON_TAB
909 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently 911 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently
910 // selected tab is a match but has a different path. 912 // selected tab is a match but has a different path.
911 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 913 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
912 Disposition_SingletonTabFocused_IgnorePath) { 914 Disposition_SingletonTabFocused_IgnorePath) {
913 GURL singleton_url_current(GetContentSettingsURL()); 915 GURL singleton_url_current(GetContentSettingsURL());
914 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, 916 chrome::AddSelectedTabWithURL(browser(), singleton_url_current,
915 ui::PAGE_TRANSITION_LINK); 917 ui::PAGE_TRANSITION_LINK);
916 918
917 // We should have one browser with 2 tabs, the 2nd selected. 919 // We should have one browser with 2 tabs, the 2nd selected.
918 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 920 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
919 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 921 EXPECT_EQ(2, browser()->tab_strip_model()->count());
920 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 922 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
921 923
922 // Navigate to a different settings path. 924 // Navigate to a different settings path.
923 GURL singleton_url_target(GetClearBrowsingDataURL()); 925 GURL singleton_url_target(GetClearBrowsingDataURL());
924 chrome::NavigateParams p(MakeNavigateParams()); 926 chrome::NavigateParams params(MakeNavigateParams());
925 p.disposition = SINGLETON_TAB; 927 params.disposition = SINGLETON_TAB;
926 p.url = singleton_url_target; 928 params.url = singleton_url_target;
927 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 929 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
928 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 930 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
929 chrome::Navigate(&p); 931 chrome::Navigate(&params);
930 932
931 // The second tab should still be selected, but navigated to the new path. 933 // The second tab should still be selected, but navigated to the new path.
932 EXPECT_EQ(browser(), p.browser); 934 EXPECT_EQ(browser(), params.browser);
933 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 935 EXPECT_EQ(2, browser()->tab_strip_model()->count());
934 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 936 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
935 EXPECT_EQ(singleton_url_target, 937 EXPECT_EQ(singleton_url_target,
936 ShortenUberURL(browser()->tab_strip_model()-> 938 ShortenUberURL(browser()->tab_strip_model()->
937 GetActiveWebContents()->GetURL())); 939 GetActiveWebContents()->GetURL()));
938 } 940 }
939 941
940 // This test verifies that constructing params with disposition = SINGLETON_TAB 942 // This test verifies that constructing params with disposition = SINGLETON_TAB
941 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different 943 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different
942 // query. 944 // query.
943 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 945 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
944 Disposition_SingletonTabExisting_IgnoreQuery) { 946 Disposition_SingletonTabExisting_IgnoreQuery) {
945 int initial_tab_count = browser()->tab_strip_model()->count(); 947 int initial_tab_count = browser()->tab_strip_model()->count();
946 GURL singleton_url_current("chrome://settings/internet"); 948 GURL singleton_url_current("chrome://settings/internet");
947 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, 949 chrome::AddSelectedTabWithURL(browser(), singleton_url_current,
948 ui::PAGE_TRANSITION_LINK); 950 ui::PAGE_TRANSITION_LINK);
949 951
950 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count()); 952 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count());
951 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index()); 953 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index());
952 954
953 // Navigate to a different settings path. 955 // Navigate to a different settings path.
954 GURL singleton_url_target( 956 GURL singleton_url_target(
955 "chrome://settings/internet?" 957 "chrome://settings/internet?"
956 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); 958 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1");
957 chrome::NavigateParams p(MakeNavigateParams()); 959 chrome::NavigateParams params(MakeNavigateParams());
958 p.disposition = SINGLETON_TAB; 960 params.disposition = SINGLETON_TAB;
959 p.url = singleton_url_target; 961 params.url = singleton_url_target;
960 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 962 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
961 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 963 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
962 chrome::Navigate(&p); 964 chrome::Navigate(&params);
963 965
964 // Last tab should still be selected. 966 // Last tab should still be selected.
965 EXPECT_EQ(browser(), p.browser); 967 EXPECT_EQ(browser(), params.browser);
966 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count()); 968 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count());
967 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index()); 969 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index());
968 } 970 }
969 971
970 // This test verifies that the settings page isn't opened in the incognito 972 // This test verifies that the settings page isn't opened in the incognito
971 // window. 973 // window.
972 // Disabled until fixed for uber settings: http://crbug.com/111243 974 // Disabled until fixed for uber settings: http://crbug.com/111243
973 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 975 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
974 DISABLED_Disposition_Settings_UseNonIncognitoWindow) { 976 DISABLED_Disposition_Settings_UseNonIncognitoWindow) {
975 RunUseNonIncognitoWindowTest(GetSettingsURL()); 977 RunUseNonIncognitoWindowTest(GetSettingsURL());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 1057
1056 // We should have one browser with 2 tabs, the 2nd selected. 1058 // We should have one browser with 2 tabs, the 2nd selected.
1057 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 1059 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1058 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 1060 EXPECT_EQ(2, browser()->tab_strip_model()->count());
1059 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 1061 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
1060 1062
1061 // Kill the singleton tab. 1063 // Kill the singleton tab.
1062 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 1064 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1063 EXPECT_TRUE(web_contents->IsCrashed()); 1065 EXPECT_TRUE(web_contents->IsCrashed());
1064 1066
1065 chrome::NavigateParams p(MakeNavigateParams()); 1067 chrome::NavigateParams params(MakeNavigateParams());
1066 p.disposition = SINGLETON_TAB; 1068 params.disposition = SINGLETON_TAB;
1067 p.url = singleton_url; 1069 params.url = singleton_url;
1068 p.window_action = chrome::NavigateParams::SHOW_WINDOW; 1070 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
1069 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 1071 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
1070 ui_test_utils::NavigateToURL(&p); 1072 ui_test_utils::NavigateToURL(&params);
1071 1073
1072 // The tab should not be sad anymore. 1074 // The tab should not be sad anymore.
1073 EXPECT_FALSE(web_contents->IsCrashed()); 1075 EXPECT_FALSE(web_contents->IsCrashed());
1074 } 1076 }
1075 1077
1076 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1078 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1077 NavigateFromDefaultToOptionsInSameTab) { 1079 NavigateFromDefaultToOptionsInSameTab) {
1078 { 1080 {
1079 content::WindowedNotificationObserver observer( 1081 content::WindowedNotificationObserver observer(
1080 content::NOTIFICATION_LOAD_STOP, 1082 content::NOTIFICATION_LOAD_STOP,
1081 content::NotificationService::AllSources()); 1083 content::NotificationService::AllSources());
1082 chrome::ShowSettings(browser()); 1084 chrome::ShowSettings(browser());
1083 observer.Wait(); 1085 observer.Wait();
1084 } 1086 }
1085 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1087 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1086 EXPECT_EQ(GetSettingsURL(), 1088 EXPECT_EQ(GetSettingsURL(),
1087 ShortenUberURL(browser()->tab_strip_model()-> 1089 ShortenUberURL(browser()->tab_strip_model()->
1088 GetActiveWebContents()->GetURL())); 1090 GetActiveWebContents()->GetURL()));
1089 } 1091 }
1090 1092
1091 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1093 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1092 NavigateFromBlankToOptionsInSameTab) { 1094 NavigateFromBlankToOptionsInSameTab) {
1093 chrome::NavigateParams p(MakeNavigateParams()); 1095 chrome::NavigateParams params(MakeNavigateParams());
1094 p.url = GURL(url::kAboutBlankURL); 1096 params.url = GURL(url::kAboutBlankURL);
1095 ui_test_utils::NavigateToURL(&p); 1097 ui_test_utils::NavigateToURL(&params);
1096 1098
1097 { 1099 {
1098 content::WindowedNotificationObserver observer( 1100 content::WindowedNotificationObserver observer(
1099 content::NOTIFICATION_LOAD_STOP, 1101 content::NOTIFICATION_LOAD_STOP,
1100 content::NotificationService::AllSources()); 1102 content::NotificationService::AllSources());
1101 chrome::ShowSettings(browser()); 1103 chrome::ShowSettings(browser());
1102 observer.Wait(); 1104 observer.Wait();
1103 } 1105 }
1104 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1106 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1105 EXPECT_EQ(GetSettingsURL(), 1107 EXPECT_EQ(GetSettingsURL(),
1106 ShortenUberURL(browser()->tab_strip_model()-> 1108 ShortenUberURL(browser()->tab_strip_model()->
1107 GetActiveWebContents()->GetURL())); 1109 GetActiveWebContents()->GetURL()));
1108 } 1110 }
1109 1111
1110 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1112 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1111 NavigateFromNTPToOptionsInSameTab) { 1113 NavigateFromNTPToOptionsInSameTab) {
1112 chrome::NavigateParams p(MakeNavigateParams()); 1114 chrome::NavigateParams params(MakeNavigateParams());
1113 p.url = GURL(chrome::kChromeUINewTabURL); 1115 params.url = GURL(chrome::kChromeUINewTabURL);
1114 ui_test_utils::NavigateToURL(&p); 1116 ui_test_utils::NavigateToURL(&params);
1115 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1117 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1116 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), 1118 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
1117 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 1119 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
1118 1120
1119 { 1121 {
1120 content::WindowedNotificationObserver observer( 1122 content::WindowedNotificationObserver observer(
1121 content::NOTIFICATION_LOAD_STOP, 1123 content::NOTIFICATION_LOAD_STOP,
1122 content::NotificationService::AllSources()); 1124 content::NotificationService::AllSources());
1123 chrome::ShowSettings(browser()); 1125 chrome::ShowSettings(browser());
1124 observer.Wait(); 1126 observer.Wait();
1125 } 1127 }
1126 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1128 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1127 EXPECT_EQ(GetSettingsURL(), 1129 EXPECT_EQ(GetSettingsURL(),
1128 ShortenUberURL(browser()->tab_strip_model()-> 1130 ShortenUberURL(browser()->tab_strip_model()->
1129 GetActiveWebContents()->GetURL())); 1131 GetActiveWebContents()->GetURL()));
1130 } 1132 }
1131 1133
1132 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1134 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1133 NavigateFromPageToOptionsInNewTab) { 1135 NavigateFromPageToOptionsInNewTab) {
1134 chrome::NavigateParams p(MakeNavigateParams()); 1136 chrome::NavigateParams params(MakeNavigateParams());
1135 ui_test_utils::NavigateToURL(&p); 1137 ui_test_utils::NavigateToURL(&params);
1136 EXPECT_EQ(GetGoogleURL(), 1138 EXPECT_EQ(GetGoogleURL(),
1137 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 1139 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
1138 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 1140 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1139 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1141 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1140 1142
1141 { 1143 {
1142 content::WindowedNotificationObserver observer( 1144 content::WindowedNotificationObserver observer(
1143 content::NOTIFICATION_LOAD_STOP, 1145 content::NOTIFICATION_LOAD_STOP,
1144 content::NotificationService::AllSources()); 1146 content::NotificationService::AllSources());
1145 chrome::ShowSettings(browser()); 1147 chrome::ShowSettings(browser());
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1371
1370 // Open a renderer initiated POST request in new foreground tab. 1372 // Open a renderer initiated POST request in new foreground tab.
1371 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); 1373 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle));
1372 std::string post_data = kExpectedTitle; 1374 std::string post_data = kExpectedTitle;
1373 base::string16 title; 1375 base::string16 title;
1374 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( 1376 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle(
1375 test_server()->GetURL(kEchoTitleCommand), post_data, false, &title)); 1377 test_server()->GetURL(kEchoTitleCommand), post_data, false, &title));
1376 EXPECT_NE(expected_title, title); 1378 EXPECT_NE(expected_title, title);
1377 } 1379 }
1378 1380
1381 // This test navigates to a data URL that contains BiDi control
1382 // characters. For security reasons, BiDi control chars should always be
1383 // escaped in the URL but they should be unescaped in the rendered page.
msw 2014/10/21 19:19:24 nit: this test doesn't seem to check anything abou
meacer 2014/10/21 19:56:02 Changed to "loaded HTML".
1384 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1385 NavigateToDataURLWithBiDiControlChars) {
1386 // Text in Arabic.
1387 std::string text = "\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1";
1388 // Page title starts with RTL mark.
1389 std::string unescaped_title = "\xE2\x80\x8F" + text;
1390 std::string data_url = "data:text/html;charset=utf-8,<html><title>" +
1391 unescaped_title + "</title></html>";
1392 // BiDi control chars in URLs are always escaped, so the expected URL should
1393 // have the title with the escaped RTL mark.
1394 std::string escaped_title = "%E2%80%8F" + text;
1395 std::string expected_url = "data:text/html;charset=utf-8,<html><title>" +
1396 escaped_title + "</title></html>";
1397
1398 // Navigate to the page.
1399 chrome::NavigateParams params(MakeNavigateParams());
1400 params.disposition = NEW_FOREGROUND_TAB;
1401 params.url = GURL(data_url);
1402 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
1403 ui_test_utils::NavigateToURL(&params);
1404
1405 base::string16 expected_title(base::UTF8ToUTF16(unescaped_title));
1406 EXPECT_TRUE(params.target_contents);
1407 EXPECT_EQ(expected_title, params.target_contents->GetTitle());
1408 // GURL always keeps non-ASCII characters escaped.
1409 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec());
1410 // Check the omnibox text. It should have escaped RTL with unescaped text.
1411 LocationBar* location_bar = browser()->window()->GetLocationBar();
1412 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
1413 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText());
1414 }
1415
1379 } // namespace 1416 } // namespace
OLDNEW
« no previous file with comments | « no previous file | net/base/data_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698