Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 base::Closure(), | 1220 base::Closure(), |
| 1220 loop_runner->QuitClosure()); | 1221 loop_runner->QuitClosure()); |
| 1221 handler->CancelAuth(); | 1222 handler->CancelAuth(); |
| 1222 if (content::InterstitialPage::GetInterstitialPage(contents)) | 1223 if (content::InterstitialPage::GetInterstitialPage(contents)) |
| 1223 loop_runner->Run(); | 1224 loop_runner->Run(); |
| 1224 EXPECT_EQ("www.a.com", contents->GetURL().host()); | 1225 EXPECT_EQ("www.a.com", contents->GetURL().host()); |
| 1225 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 1226 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
| 1226 } | 1227 } |
| 1227 } | 1228 } |
| 1228 | 1229 |
| 1230 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, | |
| 1231 LoginInterstitialShouldReplaceExistingInterstitial) { | |
| 1232 net::SpawnedTestServer https_server( | |
| 1233 net::SpawnedTestServer::TYPE_HTTPS, | |
| 1234 net::SpawnedTestServer::SSLOptions( | |
| 1235 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | |
| 1236 base::FilePath() | |
| 1237 ); | |
| 1238 ASSERT_TRUE(https_server.Start()); | |
| 1239 | |
| 1240 content::WebContents* contents = | |
| 1241 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1242 NavigationController* controller = &contents->GetController(); | |
| 1243 LoginPromptBrowserTestObserver observer; | |
| 1244 | |
| 1245 observer.Register(content::Source<NavigationController>(controller)); | |
| 1246 | |
| 1247 // Load a page which triggers an SSL interstitial. Proceeding through it | |
| 1248 // should show the login page with the blank interstitial. | |
| 1249 { | |
| 1250 GURL test_page = https_server.GetURL(kAuthBasicPage); | |
| 1251 ASSERT_EQ("127.0.0.1", test_page.host()); | |
| 1252 | |
| 1253 WindowedAuthNeededObserver auth_needed_waiter(controller); | |
| 1254 browser()->OpenURL(OpenURLParams( | |
| 1255 test_page, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, | |
| 1256 false)); | |
| 1257 ASSERT_EQ("127.0.0.1", contents->GetURL().host()); | |
| 1258 WaitForInterstitialAttach(contents); | |
| 1259 | |
| 1260 // An overrideable SSL interstitial is now being displayed. Proceed through | |
| 1261 // the interstitial to see the login prompt. | |
| 1262 contents->GetInterstitialPage()->Proceed(); | |
| 1263 auth_needed_waiter.Wait(); | |
| 1264 ASSERT_EQ(1u, observer.handlers().size()); | |
| 1265 WaitForInterstitialAttach(contents); | |
| 1266 | |
| 1267 // The omnibox should show the correct origin while the login prompt is | |
| 1268 // being displayed. | |
| 1269 EXPECT_EQ("127.0.0.1", contents->GetURL().host()); | |
|
nasko
2014/07/17 14:08:44
GetVisibleURL
meacer
2014/07/17 22:08:18
Done.
| |
| 1270 EXPECT_TRUE(contents->ShowingInterstitialPage()); | |
| 1271 | |
| 1272 // Cancelling the login prompt should detach the interstitial and keep the | |
| 1273 // correct origin. | |
| 1274 LoginHandler* handler = *observer.handlers().begin(); | |
| 1275 scoped_refptr<content::MessageLoopRunner> loop_runner( | |
| 1276 new content::MessageLoopRunner); | |
| 1277 InterstitialObserver interstitial_observer(contents, | |
| 1278 base::Closure(), | |
| 1279 loop_runner->QuitClosure()); | |
| 1280 handler->CancelAuth(); | |
| 1281 if (content::InterstitialPage::GetInterstitialPage(contents)) | |
| 1282 loop_runner->Run(); | |
| 1283 EXPECT_EQ("127.0.0.1", contents->GetURL().host()); | |
|
nasko
2014/07/17 14:08:44
GetVisibleURL
meacer
2014/07/17 22:08:18
Done.
| |
| 1284 EXPECT_FALSE(contents->ShowingInterstitialPage()); | |
| 1285 } | |
| 1286 } | |
| 1287 | |
| 1229 } // namespace | 1288 } // namespace |
| OLD | NEW |