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

Side by Side Diff: chrome/browser/ui/login/login_prompt_browsertest.cc

Issue 397453002: Add test case to see if HTTP auth interstitials work nicely with other interstitials (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: msw comments Created 6 years, 4 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 | Annotate | Revision Log
« 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <list> 6 #include <list>
7 #include <map> 7 #include <map>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/prerender/prerender_manager.h" 12 #include "chrome/browser/prerender/prerender_manager.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h" 14 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/login/login_prompt.h" 15 #include "chrome/browser/ui/login/login_prompt.h"
16 #include "chrome/browser/ui/login/login_prompt_test_utils.h" 16 #include "chrome/browser/ui/login/login_prompt_test_utils.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/interstitial_page.h" 20 #include "content/public/browser/interstitial_page.h"
21 #include "content/public/browser/notification_details.h" 21 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
25 #include "content/public/test/test_navigation_observer.h" 25 #include "content/public/test/test_navigation_observer.h"
26 #include "net/base/auth.h" 26 #include "net/base/auth.h"
27 #include "net/dns/mock_host_resolver.h" 27 #include "net/dns/mock_host_resolver.h"
28 #include "net/test/spawned_test_server/spawned_test_server.h"
28 29
29 using content::NavigationController; 30 using content::NavigationController;
30 using content::OpenURLParams; 31 using content::OpenURLParams;
31 using content::Referrer; 32 using content::Referrer;
32 33
33 namespace { 34 namespace {
34 35
35 class LoginPromptBrowserTest : public InProcessBrowserTest { 36 class LoginPromptBrowserTest : public InProcessBrowserTest {
36 public: 37 public:
37 LoginPromptBrowserTest() 38 LoginPromptBrowserTest()
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 host_resolver()->AddRule("www.a.com", "127.0.0.1"); 1243 host_resolver()->AddRule("www.a.com", "127.0.0.1");
1243 ASSERT_TRUE(test_server()->Start()); 1244 ASSERT_TRUE(test_server()->Start());
1244 1245
1245 const char* kTestPage = "files/login/cross_origin.html"; 1246 const char* kTestPage = "files/login/cross_origin.html";
1246 GURL test_page = test_server()->GetURL(kTestPage); 1247 GURL test_page = test_server()->GetURL(kTestPage);
1247 ASSERT_EQ("127.0.0.1", test_page.host()); 1248 ASSERT_EQ("127.0.0.1", test_page.host());
1248 std::string auth_host("www.a.com"); 1249 std::string auth_host("www.a.com");
1249 TestCrossOriginPrompt(test_page, auth_host); 1250 TestCrossOriginPrompt(test_page, auth_host);
1250 } 1251 }
1251 1252
1253 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest,
1254 LoginInterstitialShouldReplaceExistingInterstitial) {
1255 net::SpawnedTestServer https_server(
1256 net::SpawnedTestServer::TYPE_HTTPS,
1257 net::SpawnedTestServer::SSLOptions(
1258 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED),
1259 base::FilePath());
1260 ASSERT_TRUE(https_server.Start());
1261
1262 content::WebContents* contents =
1263 browser()->tab_strip_model()->GetActiveWebContents();
1264 NavigationController* controller = &contents->GetController();
1265 LoginPromptBrowserTestObserver observer;
1266
1267 observer.Register(content::Source<NavigationController>(controller));
1268
1269 // Load a page which triggers an SSL interstitial. Proceeding through it
1270 // should show the login page with the blank interstitial.
1271 {
1272 GURL test_page = https_server.GetURL(kAuthBasicPage);
1273 ASSERT_EQ("127.0.0.1", test_page.host());
1274
1275 WindowedAuthNeededObserver auth_needed_waiter(controller);
1276 browser()->OpenURL(OpenURLParams(
1277 test_page, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,
1278 false));
1279 ASSERT_EQ("127.0.0.1", contents->GetURL().host());
1280 WaitForInterstitialAttach(contents);
1281
1282 // An overrideable SSL interstitial is now being displayed. Proceed through
1283 // the interstitial to see the login prompt.
1284 contents->GetInterstitialPage()->Proceed();
1285 auth_needed_waiter.Wait();
1286 ASSERT_EQ(1u, observer.handlers().size());
1287 WaitForInterstitialAttach(contents);
1288
1289 // The omnibox should show the correct origin while the login prompt is
1290 // being displayed.
1291 EXPECT_EQ("127.0.0.1", contents->GetVisibleURL().host());
1292 EXPECT_TRUE(contents->ShowingInterstitialPage());
1293
1294 // Cancelling the login prompt should detach the interstitial while keeping
1295 // the correct origin.
1296 LoginHandler* handler = *observer.handlers().begin();
1297 scoped_refptr<content::MessageLoopRunner> loop_runner(
1298 new content::MessageLoopRunner);
1299 InterstitialObserver interstitial_observer(contents,
1300 base::Closure(),
1301 loop_runner->QuitClosure());
1302 handler->CancelAuth();
1303 if (content::InterstitialPage::GetInterstitialPage(contents))
1304 loop_runner->Run();
1305 EXPECT_EQ("127.0.0.1", contents->GetVisibleURL().host());
1306 EXPECT_FALSE(contents->ShowingInterstitialPage());
1307 }
1308 }
1309
1252 } // namespace 1310 } // namespace
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