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

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

Issue 2277793002: Filter duplicates in the account chooser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed one Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/password_manager/core/browser/credential_manager_pending_request_task.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f6c0ee62921fa38eac6cdd476179ee7da71e4b4f..c733a8b7e4b4058a9cab91787f9de9881b1c88d6 100644
--- a/components/password_manager/content/browser/credential_manager_impl_unittest.cc
+++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
@@ -40,6 +40,8 @@ using content::BrowserContext;
using content::WebContents;
using testing::_;
+using testing::Pointee;
+using testing::UnorderedElementsAre;
namespace password_manager {
@@ -97,7 +99,7 @@ class MockPasswordManagerClient : public StubPasswordManagerClient {
ScopedVector<autofill::PasswordForm> local_forms,
ScopedVector<autofill::PasswordForm> federated_forms,
const GURL& origin,
- const CredentialsCallback& callback) {
+ const CredentialsCallback& callback) override {
EXPECT_FALSE(local_forms.empty() && federated_forms.empty());
const autofill::PasswordForm* form =
local_forms.empty() ? federated_forms[0] : local_forms[0];
@@ -695,11 +697,14 @@ TEST_F(CredentialManagerImplTest,
}
TEST_F(CredentialManagerImplTest,
- CredentialManagerOnRequestCredentialWithEmptyAndNonUsernames) {
+ CredentialManagerOnRequestCredentialWithEmptyAndNonemptyUsernames) {
store_->AddLogin(form_);
autofill::PasswordForm empty = form_;
empty.username_value.clear();
store_->AddLogin(empty);
+ autofill::PasswordForm duplicate = form_;
+ duplicate.username_element = base::ASCIIToUTF16("different_username_element");
+ store_->AddLogin(duplicate);
std::vector<GURL> federations;
ExpectZeroClickSignInSuccess(false, true, federations,
@@ -707,6 +712,51 @@ TEST_F(CredentialManagerImplTest,
}
TEST_F(CredentialManagerImplTest,
+ CredentialManagerOnRequestCredentialWithDuplicates) {
+ // Add 7 credentials. Two buckets of duplicates and one empty username. There
+ // should be just two in the account chooser.
+ form_.preferred = true;
+ form_.username_element = base::ASCIIToUTF16("username_element");
+ store_->AddLogin(form_);
+ 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;
+ store_->AddLogin(duplicate);
+ duplicate = form_;
+ duplicate.username_element = base::ASCIIToUTF16("username_element2");
+ duplicate.preferred = false;
+ store_->AddLogin(duplicate);
+
+ origin_path_form_.preferred = true;
+ store_->AddLogin(origin_path_form_);
+ duplicate = origin_path_form_;
+ duplicate.username_element = base::ASCIIToUTF16("username_element3");
+ duplicate.is_public_suffix_match = true;
+ store_->AddLogin(duplicate);
+ duplicate = origin_path_form_;
+ duplicate.username_element = base::ASCIIToUTF16("username_element4");
+ duplicate.preferred = false;
+ store_->AddLogin(duplicate);
+
+ EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(
+ UnorderedElementsAre(Pointee(form_),
+ Pointee(origin_path_form_)),
+ testing::IsEmpty(), _, _));
+
+ bool called = false;
+ mojom::CredentialManagerError error;
+ base::Optional<CredentialInfo> credential;
+ std::vector<GURL> federations;
+ CallGet(false, true, federations,
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
+
+ RunAllPendingTasks();
+}
+
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) {
store_->AddLogin(cross_origin_form_);
« no previous file with comments | « no previous file | components/password_manager/core/browser/credential_manager_pending_request_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698