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