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" |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 } | 976 } |
| 977 | 977 |
| 978 EXPECT_EQ(1, observer.auth_needed_count()); | 978 EXPECT_EQ(1, observer.auth_needed_count()); |
| 979 EXPECT_EQ(1, observer.auth_supplied_count()); | 979 EXPECT_EQ(1, observer.auth_supplied_count()); |
| 980 EXPECT_EQ(0, observer.auth_cancelled_count()); | 980 EXPECT_EQ(0, observer.auth_cancelled_count()); |
| 981 EXPECT_EQ(1, observer_incognito.auth_needed_count()); | 981 EXPECT_EQ(1, observer_incognito.auth_needed_count()); |
| 982 EXPECT_EQ(0, observer_incognito.auth_supplied_count()); | 982 EXPECT_EQ(0, observer_incognito.auth_supplied_count()); |
| 983 EXPECT_EQ(0, observer_incognito.auth_cancelled_count()); | 983 EXPECT_EQ(0, observer_incognito.auth_cancelled_count()); |
| 984 } | 984 } |
| 985 | 985 |
| 986 // If an XMLHttpRequest is made with incorrect credentials, there should be no | |
| 987 // login prompt; instead the 401 status should be returned to the script. | |
| 988 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, | |
| 989 NoLoginPromptForXHRWithBadCredentials) { | |
| 990 const char kXHRTestPage[] = "/login/xhr_with_credentials.html#incorrect"; | |
|
Mike West
2017/03/27 11:58:50
Dropping both of these tests, as they rely on XHR
| |
| 991 | |
| 992 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 993 | |
| 994 content::WebContents* contents = | |
| 995 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 996 NavigationController* controller = &contents->GetController(); | |
| 997 LoginPromptBrowserTestObserver observer; | |
| 998 | |
| 999 observer.Register(content::Source<NavigationController>(controller)); | |
| 1000 | |
| 1001 // Load a page which makes a synchronous XMLHttpRequest for an authenticated | |
| 1002 // resource with the wrong credentials. There should be no login prompt. | |
| 1003 { | |
| 1004 GURL test_page = embedded_test_server()->GetURL(kXHRTestPage); | |
| 1005 WindowedLoadStopObserver load_stop_waiter(controller, 1); | |
| 1006 browser()->OpenURL(OpenURLParams(test_page, Referrer(), | |
| 1007 WindowOpenDisposition::CURRENT_TAB, | |
| 1008 ui::PAGE_TRANSITION_TYPED, false)); | |
| 1009 load_stop_waiter.Wait(); | |
| 1010 } | |
| 1011 | |
| 1012 base::string16 expected_title(base::UTF8ToUTF16("status=401")); | |
| 1013 | |
| 1014 EXPECT_EQ(expected_title, contents->GetTitle()); | |
| 1015 EXPECT_EQ(0, observer.auth_supplied_count()); | |
| 1016 EXPECT_EQ(0, observer.auth_needed_count()); | |
| 1017 EXPECT_EQ(0, observer.auth_cancelled_count()); | |
| 1018 } | |
| 1019 | |
| 1020 // If an XMLHttpRequest is made with correct credentials, there should be no | |
| 1021 // login prompt either. | |
| 1022 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, | |
| 1023 NoLoginPromptForXHRWithGoodCredentials) { | |
| 1024 const char kXHRTestPage[] = "/login/xhr_with_credentials.html#secret"; | |
| 1025 | |
| 1026 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1027 | |
| 1028 content::WebContents* contents = | |
| 1029 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1030 NavigationController* controller = &contents->GetController(); | |
| 1031 LoginPromptBrowserTestObserver observer; | |
| 1032 | |
| 1033 observer.Register(content::Source<NavigationController>(controller)); | |
| 1034 | |
| 1035 // Load a page which makes a synchronous XMLHttpRequest for an authenticated | |
| 1036 // resource with the wrong credentials. There should be no login prompt. | |
| 1037 { | |
| 1038 GURL test_page = embedded_test_server()->GetURL(kXHRTestPage); | |
| 1039 WindowedLoadStopObserver load_stop_waiter(controller, 1); | |
| 1040 browser()->OpenURL(OpenURLParams(test_page, Referrer(), | |
| 1041 WindowOpenDisposition::CURRENT_TAB, | |
| 1042 ui::PAGE_TRANSITION_TYPED, false)); | |
| 1043 load_stop_waiter.Wait(); | |
| 1044 } | |
| 1045 | |
| 1046 base::string16 expected_title(base::UTF8ToUTF16("status=200")); | |
| 1047 | |
| 1048 EXPECT_EQ(expected_title, contents->GetTitle()); | |
| 1049 EXPECT_EQ(0, observer.auth_supplied_count()); | |
| 1050 EXPECT_EQ(0, observer.auth_needed_count()); | |
| 1051 EXPECT_EQ(0, observer.auth_cancelled_count()); | |
| 1052 } | |
| 1053 | |
| 1054 // If an XMLHttpRequest is made without credentials, there should be a login | 986 // If an XMLHttpRequest is made without credentials, there should be a login |
| 1055 // prompt. | 987 // prompt. |
| 1056 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, | 988 IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, |
| 1057 LoginPromptForXHRWithoutCredentials) { | 989 LoginPromptForXHRWithoutCredentials) { |
| 1058 const char kXHRTestPage[] = "/login/xhr_without_credentials.html"; | 990 const char kXHRTestPage[] = "/login/xhr_without_credentials.html"; |
| 1059 | 991 |
| 1060 ASSERT_TRUE(embedded_test_server()->Start()); | 992 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1061 | 993 |
| 1062 content::WebContents* contents = | 994 content::WebContents* contents = |
| 1063 browser()->tab_strip_model()->GetActiveWebContents(); | 995 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1064 NavigationController* controller = &contents->GetController(); | 996 NavigationController* controller = &contents->GetController(); |
| 1065 LoginPromptBrowserTestObserver observer; | 997 LoginPromptBrowserTestObserver observer; |
| 1066 | 998 |
| 1067 observer.Register(content::Source<NavigationController>(controller)); | 999 observer.Register(content::Source<NavigationController>(controller)); |
| 1068 | 1000 |
| 1069 // Load a page which makes a synchronous XMLHttpRequest for an authenticated | 1001 // Load a page which makes a synchronous XMLHttpRequest for an authenticated |
| 1070 // resource with the wrong credentials. There should be no login prompt. | 1002 // resource without credentials. There should be a login prompt. |
| 1071 { | 1003 { |
| 1072 GURL test_page = embedded_test_server()->GetURL(kXHRTestPage); | 1004 GURL test_page = embedded_test_server()->GetURL(kXHRTestPage); |
| 1073 WindowedAuthNeededObserver auth_needed_waiter(controller); | 1005 WindowedAuthNeededObserver auth_needed_waiter(controller); |
| 1074 browser()->OpenURL(OpenURLParams(test_page, Referrer(), | 1006 browser()->OpenURL(OpenURLParams(test_page, Referrer(), |
| 1075 WindowOpenDisposition::CURRENT_TAB, | 1007 WindowOpenDisposition::CURRENT_TAB, |
| 1076 ui::PAGE_TRANSITION_TYPED, false)); | 1008 ui::PAGE_TRANSITION_TYPED, false)); |
| 1077 auth_needed_waiter.Wait(); | 1009 auth_needed_waiter.Wait(); |
| 1078 } | 1010 } |
| 1079 | 1011 |
| 1080 ASSERT_FALSE(observer.handlers().empty()); | 1012 ASSERT_FALSE(observer.handlers().empty()); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1497 // out. | 1429 // out. |
| 1498 EXPECT_TRUE( | 1430 EXPECT_TRUE( |
| 1499 WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame())); | 1431 WaitForRenderFrameReady(contents->GetInterstitialPage()->GetMainFrame())); |
| 1500 EXPECT_TRUE(contents->ShowingInterstitialPage()); | 1432 EXPECT_TRUE(contents->ShowingInterstitialPage()); |
| 1501 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, contents->GetInterstitialPage() | 1433 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, contents->GetInterstitialPage() |
| 1502 ->GetDelegateForTesting() | 1434 ->GetDelegateForTesting() |
| 1503 ->GetTypeForTesting()); | 1435 ->GetTypeForTesting()); |
| 1504 } | 1436 } |
| 1505 | 1437 |
| 1506 } // namespace | 1438 } // namespace |
| OLD | NEW |