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