| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/signin/signin_promo.h" | 6 #include "chrome/browser/signin/signin_promo.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 9 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" | 9 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
| 10 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 10 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 #else | 101 #else |
| 102 #define MAYBE_DifferentStorageId DifferentStorageId | 102 #define MAYBE_DifferentStorageId DifferentStorageId |
| 103 #endif | 103 #endif |
| 104 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, MAYBE_DifferentStorageId) { | 104 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, MAYBE_DifferentStorageId) { |
| 105 GURL test_url = ui_test_utils::GetTestUrl( | 105 GURL test_url = ui_test_utils::GetTestUrl( |
| 106 base::FilePath(base::FilePath::kCurrentDirectory), | 106 base::FilePath(base::FilePath::kCurrentDirectory), |
| 107 base::FilePath(FILE_PATH_LITERAL("title1.html"))); | 107 base::FilePath(FILE_PATH_LITERAL("title1.html"))); |
| 108 | 108 |
| 109 ContentInfo info1 = | 109 ContentInfo info1 = |
| 110 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB); | 110 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB); |
| 111 ContentInfo info2 = | 111 ContentInfo info2 = NavigateAndGetInfo( |
| 112 NavigateAndGetInfo(browser(), | 112 browser(), |
| 113 signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | 113 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), |
| 114 CURRENT_TAB); | 114 CURRENT_TAB); |
| 115 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB); | 115 NavigateAndGetInfo(browser(), test_url, CURRENT_TAB); |
| 116 ContentInfo info3 = | 116 ContentInfo info3 = NavigateAndGetInfo( |
| 117 NavigateAndGetInfo(browser(), | 117 browser(), |
| 118 signin::GetPromoURL( signin::SOURCE_START_PAGE, false), | 118 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), |
| 119 NEW_FOREGROUND_TAB); | 119 NEW_FOREGROUND_TAB); |
| 120 | 120 |
| 121 // The info for signin should be the same. | 121 // The info for signin should be the same. |
| 122 ASSERT_EQ(info2.storage_partition, info3.storage_partition); | 122 ASSERT_EQ(info2.storage_partition, info3.storage_partition); |
| 123 // The info for test_url and signin should be different. | 123 // The info for test_url and signin should be different. |
| 124 ASSERT_NE(info1.storage_partition, info2.storage_partition); | 124 ASSERT_NE(info1.storage_partition, info2.storage_partition); |
| 125 } | 125 } |
| 126 | 126 |
| 127 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, OneProcessLimit) { | 127 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, OneProcessLimit) { |
| 128 GURL test_url_1 = ui_test_utils::GetTestUrl( | 128 GURL test_url_1 = ui_test_utils::GetTestUrl( |
| 129 base::FilePath(base::FilePath::kCurrentDirectory), | 129 base::FilePath(base::FilePath::kCurrentDirectory), |
| 130 base::FilePath(FILE_PATH_LITERAL("title1.html"))); | 130 base::FilePath(FILE_PATH_LITERAL("title1.html"))); |
| 131 GURL test_url_2 = ui_test_utils::GetTestUrl( | 131 GURL test_url_2 = ui_test_utils::GetTestUrl( |
| 132 base::FilePath(base::FilePath::kCurrentDirectory), | 132 base::FilePath(base::FilePath::kCurrentDirectory), |
| 133 base::FilePath(FILE_PATH_LITERAL("data:text/html,Hello world!"))); | 133 base::FilePath(FILE_PATH_LITERAL("data:text/html,Hello world!"))); |
| 134 | 134 |
| 135 // Even when the process limit is set to one, the signin process should | 135 // Even when the process limit is set to one, the signin process should |
| 136 // still be given its own process and storage partition. | 136 // still be given its own process and storage partition. |
| 137 content::RenderProcessHost::SetMaxRendererProcessCount(1); | 137 content::RenderProcessHost::SetMaxRendererProcessCount(1); |
| 138 | 138 |
| 139 ContentInfo info1 = | 139 ContentInfo info1 = |
| 140 NavigateAndGetInfo(browser(), test_url_1, CURRENT_TAB); | 140 NavigateAndGetInfo(browser(), test_url_1, CURRENT_TAB); |
| 141 ContentInfo info2 = | 141 ContentInfo info2 = |
| 142 NavigateAndGetInfo(browser(), test_url_2, CURRENT_TAB); | 142 NavigateAndGetInfo(browser(), test_url_2, CURRENT_TAB); |
| 143 ContentInfo info3 = | 143 ContentInfo info3 = NavigateAndGetInfo( |
| 144 NavigateAndGetInfo(browser(), | 144 browser(), |
| 145 signin::GetPromoURL( signin::SOURCE_START_PAGE, false), | 145 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), |
| 146 CURRENT_TAB); | 146 CURRENT_TAB); |
| 147 | 147 |
| 148 ASSERT_EQ(info1.pid, info2.pid); | 148 ASSERT_EQ(info1.pid, info2.pid); |
| 149 ASSERT_NE(info1.pid, info3.pid); | 149 ASSERT_NE(info1.pid, info3.pid); |
| 150 } | 150 } |
| 151 | 151 |
| 152 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { | 152 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { |
| 153 public: | 153 public: |
| 154 FooWebUIProvider& foo_provider() { return foo_provider_; } | 154 FooWebUIProvider& foo_provider() { return foo_provider_; } |
| 155 | 155 |
| 156 private: | 156 private: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, Basic) { | 200 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, Basic) { |
| 201 const GURL kUrl(kFooWebUIURL); | 201 const GURL kUrl(kFooWebUIURL); |
| 202 EXPECT_CALL(foo_provider(), NewWebUI(_, ::testing::Eq(kUrl))) | 202 EXPECT_CALL(foo_provider(), NewWebUI(_, ::testing::Eq(kUrl))) |
| 203 .WillOnce(ReturnNewWebUI()); | 203 .WillOnce(ReturnNewWebUI()); |
| 204 ui_test_utils::NavigateToURL(browser(), GURL(kFooWebUIURL)); | 204 ui_test_utils::NavigateToURL(browser(), GURL(kFooWebUIURL)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Make sure that the foo webui handler does not get created when we try to | 207 // Make sure that the foo webui handler does not get created when we try to |
| 208 // load it inside the iframe of the login ui. | 208 // load it inside the iframe of the login ui. |
| 209 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { | 209 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { |
| 210 GURL url = signin::GetPromoURL(signin::SOURCE_START_PAGE, false). | 210 GURL url = signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false). |
| 211 Resolve("?source=0&frameUrl=chrome://foo"); | 211 Resolve("?source=0&frameUrl=chrome://foo"); |
| 212 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); | 212 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); |
| 213 ui_test_utils::NavigateToURL(browser(), url); | 213 ui_test_utils::NavigateToURL(browser(), url); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Flaky on CrOS, http://crbug.com/364759. | 216 // Flaky on CrOS, http://crbug.com/364759. |
| 217 #if defined(OS_CHROMEOS) | 217 #if defined(OS_CHROMEOS) |
| 218 #define MAYBE_TopFrameNavigationDisallowed DISABLED_TopFrameNavigationDisallowed | 218 #define MAYBE_TopFrameNavigationDisallowed DISABLED_TopFrameNavigationDisallowed |
| 219 #else | 219 #else |
| 220 #define MAYBE_TopFrameNavigationDisallowed TopFrameNavigationDisallowed | 220 #define MAYBE_TopFrameNavigationDisallowed TopFrameNavigationDisallowed |
| 221 #endif | 221 #endif |
| 222 | 222 |
| 223 // Make sure that the gaia iframe cannot trigger top-frame navigation. | 223 // Make sure that the gaia iframe cannot trigger top-frame navigation. |
| 224 // TODO(guohui): flaky on trybot crbug/364759. | 224 // TODO(guohui): flaky on trybot crbug/364759. |
| 225 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, | 225 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, |
| 226 MAYBE_TopFrameNavigationDisallowed) { | 226 MAYBE_TopFrameNavigationDisallowed) { |
| 227 // Loads into gaia iframe a web page that attempts to deframe on load. | 227 // Loads into gaia iframe a web page that attempts to deframe on load. |
| 228 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html")); | 228 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html")); |
| 229 GURL url(net::AppendOrReplaceQueryParameter( | 229 GURL url(net::AppendOrReplaceQueryParameter( |
| 230 signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | 230 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false), |
| 231 "frameUrl", deframe_url.spec())); | 231 "frameUrl", deframe_url.spec())); |
| 232 ui_test_utils::NavigateToURL(browser(), url); | 232 ui_test_utils::NavigateToURL(browser(), url); |
| 233 WaitUntilUIReady(browser()); | 233 WaitUntilUIReady(browser()); |
| 234 | 234 |
| 235 content::WebContents* contents = | 235 content::WebContents* contents = |
| 236 browser()->tab_strip_model()->GetActiveWebContents(); | 236 browser()->tab_strip_model()->GetActiveWebContents(); |
| 237 EXPECT_EQ(url, contents->GetVisibleURL()); | 237 EXPECT_EQ(url, contents->GetVisibleURL()); |
| 238 | 238 |
| 239 content::NavigationController& controller = contents->GetController(); | 239 content::NavigationController& controller = contents->GetController(); |
| 240 EXPECT_TRUE(controller.GetPendingEntry() == NULL); | 240 EXPECT_TRUE(controller.GetPendingEntry() == NULL); |
| 241 } | 241 } |
| 242 | 242 |
| 243 // Flaky on CrOS, http://crbug.com/364759. | 243 // Flaky on CrOS, http://crbug.com/364759. |
| 244 // Also flaky on Mac, http://crbug.com/442674. | 244 // Also flaky on Mac, http://crbug.com/442674. |
| 245 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | 245 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) |
| 246 #define MAYBE_NavigationToOtherChromeURLDisallowed \ | 246 #define MAYBE_NavigationToOtherChromeURLDisallowed \ |
| 247 DISABLED_NavigationToOtherChromeURLDisallowed | 247 DISABLED_NavigationToOtherChromeURLDisallowed |
| 248 #else | 248 #else |
| 249 #define MAYBE_NavigationToOtherChromeURLDisallowed \ | 249 #define MAYBE_NavigationToOtherChromeURLDisallowed \ |
| 250 NavigationToOtherChromeURLDisallowed | 250 NavigationToOtherChromeURLDisallowed |
| 251 #endif | 251 #endif |
| 252 | 252 |
| 253 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, | 253 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, |
| 254 MAYBE_NavigationToOtherChromeURLDisallowed) { | 254 MAYBE_NavigationToOtherChromeURLDisallowed) { |
| 255 ui_test_utils::NavigateToURL( | 255 ui_test_utils::NavigateToURL( |
| 256 browser(), signin::GetPromoURL(signin::SOURCE_START_PAGE, false)); | 256 browser(), signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false)); |
| 257 WaitUntilUIReady(browser()); | 257 WaitUntilUIReady(browser()); |
| 258 | 258 |
| 259 content::WebContents* contents = | 259 content::WebContents* contents = |
| 260 browser()->tab_strip_model()->GetActiveWebContents(); | 260 browser()->tab_strip_model()->GetActiveWebContents(); |
| 261 ASSERT_TRUE(content::ExecuteScript( | 261 ASSERT_TRUE(content::ExecuteScript( |
| 262 contents, "window.location.href = 'chrome://foo'")); | 262 contents, "window.location.href = 'chrome://foo'")); |
| 263 | 263 |
| 264 content::TestNavigationObserver navigation_observer(contents, 1); | 264 content::TestNavigationObserver navigation_observer(contents, 1); |
| 265 navigation_observer.Wait(); | 265 navigation_observer.Wait(); |
| 266 | 266 |
| 267 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); | 267 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); |
| 268 } | 268 } |
| 269 | 269 |
| 270 #if !defined(OS_CHROMEOS) | 270 #if !defined(OS_CHROMEOS) |
| 271 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, | 271 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, |
| 272 ConfirmationRequiredForNonsecureSignin) { | 272 ConfirmationRequiredForNonsecureSignin) { |
| 273 FakeGaia fake_gaia; | 273 FakeGaia fake_gaia; |
| 274 fake_gaia.Initialize(); | 274 fake_gaia.Initialize(); |
| 275 | 275 |
| 276 embedded_test_server()->RegisterRequestHandler( | 276 embedded_test_server()->RegisterRequestHandler( |
| 277 base::Bind(&FakeGaia::HandleRequest, | 277 base::Bind(&FakeGaia::HandleRequest, |
| 278 base::Unretained(&fake_gaia))); | 278 base::Unretained(&fake_gaia))); |
| 279 fake_gaia.SetFakeMergeSessionParams( | 279 fake_gaia.SetFakeMergeSessionParams( |
| 280 "email", "fake-sid-cookie", "fake-lsid-cookie"); | 280 "email", "fake-sid-cookie", "fake-lsid-cookie"); |
| 281 | 281 |
| 282 // Navigates to the Chrome signin page which loads the fake gaia auth page. | 282 // Navigates to the Chrome signin page which loads the fake gaia auth page. |
| 283 // Since the fake gaia auth page is served over HTTP, thus expects to see an | 283 // Since the fake gaia auth page is served over HTTP, thus expects to see an |
| 284 // untrusted signin confirmation dialog upon submitting credentials below. | 284 // untrusted signin confirmation dialog upon submitting credentials below. |
| 285 ui_test_utils::NavigateToURL( | 285 ui_test_utils::NavigateToURL( |
| 286 browser(), signin::GetPromoURL(signin::SOURCE_START_PAGE, false)); | 286 browser(), signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE, false)); |
| 287 WaitUntilUIReady(browser()); | 287 WaitUntilUIReady(browser()); |
| 288 | 288 |
| 289 MockLoginUIObserver observer; | 289 MockLoginUIObserver observer; |
| 290 LoginUIServiceFactory::GetForProfile(browser()->profile()) | 290 LoginUIServiceFactory::GetForProfile(browser()->profile()) |
| 291 ->AddObserver(&observer); | 291 ->AddObserver(&observer); |
| 292 base::RunLoop run_loop; | 292 base::RunLoop run_loop; |
| 293 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) | 293 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) |
| 294 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 294 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 295 | 295 |
| 296 ExecuteJsToSigninInSigninFrame(browser(), "email", "password"); | 296 ExecuteJsToSigninInSigninFrame(browser(), "email", "password"); |
| 297 run_loop.Run(); | 297 run_loop.Run(); |
| 298 base::MessageLoop::current()->RunUntilIdle(); | 298 base::MessageLoop::current()->RunUntilIdle(); |
| 299 } | 299 } |
| 300 #endif // OS_CHROMEOS | 300 #endif // OS_CHROMEOS |
| OLD | NEW |