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

Unified Diff: components/password_manager/content/browser/credential_manager_impl_unittest.cc

Issue 2523593006: Show PSL-matched credentials in the account chooser. (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/content/browser/credential_manager_impl_unittest.cc
diff --git a/components/password_manager/content/browser/credential_manager_impl_unittest.cc b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
index e9337abff99c746f94348e47b38bf77d722948d2..ccf6bc92473ea0dabf01f80328c04796b83cb876 100644
--- a/components/password_manager/content/browser/credential_manager_impl_unittest.cc
+++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
@@ -227,7 +227,7 @@ class CredentialManagerImplTest : public content::RenderViewHostTestHarness {
form_.icon_url = GURL("https://example.com/icon.png");
form_.password_value = base::ASCIIToUTF16("Password");
form_.origin = web_contents()->GetLastCommittedURL().GetOrigin();
- form_.signon_realm = form_.origin.spec();
+ form_.signon_realm = form_.origin.GetOrigin().spec();
form_.scheme = autofill::PasswordForm::SCHEME_HTML;
form_.skip_zero_click = false;
@@ -251,7 +251,8 @@ class CredentialManagerImplTest : public content::RenderViewHostTestHarness {
origin_path_form_.display_name = base::ASCIIToUTF16("Display Name 2");
origin_path_form_.password_value = base::ASCIIToUTF16("Password 2");
origin_path_form_.origin = GURL("https://example.com/path");
- origin_path_form_.signon_realm = origin_path_form_.origin.spec();
+ origin_path_form_.signon_realm =
+ origin_path_form_.origin.GetOrigin().spec();
origin_path_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
origin_path_form_.skip_zero_click = false;
@@ -259,7 +260,7 @@ class CredentialManagerImplTest : public content::RenderViewHostTestHarness {
subdomain_form_.display_name = base::ASCIIToUTF16("Display Name 2");
subdomain_form_.password_value = base::ASCIIToUTF16("Password 2");
subdomain_form_.origin = GURL("https://subdomain.example.com/path");
- subdomain_form_.signon_realm = subdomain_form_.origin.spec();
+ subdomain_form_.signon_realm = subdomain_form_.origin.GetOrigin().spec();
subdomain_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
subdomain_form_.skip_zero_click = false;
@@ -267,7 +268,8 @@ class CredentialManagerImplTest : public content::RenderViewHostTestHarness {
cross_origin_form_.display_name = base::ASCIIToUTF16("Display Name");
cross_origin_form_.password_value = base::ASCIIToUTF16("Password");
cross_origin_form_.origin = GURL("https://example.net/");
- cross_origin_form_.signon_realm = cross_origin_form_.origin.spec();
+ cross_origin_form_.signon_realm =
+ cross_origin_form_.origin.GetOrigin().spec();
cross_origin_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
cross_origin_form_.skip_zero_click = false;
@@ -735,6 +737,17 @@ TEST_F(CredentialManagerImplTest,
}
TEST_F(CredentialManagerImplTest,
+ CredentialManagerOnRequestCredentialWithPSLCredential) {
+ subdomain_form_.skip_zero_click = false;
vabr (Chromium) 2016/11/23 18:49:11 Is the skip_zero_click bit being false a part of t
vasilii 2016/11/24 12:44:10 It's the second. The test should pass with any val
vabr (Chromium) 2016/11/24 13:58:14 Acknowledged.
+ store_->AddLogin(subdomain_form_);
+ EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _));
+ EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(0);
+
+ ExpectCredentialType(false, true, std::vector<GURL>(),
+ CredentialType::CREDENTIAL_TYPE_PASSWORD);
+}
+
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithEmptyAndNonemptyUsernames) {
store_->AddLogin(form_);
autofill::PasswordForm empty = form_;
@@ -743,6 +756,7 @@ TEST_F(CredentialManagerImplTest,
autofill::PasswordForm duplicate = form_;
duplicate.username_element = base::ASCIIToUTF16("different_username_element");
store_->AddLogin(duplicate);
+ store_->AddLogin(subdomain_form_);
std::vector<GURL> federations;
ExpectZeroClickSignInSuccess(false, true, federations,
@@ -759,9 +773,8 @@ TEST_F(CredentialManagerImplTest,
autofill::PasswordForm empty = form_;
empty.username_value.clear();
store_->AddLogin(empty);
- autofill::PasswordForm duplicate = form_;
- duplicate.username_element = base::ASCIIToUTF16("username_element1");
- duplicate.is_public_suffix_match = true;
+ autofill::PasswordForm duplicate = subdomain_form_;
+ duplicate.username_value = form_.username_value;
store_->AddLogin(duplicate);
duplicate = form_;
duplicate.username_element = base::ASCIIToUTF16("username_element2");
@@ -770,9 +783,9 @@ TEST_F(CredentialManagerImplTest,
origin_path_form_.preferred = true;
store_->AddLogin(origin_path_form_);
- duplicate = origin_path_form_;
+ duplicate = subdomain_form_;
duplicate.username_element = base::ASCIIToUTF16("username_element3");
- duplicate.is_public_suffix_match = true;
+ duplicate.username_value = subdomain_form_.username_value;
store_->AddLogin(duplicate);
duplicate = origin_path_form_;
duplicate.username_element = base::ASCIIToUTF16("username_element4");
@@ -848,16 +861,7 @@ TEST_F(
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(testing::Exactly(0));
- bool called = false;
- mojom::CredentialManagerError error;
- base::Optional<CredentialInfo> credential;
- CallGet(true, true, federations,
- base::Bind(&GetCredentialCallback, &called, &error, &credential));
-
- RunAllPendingTasks();
-
- EXPECT_TRUE(called);
- EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error);
+ ExpectZeroClickSignInFailure(true, true, federations);
}
TEST_F(CredentialManagerImplTest,

Powered by Google App Engine
This is Rietveld 408576698