| 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" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 const char kPrefetchAuthPage[] = "/login/prefetch.html"; | 96 const char kPrefetchAuthPage[] = "/login/prefetch.html"; |
| 97 | 97 |
| 98 const char kMultiRealmTestPage[] = "/login/multi_realm.html"; | 98 const char kMultiRealmTestPage[] = "/login/multi_realm.html"; |
| 99 const int kMultiRealmTestRealmCount = 2; | 99 const int kMultiRealmTestRealmCount = 2; |
| 100 | 100 |
| 101 const char kSingleRealmTestPage[] = "/login/single_realm.html"; | 101 const char kSingleRealmTestPage[] = "/login/single_realm.html"; |
| 102 | 102 |
| 103 const char kAuthBasicPage[] = "/auth-basic"; | 103 const char kAuthBasicPage[] = "/auth-basic"; |
| 104 const char kAuthDigestPage[] = "/auth-digest"; | 104 const char kAuthDigestPage[] = "/auth-digest"; |
| 105 | 105 |
| 106 const char kNoAuthPage1[] = "/a"; | 106 // It does not matter what pages are selected as no-auth, as long as they exist. |
| 107 const char kNoAuthPage2[] = "/b"; | 107 // Navigating to non-existing pages caused flakes in the past |
| 108 // (https://crbug.com/636875). |
| 109 const char kNoAuthPage1[] = "/simple.html"; |
| 110 const char kNoAuthPage2[] = "/form.html"; |
| 108 | 111 |
| 109 base::string16 ExpectedTitleFromAuth(const base::string16& username, | 112 base::string16 ExpectedTitleFromAuth(const base::string16& username, |
| 110 const base::string16& password) { | 113 const base::string16& password) { |
| 111 // The TestServer sets the title to username/password on successful login. | 114 // The TestServer sets the title to username/password on successful login. |
| 112 return username + base::UTF8ToUTF16("/") + password; | 115 return username + base::UTF8ToUTF16("/") + password; |
| 113 } | 116 } |
| 114 | 117 |
| 115 // Confirm that <link rel="prefetch"> targetting an auth required | 118 // Confirm that <link rel="prefetch"> targetting an auth required |
| 116 // resource does not provide a login dialog. These types of requests | 119 // resource does not provide a login dialog. These types of requests |
| 117 // should instead just cancel the auth. | 120 // should instead just cancel the auth. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 WindowedAuthCancelledObserver auth_cancelled_waiter(controller); | 402 WindowedAuthCancelledObserver auth_cancelled_waiter(controller); |
| 400 // Navigating back while auth is requested is the same as cancelling. | 403 // Navigating back while auth is requested is the same as cancelling. |
| 401 ASSERT_TRUE(controller->CanGoBack()); | 404 ASSERT_TRUE(controller->CanGoBack()); |
| 402 controller->GoBack(); | 405 controller->GoBack(); |
| 403 auth_cancelled_waiter.Wait(); | 406 auth_cancelled_waiter.Wait(); |
| 404 load_stop_waiter.Wait(); | 407 load_stop_waiter.Wait(); |
| 405 EXPECT_TRUE(observer.handlers().empty()); | 408 EXPECT_TRUE(observer.handlers().empty()); |
| 406 } | 409 } |
| 407 | 410 |
| 408 // Test login prompt cancellation on navigation to forward. | 411 // Test login prompt cancellation on navigation to forward. |
| 409 // TODO(crbug.com/636875) Flaky on Mac and Linux at least. | 412 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestCancelAuth_OnForward) { |
| 410 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, | |
| 411 DISABLED_TestCancelAuth_OnForward) { | |
| 412 ASSERT_TRUE(embedded_test_server()->Start()); | 413 ASSERT_TRUE(embedded_test_server()->Start()); |
| 413 const GURL kAuthURL = embedded_test_server()->GetURL(kAuthBasicPage); | 414 const GURL kAuthURL = embedded_test_server()->GetURL(kAuthBasicPage); |
| 414 const GURL kNoAuthURL1 = embedded_test_server()->GetURL(kNoAuthPage1); | 415 const GURL kNoAuthURL1 = embedded_test_server()->GetURL(kNoAuthPage1); |
| 415 const GURL kNoAuthURL2 = embedded_test_server()->GetURL(kNoAuthPage2); | 416 const GURL kNoAuthURL2 = embedded_test_server()->GetURL(kNoAuthPage2); |
| 416 | 417 |
| 417 NavigationController* controller = | 418 NavigationController* controller = |
| 418 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); | 419 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); |
| 419 | 420 |
| 420 LoginPromptBrowserTestObserver observer; | 421 LoginPromptBrowserTestObserver observer; |
| 421 observer.Register(content::Source<NavigationController>(controller)); | 422 observer.Register(content::Source<NavigationController>(controller)); |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 // out. | 1502 // out. |
| 1502 EXPECT_TRUE( | 1503 EXPECT_TRUE( |
| 1503 WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame())); | 1504 WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame())); |
| 1504 EXPECT_TRUE(contents->ShowingInterstitialPage()); | 1505 EXPECT_TRUE(contents->ShowingInterstitialPage()); |
| 1505 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, contents->GetInterstitialPage() | 1506 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, contents->GetInterstitialPage() |
| 1506 ->GetDelegateForTesting() | 1507 ->GetDelegateForTesting() |
| 1507 ->GetTypeForTesting()); | 1508 ->GetTypeForTesting()); |
| 1508 } | 1509 } |
| 1509 | 1510 |
| 1510 } // namespace | 1511 } // namespace |
| OLD | NEW |