Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc

Issue 2912103002: Avoid failed requests in inline login UI browser tests. (Closed)
Patch Set: Ready for review Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 }; 129 };
130 130
131 const char kFooWebUIURL[] = "chrome://foo/"; 131 const char kFooWebUIURL[] = "chrome://foo/";
132 132
133 bool AddToSet(std::set<content::WebContents*>* set, 133 bool AddToSet(std::set<content::WebContents*>* set,
134 content::WebContents* web_contents) { 134 content::WebContents* web_contents) {
135 set->insert(web_contents); 135 set->insert(web_contents);
136 return false; 136 return false;
137 } 137 }
138 138
139 std::unique_ptr<net::test_server::HttpResponse> EmptyHtmlResponseHandler(
140 const net::test_server::HttpRequest& request) {
141 std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
142 new net::test_server::BasicHttpResponse());
143 http_response->set_code(net::HTTP_OK);
144 http_response->set_content_type("text/html");
145 http_response->set_content(
146 "<html><head><link rel=manifest href=/manifest.json></head></html>");
147 return std::move(http_response);
148 }
149
139 // This class is used to mock out virtual methods with side effects so that 150 // This class is used to mock out virtual methods with side effects so that
140 // tests below can ensure they are called without causing side effects. 151 // tests below can ensure they are called without causing side effects.
141 class MockInlineSigninHelper : public InlineSigninHelper { 152 class MockInlineSigninHelper : public InlineSigninHelper {
142 public: 153 public:
143 MockInlineSigninHelper( 154 MockInlineSigninHelper(
144 base::WeakPtr<InlineLoginHandlerImpl> handler, 155 base::WeakPtr<InlineLoginHandlerImpl> handler,
145 net::URLRequestContextGetter* getter, 156 net::URLRequestContextGetter* getter,
146 Profile* profile, 157 Profile* profile,
147 const GURL& current_url, 158 const GURL& current_url,
148 const std::string& email, 159 const std::string& email,
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 ASSERT_EQ(2ul, BrowserList::GetInstance()->size()); 813 ASSERT_EQ(2ul, BrowserList::GetInstance()->size());
803 ASSERT_FALSE(entry->IsSigninRequired()); 814 ASSERT_FALSE(entry->IsSigninRequired());
804 } 815 }
805 816
806 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { 817 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest {
807 public: 818 public:
808 FooWebUIProvider& foo_provider() { return foo_provider_; } 819 FooWebUIProvider& foo_provider() { return foo_provider_; }
809 820
810 private: 821 private:
811 void SetUp() override { 822 void SetUp() override {
823 embedded_test_server()->RegisterRequestHandler(
824 base::Bind(&EmptyHtmlResponseHandler));
825
812 // Don't spin up the IO thread yet since no threads are allowed while 826 // Don't spin up the IO thread yet since no threads are allowed while
813 // spawning sandbox host process. See crbug.com/322732. 827 // spawning sandbox host process. See crbug.com/322732.
814 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); 828 ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
815 829
816 InProcessBrowserTest::SetUp(); 830 InProcessBrowserTest::SetUp();
817 } 831 }
818 832
819 void SetUpCommandLine(base::CommandLine* command_line) override { 833 void SetUpCommandLine(base::CommandLine* command_line) override {
820 const GURL& base_url = embedded_test_server()->base_url(); 834 const GURL& base_url = embedded_test_server()->base_url();
821 command_line->AppendSwitchASCII(::switches::kGaiaUrl, base_url.spec()); 835 command_line->AppendSwitchASCII(::switches::kGaiaUrl, base_url.spec());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 GURL url = GetSigninPromoURL().Resolve( 876 GURL url = GetSigninPromoURL().Resolve(
863 "?source=0&access_point=0&reason=0&frameUrl=chrome://foo"); 877 "?source=0&access_point=0&reason=0&frameUrl=chrome://foo");
864 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); 878 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0);
865 ui_test_utils::NavigateToURL(browser(), url); 879 ui_test_utils::NavigateToURL(browser(), url);
866 } 880 }
867 881
868 // Make sure that "success.html" can be loaded by chrome://chrome-signin. 882 // Make sure that "success.html" can be loaded by chrome://chrome-signin.
869 // http://crbug.com/709117. 883 // http://crbug.com/709117.
870 // Flaky on Linux and Mac. http://crbug.com/722164. 884 // Flaky on Linux and Mac. http://crbug.com/722164.
871 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, 885 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest,
872 DISABLED_LoadSuccessContinueURL) { 886 LoadSuccessContinueURL) {
873 ui_test_utils::NavigateToURL(browser(), GetSigninPromoURL()); 887 ui_test_utils::NavigateToURL(browser(), GetSigninPromoURL());
874 WaitUntilUIReady(browser()); 888 WaitUntilUIReady(browser());
875 889
876 const std::string success_url = 890 const std::string success_url =
877 GaiaUrls::GetInstance()->signin_completed_continue_url().spec(); 891 GaiaUrls::GetInstance()->signin_completed_continue_url().spec();
878 const char* kLoadSuccessPageScript = 892 const char* kLoadSuccessPageScript =
879 "var handler = function(e) {" 893 "var handler = function(e) {"
880 " if (e.url == '%s') {" 894 " if (e.url == '%s') {"
881 " window.domAutomationController.send('success_page_loaded');" 895 " window.domAutomationController.send('success_page_loaded');"
882 " }" 896 " }"
883 "};" 897 "};"
884 "var extension_webview = inline.login.getAuthExtHost().webview_;" 898 "var extension_webview = inline.login.getAuthExtHost().webview_;"
885 "extension_webview.addEventListener('loadcommit', handler);" 899 "extension_webview.addEventListener('loadcommit', handler);"
886 "extension_webview.src = '%s';"; 900 "extension_webview.src = '%s';";
887 std::string script = base::StringPrintf( 901 std::string script = base::StringPrintf(
888 kLoadSuccessPageScript, success_url.c_str(), success_url.c_str()); 902 kLoadSuccessPageScript, success_url.c_str(), success_url.c_str());
889 903
890 std::string message; 904 std::string message;
891 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 905 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
892 browser()->tab_strip_model()->GetActiveWebContents(), script, &message)); 906 browser()->tab_strip_model()->GetActiveWebContents(), script, &message));
893 EXPECT_EQ("success_page_loaded", message); 907 EXPECT_EQ("success_page_loaded", message);
894 } 908 }
895 909
896 // Make sure that the gaia iframe cannot trigger top-frame navigation. 910 // Make sure that the gaia iframe cannot trigger top-frame navigation.
897 // TODO(guohui): flaky on trybot crbug/364759.
898 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, 911 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest,
899 TopFrameNavigationDisallowed) { 912 TopFrameNavigationDisallowed) {
900 // Loads into gaia iframe a web page that attempts to deframe on load. 913 // Loads into gaia iframe a web page that attempts to deframe on load.
901 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html")); 914 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html"));
902 GURL url(net::AppendOrReplaceQueryParameter(GetSigninPromoURL(), "frameUrl", 915 GURL url(net::AppendOrReplaceQueryParameter(GetSigninPromoURL(), "frameUrl",
903 deframe_url.spec())); 916 deframe_url.spec()));
904 ui_test_utils::NavigateToURL(browser(), url); 917 ui_test_utils::NavigateToURL(browser(), url);
905 WaitUntilUIReady(browser()); 918 WaitUntilUIReady(browser());
906 919
907 content::WebContents* contents = 920 content::WebContents* contents =
(...skipping 15 matching lines...) Expand all
923 content::WebContents* contents = 936 content::WebContents* contents =
924 browser()->tab_strip_model()->GetActiveWebContents(); 937 browser()->tab_strip_model()->GetActiveWebContents();
925 ASSERT_TRUE(content::ExecuteScript( 938 ASSERT_TRUE(content::ExecuteScript(
926 contents, "window.location.href = 'chrome://foo'")); 939 contents, "window.location.href = 'chrome://foo'"));
927 940
928 content::TestNavigationObserver navigation_observer(contents, 1); 941 content::TestNavigationObserver navigation_observer(contents, 1);
929 navigation_observer.Wait(); 942 navigation_observer.Wait();
930 943
931 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL()); 944 EXPECT_EQ(GURL("about:blank"), contents->GetVisibleURL());
932 } 945 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698