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