| 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 "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 NavigateAndGetInfo(browser(), test_url_1, CURRENT_TAB); | 346 NavigateAndGetInfo(browser(), test_url_1, CURRENT_TAB); |
| 347 ContentInfo info2 = | 347 ContentInfo info2 = |
| 348 NavigateAndGetInfo(browser(), test_url_2, CURRENT_TAB); | 348 NavigateAndGetInfo(browser(), test_url_2, CURRENT_TAB); |
| 349 ContentInfo info3 = | 349 ContentInfo info3 = |
| 350 NavigateAndGetInfo(browser(), GetSigninPromoURL(), CURRENT_TAB); | 350 NavigateAndGetInfo(browser(), GetSigninPromoURL(), CURRENT_TAB); |
| 351 | 351 |
| 352 ASSERT_EQ(info1.pid, info2.pid); | 352 ASSERT_EQ(info1.pid, info2.pid); |
| 353 ASSERT_NE(info1.pid, info3.pid); | 353 ASSERT_NE(info1.pid, info3.pid); |
| 354 } | 354 } |
| 355 | 355 |
| 356 #if !defined(OS_CHROMEOS) | |
| 357 | |
| 358 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferNoProfile) { | 356 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferNoProfile) { |
| 359 std::string error_message; | 357 std::string error_message; |
| 360 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( | 358 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( |
| 361 NULL, InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 359 NULL, InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 362 "12345", "user@gmail.com", &error_message)); | 360 "12345", "user@gmail.com", &error_message)); |
| 363 EXPECT_EQ("", error_message); | 361 EXPECT_EQ("", error_message); |
| 364 } | 362 } |
| 365 | 363 |
| 366 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOffer) { | 364 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOffer) { |
| 367 EnableOneClick(true); | 365 EnableOneClick(true); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 "", // session index | 749 "", // session index |
| 752 "auth_code", // auth code | 750 "auth_code", // auth code |
| 753 std::string(), | 751 std::string(), |
| 754 false, // choose what to sync | 752 false, // choose what to sync |
| 755 false); // confirm untrusted signin | 753 false); // confirm untrusted signin |
| 756 SimulateOnClientOAuthSuccess(&helper, "refresh_token"); | 754 SimulateOnClientOAuthSuccess(&helper, "refresh_token"); |
| 757 ASSERT_EQ(1ul, token_service()->GetAccounts().size()); | 755 ASSERT_EQ(1ul, token_service()->GetAccounts().size()); |
| 758 base::MessageLoop::current()->RunUntilIdle(); | 756 base::MessageLoop::current()->RunUntilIdle(); |
| 759 } | 757 } |
| 760 | 758 |
| 761 #endif // OS_CHROMEOS | |
| 762 | |
| 763 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { | 759 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { |
| 764 public: | 760 public: |
| 765 FooWebUIProvider& foo_provider() { return foo_provider_; } | 761 FooWebUIProvider& foo_provider() { return foo_provider_; } |
| 766 | 762 |
| 767 private: | 763 private: |
| 768 void SetUp() override { | 764 void SetUp() override { |
| 769 // Don't spin up the IO thread yet since no threads are allowed while | 765 // Don't spin up the IO thread yet since no threads are allowed while |
| 770 // spawning sandbox host process. See crbug.com/322732. | 766 // spawning sandbox host process. See crbug.com/322732. |
| 771 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); | 767 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); |
| 772 | 768 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 | 811 |
| 816 // Make sure that the foo webui handler does not get created when we try to | 812 // Make sure that the foo webui handler does not get created when we try to |
| 817 // load it inside the iframe of the login ui. | 813 // load it inside the iframe of the login ui. |
| 818 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { | 814 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { |
| 819 GURL url = GetSigninPromoURL().Resolve( | 815 GURL url = GetSigninPromoURL().Resolve( |
| 820 "?source=0&access_point=0&reason=0&frameUrl=chrome://foo"); | 816 "?source=0&access_point=0&reason=0&frameUrl=chrome://foo"); |
| 821 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); | 817 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); |
| 822 ui_test_utils::NavigateToURL(browser(), url); | 818 ui_test_utils::NavigateToURL(browser(), url); |
| 823 } | 819 } |
| 824 | 820 |
| 825 // Flaky on CrOS, http://crbug.com/364759. | |
| 826 #if defined(OS_CHROMEOS) | |
| 827 #define MAYBE_TopFrameNavigationDisallowed DISABLED_TopFrameNavigationDisallowed | |
| 828 #else | |
| 829 #define MAYBE_TopFrameNavigationDisallowed TopFrameNavigationDisallowed | |
| 830 #endif | |
| 831 | |
| 832 // Make sure that the gaia iframe cannot trigger top-frame navigation. | 821 // Make sure that the gaia iframe cannot trigger top-frame navigation. |
| 833 // TODO(guohui): flaky on trybot crbug/364759. | 822 // TODO(guohui): flaky on trybot crbug/364759. |
| 834 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, | 823 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, |
| 835 MAYBE_TopFrameNavigationDisallowed) { | 824 TopFrameNavigationDisallowed) { |
| 836 // Loads into gaia iframe a web page that attempts to deframe on load. | 825 // Loads into gaia iframe a web page that attempts to deframe on load. |
| 837 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html")); | 826 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html")); |
| 838 GURL url(net::AppendOrReplaceQueryParameter(GetSigninPromoURL(), "frameUrl", | 827 GURL url(net::AppendOrReplaceQueryParameter(GetSigninPromoURL(), "frameUrl", |
| 839 deframe_url.spec())); | 828 deframe_url.spec())); |
| 840 ui_test_utils::NavigateToURL(browser(), url); | 829 ui_test_utils::NavigateToURL(browser(), url); |
| 841 WaitUntilUIReady(browser()); | 830 WaitUntilUIReady(browser()); |
| 842 | 831 |
| 843 content::WebContents* contents = | 832 content::WebContents* contents = |
| 844 browser()->tab_strip_model()->GetActiveWebContents(); | 833 browser()->tab_strip_model()->GetActiveWebContents(); |
| 845 EXPECT_EQ(url, contents->GetVisibleURL()); | 834 EXPECT_EQ(url, contents->GetVisibleURL()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 860 browser()->tab_strip_model()->GetActiveWebContents(); | 849 browser()->tab_strip_model()->GetActiveWebContents(); |
| 861 ASSERT_TRUE(content::ExecuteScript( | 850 ASSERT_TRUE(content::ExecuteScript( |
| 862 contents, "window.location.href = 'chrome://foo'")); | 851 contents, "window.location.href = 'chrome://foo'")); |
| 863 | 852 |
| 864 content::TestNavigationObserver navigation_observer(contents, 1); | 853 content::TestNavigationObserver navigation_observer(contents, 1); |
| 865 navigation_observer.Wait(); | 854 navigation_observer.Wait(); |
| 866 | 855 |
| 867 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); | 856 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); |
| 868 } | 857 } |
| 869 | 858 |
| 870 #if !defined(OS_CHROMEOS) | |
| 871 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, | 859 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, |
| 872 ConfirmationRequiredForNonsecureSignin) { | 860 ConfirmationRequiredForNonsecureSignin) { |
| 873 FakeGaia fake_gaia; | 861 FakeGaia fake_gaia; |
| 874 fake_gaia.Initialize(); | 862 fake_gaia.Initialize(); |
| 875 | 863 |
| 876 embedded_test_server()->RegisterRequestHandler( | 864 embedded_test_server()->RegisterRequestHandler( |
| 877 base::Bind(&FakeGaia::HandleRequest, | 865 base::Bind(&FakeGaia::HandleRequest, |
| 878 base::Unretained(&fake_gaia))); | 866 base::Unretained(&fake_gaia))); |
| 879 fake_gaia.SetFakeMergeSessionParams( | 867 fake_gaia.SetFakeMergeSessionParams( |
| 880 "email@gmail.com", "fake-sid-cookie", "fake-lsid-cookie"); | 868 "email@gmail.com", "fake-sid-cookie", "fake-lsid-cookie"); |
| 881 | 869 |
| 882 // Navigates to the Chrome signin page which loads the fake gaia auth page. | 870 // Navigates to the Chrome signin page which loads the fake gaia auth page. |
| 883 // Since the fake gaia auth page is served over HTTP, thus expects to see an | 871 // Since the fake gaia auth page is served over HTTP, thus expects to see an |
| 884 // untrusted signin confirmation dialog upon submitting credentials below. | 872 // untrusted signin confirmation dialog upon submitting credentials below. |
| 885 ui_test_utils::NavigateToURL(browser(), GetSigninPromoURL()); | 873 ui_test_utils::NavigateToURL(browser(), GetSigninPromoURL()); |
| 886 WaitUntilUIReady(browser()); | 874 WaitUntilUIReady(browser()); |
| 887 | 875 |
| 888 MockLoginUIObserver observer; | 876 MockLoginUIObserver observer; |
| 889 LoginUIServiceFactory::GetForProfile(browser()->profile()) | 877 LoginUIServiceFactory::GetForProfile(browser()->profile()) |
| 890 ->AddObserver(&observer); | 878 ->AddObserver(&observer); |
| 891 base::RunLoop run_loop; | 879 base::RunLoop run_loop; |
| 892 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) | 880 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) |
| 893 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 881 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 894 | 882 |
| 895 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password"); | 883 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password"); |
| 896 run_loop.Run(); | 884 run_loop.Run(); |
| 897 base::MessageLoop::current()->RunUntilIdle(); | 885 base::MessageLoop::current()->RunUntilIdle(); |
| 898 } | 886 } |
| 899 #endif // OS_CHROMEOS | |
| OLD | NEW |