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