| Index: components/password_manager/core/browser/password_form_manager_unittest.cc
|
| diff --git a/components/password_manager/core/browser/password_form_manager_unittest.cc b/components/password_manager/core/browser/password_form_manager_unittest.cc
|
| index a3399cd47ae732545fd08d488ce8b4c21cd96661..b8a067db76ffd55a94c0c5e4c6f48b8262a35bbf 100644
|
| --- a/components/password_manager/core/browser/password_form_manager_unittest.cc
|
| +++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
|
| @@ -60,6 +60,13 @@ class TestPasswordManagerClient : public StubPasswordManagerClient {
|
| true);
|
| }
|
|
|
| + virtual bool ShouldFilterAutofillResult(
|
| + const autofill::PasswordForm& form) const OVERRIDE {
|
| + if (form == form_to_filter_)
|
| + return true;
|
| + return false;
|
| + }
|
| +
|
| virtual void PromptUserToSavePassword(
|
| scoped_ptr<PasswordFormManager> form_to_save) OVERRIDE {}
|
| virtual PrefService* GetPrefs() OVERRIDE { return &prefs_; }
|
| @@ -70,9 +77,15 @@ class TestPasswordManagerClient : public StubPasswordManagerClient {
|
| driver_.FillPasswordForm(*fill_data.get());
|
| }
|
|
|
| + void SetFormToFilter(const autofill::PasswordForm& form) {
|
| + form_to_filter_ = form;
|
| + }
|
| +
|
| MockPasswordManagerDriver* GetMockDriver() { return &driver_; }
|
|
|
| private:
|
| + autofill::PasswordForm form_to_filter_;
|
| +
|
| TestingPrefServiceSimple prefs_;
|
| PasswordStore* password_store_;
|
| MockPasswordManagerDriver driver_;
|
| @@ -176,8 +189,9 @@ class PasswordFormManagerTest : public testing::Test {
|
| p->SanitizePossibleUsernames(form);
|
| }
|
|
|
| - bool IgnoredResult(PasswordFormManager* p, PasswordForm* form) {
|
| - return p->IgnoreResult(*form);
|
| + bool IgnoredResult(PasswordFormManager* p, PasswordForm* form,
|
| + bool* autofill_filtered) {
|
| + return p->IgnoreResult(*form, autofill_filtered);
|
| }
|
|
|
| PasswordForm* observed_form() { return &observed_form_; }
|
| @@ -416,17 +430,25 @@ TEST_F(PasswordFormManagerTest, TestUpdatePasswordFromNewPasswordElement) {
|
|
|
| TEST_F(PasswordFormManagerTest, TestIgnoreResult) {
|
| PasswordFormManager manager(NULL, client(), NULL, *observed_form(), false);
|
| + bool autofill_filtered = false;
|
|
|
| // Make sure we don't match a PasswordForm if it was originally saved on
|
| // an SSL-valid page and we are now on a page with invalid certificate.
|
| saved_match()->ssl_valid = true;
|
| - EXPECT_TRUE(IgnoredResult(&manager, saved_match()));
|
| + EXPECT_TRUE(IgnoredResult(&manager, saved_match(), &autofill_filtered));
|
| + EXPECT_FALSE(autofill_filtered);
|
|
|
| saved_match()->ssl_valid = false;
|
| // Different paths for action / origin are okay.
|
| saved_match()->action = GURL("http://www.google.com/b/Login");
|
| saved_match()->origin = GURL("http://www.google.com/foo");
|
| - EXPECT_FALSE(IgnoredResult(&manager, saved_match()));
|
| + EXPECT_FALSE(IgnoredResult(&manager, saved_match(), &autofill_filtered));
|
| + EXPECT_FALSE(autofill_filtered);
|
| +
|
| + // Results should be ignored if the client requests it.
|
| + client()->SetFormToFilter(*saved_match());
|
| + EXPECT_TRUE(IgnoredResult(&manager, saved_match(), &autofill_filtered));
|
| + EXPECT_TRUE(autofill_filtered);
|
| }
|
|
|
| TEST_F(PasswordFormManagerTest, TestEmptyAction) {
|
|
|