#include "components/autofill/content/renderer/password_autofill_agent.h"
#include <vector>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/numerics/safe_conversions.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "build/build_config.h"
#include "chrome/renderer/autofill/fake_mojo_password_manager_driver.h"
#include "chrome/renderer/autofill/fake_password_generation_driver.h"
#include "chrome/renderer/autofill/password_generation_test_utils.h"
#include "chrome/test/base/chrome_render_view_test.h"
#include "components/autofill/content/renderer/autofill_agent.h"
#include "components/autofill/content/renderer/autofill_agent_test_api.h"
#include "components/autofill/content/renderer/form_autofill_util.h"
#include "components/autofill/content/renderer/form_tracker.h"
#include "components/autofill/content/renderer/password_generation_agent.h"
#include "components/autofill/content/renderer/test_password_autofill_agent.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom.h"
#include "components/autofill/core/common/password_form_fill_data.h"
#include "components/autofill/core/common/unique_ids.h"
#include "components/password_manager/core/common/password_manager_constants.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/safe_browsing/buildflags.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/test/browser_test_utils.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "testing/gtest/include/gtest/gtest-param-test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_form_element.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_input_element.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "ui/events/keycodes/keyboard_codes.h"
#if BUILDFLAG(IS_WIN)
#include "third_party/blink/public/web/win/web_font_rendering.h"
#endif
namespace autofill {
namespace {
FormRendererId;
FormTracker;
FocusedFieldType;
SubmissionIndicatorEvent;
ASCIIToUTF16;
UTF16ToUTF8;
WebAutofillState;
WebDocument;
WebElement;
WebFormElement;
WebFrame;
WebInputElement;
WebLocalFrame;
WebString;
_;
AllOf;
AtMost;
Eq;
Field;
Truly;
const char kUsernameName[] = …;
const char kPasswordName[] = …;
const char kSearchField[] = …;
const char kSocialMediaTextArea[] = …;
const char kAliceUsername[] = …;
const char16_t kAliceUsername16[] = …;
const char kAlicePassword[] = …;
const char16_t kAlicePassword16[] = …;
const char kBobUsername[] = …;
const char16_t kBobUsername16[] = …;
const char kBobPassword[] = …;
const char16_t kBobPassword16[] = …;
const char16_t kCarolUsername16[] = …;
const char kCarolPassword[] = …;
const char16_t kCarolPassword16[] = …;
const char16_t kCarolAlternateUsername16[] = …;
const char kFormHTML[] = …;
#if BUILDFLAG(IS_ANDROID)
const char kFormWithUsernameFieldWebauthnHTML[] =
"<FORM id='LoginTestForm' action='http://www.example.com'>"
" <INPUT type='text' id='username' autocomplete='webauthn'/>"
" <INPUT type='password' id='password'/>"
" <INPUT type='submit' value='Login'/>"
"</FORM>";
const char kFormWithPasswordFieldWebauthnHTML[] =
"<FORM id='LoginTestForm' action='http://www.example.com'>"
" <INPUT type='text' id='username'/>"
" <INPUT type='password' id='password' autocomplete='webauthn'/>"
" <INPUT type='submit' value='Login'/>"
"</FORM>";
#endif
const char kSocialNetworkPostFormHTML[] = …;
const char kSearchFieldHTML[] = …;
const char kWebAutnFieldHTML[] = …;
const char kVisibleFormWithNoUsernameHTML[] = …;
const char kSingleUsernameFormHTML[] = …;
const char kSingleTextInputFormHTML[] = …;
const char kEmptyFormHTML[] = …;
const char kFormWithoutPasswordsHTML[] = …;
const char kNonVisibleFormHTML[] = …;
const char kNonDisplayedFormHTML[] = …;
const char kSignupFormHTML[] = …;
const char kEmptyWebpage[] = …;
const char kRedirectionWebpage[] = …;
const char kSimpleWebpage[] = …;
const char kWebpageWithDynamicContent[] = …;
const char kJavaScriptClick[] = …;
const char kPasswordChangeFormHTML[] = …;
const char kCreditCardFormHTML[] = …;
const char kNoFormHTML[] = …;
const char kTwoNoUsernameFormsHTML[] = …;
const char kDivWrappedFormHTML[] = …;
const char kJavaScriptRemoveForm[] = …;
const char kFormTagHostsShadowDomInputs[] = …;
constexpr std::string_view kUnownedFieldsWithPasswordDisabled = …;
void SetElementReadOnly(WebInputElement& element, bool read_only) { … }
bool FormHasFieldWithValue(const autofill::FormData& form,
const std::u16string& value) { … }
enum PasswordFormSourceType { … };
enum class FieldChangeSource { … };
auto NumShowSuggestionsCalls() { … }
class PasswordAutofillAgentTest : public ChromeRenderViewTest { … };
TEST_F(PasswordAutofillAgentTest, InitialAutocomplete) { … }
TEST_F(PasswordAutofillAgentTest, InitialAutocompleteForEmptyAction) { … }
TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForReadOnlyPassword) { … }
TEST_F(PasswordAutofillAgentTest,
AutocompletePasswordForReadonlyUsernameMatched) { … }
TEST_F(PasswordAutofillAgentTest, AutocompleteForPrefilledUsernameValue) { … }
TEST_F(PasswordAutofillAgentTest, MetricsOnlyLoggedOnce) { … }
TEST_F(PasswordAutofillAgentTest,
AutocompletePasswordForReadonlyUsernamePrefixMatched) { … }
TEST_F(PasswordAutofillAgentTest, NoFillingOnSignupForm_NoMetrics) { … }
TEST_F(PasswordAutofillAgentTest,
DontAutocompletePasswordForReadonlyUsernamePrefixMatched) { … }
TEST_F(
PasswordAutofillAgentTest,
DontAutocompletePasswordForNotReadonlyUsernameFieldEvenWhenPrefixMatched) { … }
TEST_F(PasswordAutofillAgentTest,
NoAutocompletePasswordForReadonlyUsernameUnmatched) { … }
TEST_F(PasswordAutofillAgentTest, NoAutocompleteForFilledFieldUnmatched) { … }
TEST_F(PasswordAutofillAgentTest, NoPartialMatchForPrefilledUsername) { … }
TEST_F(PasswordAutofillAgentTest, InitialAutocompleteForMatchingFilledField) { … }
TEST_F(PasswordAutofillAgentTest, PasswordNotClearedOnEdit) { … }
TEST_F(PasswordAutofillAgentTest, WaitUsername) { … }
TEST_F(PasswordAutofillAgentTest, IsWebElementVisibleTest) { … }
TEST_F(PasswordAutofillAgentTest,
SendPasswordFormsTest_VisibleFormWithNoUsername) { … }
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_EmptyForm) { … }
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_FormWithoutPasswords) { … }
TEST_F(PasswordAutofillAgentTest,
SendPasswordFormsTest_UndetectedPasswordField) { … }
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_NonDisplayedForm) { … }
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_NonVisibleForm) { … }
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_PasswordChangeForm) { … }
TEST_F(PasswordAutofillAgentTest,
SendPasswordFormsTest_CannotCreatePasswordForm) { … }
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_ReloadTab) { … }
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_Redirection) { … }
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_UnownedtextInputs) { … }
TEST_F(PasswordAutofillAgentTest, GestureRequiredTest) { … }
TEST_F(PasswordAutofillAgentTest, NoDOMActivationTest) { … }
TEST_F(PasswordAutofillAgentTest,
PasswordAutofillTriggersOnChangeEventsOnLoad) { … }
TEST_F(PasswordAutofillAgentTest,
PasswordAutofillTriggersOnChangeEventsWaitForUsername) { … }
TEST_F(PasswordAutofillAgentTest, FillSuggestionOnUsernameField) { … }
TEST_F(PasswordAutofillAgentTest,
NoFillSuggestionOnNoFormTagAndPasswordDisabled) { … }
TEST_F(PasswordAutofillAgentTest, FillSuggestionOnPasswordField) { … }
TEST_F(PasswordAutofillAgentTest, FillSuggestionWithDynamicUsernameField) { … }
TEST_F(PasswordAutofillAgentTest,
FillSuggestionFromPasswordFieldWithUsernameManuallyFilled) { … }
TEST_F(PasswordAutofillAgentTest, PreviewSuggestionOnUsernameField) { … }
TEST_F(PasswordAutofillAgentTest, PreviewSuggestionOnPasswordField) { … }
TEST_F(PasswordAutofillAgentTest,
PreviewSuggestionFromPasswordFieldWithUsernameManuallyFilled) { … }
TEST_F(PasswordAutofillAgentTest, PreviewSuggestionSelectionRange) { … }
TEST_F(PasswordAutofillAgentTest, ClearPreviewWithPasswordAutofilled) { … }
TEST_F(PasswordAutofillAgentTest, ClearPreviewWithUsernameAutofilled) { … }
TEST_F(PasswordAutofillAgentTest, PreviewField) { … }
TEST_F(PasswordAutofillAgentTest, PreviewField_ClearPreviewedForm) { … }
TEST_F(PasswordAutofillAgentTest,
ClearPreviewWithAutofilledUsernameAndPassword) { … }
TEST_F(PasswordAutofillAgentTest, ClearPreviewBeforeFillingSuggestion) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(PasswordAutofillAgentTest, TryToShowKeyboardReplacingSurfaceUsername) {
WebInputElement random_element = GetInputElementByID("random_field");
EXPECT_FALSE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
username_element_));
EXPECT_FALSE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_FALSE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
random_element));
EXPECT_FALSE(password_autofill_agent_->ShouldSuppressKeyboard());
fill_data_.wait_for_username = true;
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
username_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_EQ(WebAutofillState::kNotFilled, username_element_.GetAutofillState());
EXPECT_EQ(WebAutofillState::kNotFilled, password_element_.GetAutofillState());
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kEmptyFields,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, TryToShowKeyboardReplacingSurfacePassword) {
fill_data_.wait_for_username = true;
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_EQ(WebAutofillState::kNotFilled, password_element_.GetAutofillState());
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kEmptyFields,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest,
TryToShowKeyboardReplacingSurfaceWithWebauthnField) {
LoadHTML(kFormWithUsernameFieldWebauthnHTML);
UpdateUrlForHTML(kFormWithUsernameFieldWebauthnHTML);
UpdateUsernameAndPasswordElements();
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(_, true));
base::RunLoop().RunUntilIdle();
LoadHTML(kFormWithPasswordFieldWebauthnHTML);
UpdateUrlForHTML(kFormWithPasswordFieldWebauthnHTML);
UpdateUsernameAndPasswordElements();
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(_, true));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest,
TryToShowKeyboardReplacingSurfaceButDontEnableSubmission) {
LoadHTML(kPasswordChangeFormHTML);
UpdateUrlForHTML(kPasswordChangeFormHTML);
UpdateUsernameAndPasswordElements();
fill_data_.wait_for_username = true;
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_EQ(WebAutofillState::kNotFilled, password_element_.GetAutofillState());
EXPECT_CALL(
fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kFieldAfterPasswordField,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, KeyboardReplacingSurfaceSuppressesPopups) {
SimulateOnFillPasswordForm(fill_data_);
SimulateSuggestionChoice(username_element_);
EXPECT_CALL(fake_driver_, ShowKeyboardReplacingSurface);
CheckSuggestionsNotShown();
}
TEST_F(PasswordAutofillAgentTest, KeyboardReplacingSurfaceClosed) {
fill_data_.wait_for_username = true;
SimulateOnFillPasswordForm(fill_data_);
SimulateElementClick(password_element_);
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_EQ(WebAutofillState::kNotFilled, password_element_.GetAutofillState());
EXPECT_CALL(fake_driver_, ShowKeyboardReplacingSurface);
base::RunLoop().RunUntilIdle();
password_autofill_agent_->KeyboardReplacingSurfaceClosed(true);
EXPECT_FALSE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_FALSE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_EQ(WebAutofillState::kNotFilled, password_element_.GetAutofillState());
LoadHTML(kFormHTML);
UpdateUrlForHTML(kFormHTML);
UpdateUsernameAndPasswordElements();
SimulateOnFillPasswordForm(fill_data_);
SimulateElementClick(password_element_);
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_EQ(WebAutofillState::kNotFilled, password_element_.GetAutofillState());
EXPECT_CALL(fake_driver_, ShowKeyboardReplacingSurface);
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, SubmissionReadiness_NoUsernameField) {
LoadHTML(kVisibleFormWithNoUsernameHTML);
UpdateUrlForHTML(kVisibleFormWithNoUsernameHTML);
UpdateOnlyPasswordElement();
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kNoUsernameField,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, SubmissionReadiness_FieldsInBetween) {
WebDocument document = GetMainFrame()->GetDocument();
WebElement element =
document.GetElementById(WebString::FromUTF16(u"random_field"));
ASSERT_TRUE(element);
username_element_ = element.To<WebInputElement>();
UpdateRendererIDsInFillData();
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_CALL(fake_driver_, ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::
kFieldBetweenUsernameAndPassword,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, SubmissionReadiness_FieldAfterPassword) {
LoadHTML(kPasswordChangeFormHTML);
UpdateUrlForHTML(kPasswordChangeFormHTML);
UpdateUsernameAndPasswordElements();
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_CALL(
fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kFieldAfterPasswordField,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, SubmissionReadiness_EmptyFields) {
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kEmptyFields,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, SubmissionReadiness_MoreThanTwoFields) {
SimulateOnFillPasswordForm(fill_data_);
WebInputElement surname_element = GetInputElementByID("random_field");
ASSERT_TRUE(surname_element);
SimulateUserInputChangeForElement(&surname_element, "Smith");
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kMoreThanTwoFields,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, SubmissionReadiness_TwoFields) {
LoadHTML(kSimpleWebpage);
UpdateUrlForHTML(kSimpleWebpage);
UpdateUsernameAndPasswordElements();
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kTwoFields,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, SubmissionReadiness_NoPasswordField) {
LoadHTML(kSingleUsernameFormHTML);
UpdateUrlForHTML(kSingleUsernameFormHTML);
UpdateOnlyUsernameElement();
SimulateOnFillPasswordForm(fill_data_);
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
username_element_));
EXPECT_CALL(fake_driver_,
ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState::kNoPasswordField,
false));
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest,
DontTryToShowKeyboardReplacingSurfaceOnReadonlyForm) {
SetElementReadOnly(username_element_, true);
SetElementReadOnly(password_element_, true);
SimulateOnFillPasswordForm(fill_data_);
EXPECT_FALSE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
username_element_));
EXPECT_FALSE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
}
class PasswordAutofillAgentTestReadonlyElementVariationTest
: public PasswordAutofillAgentTest,
public testing::WithParamInterface<bool> {};
TEST_P(PasswordAutofillAgentTestReadonlyElementVariationTest,
DontTryToShowKeyboardReplacingSurfaceOnReadonlyElement) {
bool is_password_readonly = GetParam();
WebInputElement readonly_element =
is_password_readonly ? password_element_ : username_element_;
WebInputElement editable_element =
is_password_readonly ? username_element_ : password_element_;
SetElementReadOnly(readonly_element, true);
SetElementReadOnly(editable_element, false);
base::RunLoop().RunUntilIdle();
SimulateOnFillPasswordForm(fill_data_);
EXPECT_FALSE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
readonly_element));
EXPECT_TRUE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
editable_element));
}
INSTANTIATE_TEST_SUITE_P(ReadonlyElementVariation,
PasswordAutofillAgentTestReadonlyElementVariationTest,
testing::Bool());
TEST_F(PasswordAutofillAgentTest,
DontTryToShowKeyboardReplacingSurfaceSignUpForm) {
LoadHTML(kSignupFormHTML);
WebDocument document = GetMainFrame()->GetDocument();
WebElement element =
document.GetElementById(WebString::FromUTF8("random_info"));
ASSERT_TRUE(element);
username_element_ = element.To<WebInputElement>();
fill_data_.username_element_renderer_id = autofill::FieldRendererId();
fill_data_.password_element_renderer_id = autofill::FieldRendererId();
WebFormElement form_element =
document.GetElementById("LoginTestForm").To<WebFormElement>();
fill_data_.form_renderer_id = form_util::GetFormRendererId(form_element);
SimulateOnFillPasswordForm(fill_data_);
EXPECT_FALSE(password_autofill_agent_->TryToShowKeyboardReplacingSurface(
password_element_));
}
#endif
TEST_F(PasswordAutofillAgentTest, FillIntoFocusedReadonlyTextField) { … }
TEST_F(PasswordAutofillAgentTest, FillIntoFocusedWritableTextField) { … }
TEST_F(PasswordAutofillAgentTest, FillIntoFocusedFieldOnlyIntoPasswordFields) { … }
TEST_F(PasswordAutofillAgentTest, FillIntoFocusedFieldForNonClickFocus) { … }
TEST_F(PasswordAutofillAgentTest, FillIntoReadonlyTextField) { … }
TEST_F(PasswordAutofillAgentTest, FillIntoUsernameField) { … }
TEST_F(PasswordAutofillAgentTest, FillIntoPasswordField) { … }
TEST_F(PasswordAutofillAgentTest, FillIntoRandomField) { … }
TEST_F(PasswordAutofillAgentTest, FillIntoNonExistingField) { … }
TEST_F(PasswordAutofillAgentTest,
ClearPreviewWithNotAutofilledUsernameAndPassword) { … }
TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState_NoMessage) { … }
TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState_Activated) { … }
TEST_F(PasswordAutofillAgentTest, OnChangeLoggingState_Deactivated) { … }
TEST_F(PasswordAutofillAgentTest, ClickAndSelect) { … }
TEST_F(PasswordAutofillAgentTest, SuggestionsPrefixMatchedByTypedUsername) { … }
TEST_F(PasswordAutofillAgentTest,
SuggestionsNotPrefixMatchedWhenFeatureEnabled) { … }
TEST_F(PasswordAutofillAgentTest,
NoPopupOnPasswordFieldWhereAddressOrPaymentsManualFallbackWasSelected) { … }
TEST_F(PasswordAutofillAgentTest,
NoPopupOnPasswordFieldWithoutSuggestionsByDefault) { … }
TEST_F(PasswordAutofillAgentTest, ShowPopupOnPasswordFieldWithoutSuggestions) { … }
TEST_F(PasswordAutofillAgentTest, NoPopupOnPasswordFieldWithoutSuggestions) { … }
TEST_F(PasswordAutofillAgentTest, CredentialsOnClick) { … }
TEST_F(PasswordAutofillAgentTest, NoCredentialsOnPasswordClick) { … }
TEST_F(PasswordAutofillAgentTest,
RememberLastNonEmptyUsernameAndPasswordOnSubmit_ScriptCleared) { … }
TEST_F(PasswordAutofillAgentTest,
RememberLastNonEmptyUsernameAndPasswordOnSubmit_UserCleared) { … }
TEST_F(PasswordAutofillAgentTest,
RememberLastNonEmptyUsernameAndPasswordOnSubmit_New) { … }
TEST_F(PasswordAutofillAgentTest, RememberLastNonEmptySingleUsername) { … }
TEST_F(PasswordAutofillAgentTest,
NoopEditingDoesNotOverwriteManuallyEditedPassword) { … }
TEST_F(PasswordAutofillAgentTest, AcceptingSuggestionDoesntRewriteUsername) { … }
TEST_F(PasswordAutofillAgentTest,
RememberLastTypedUsernameAndPasswordOnSubmit_ScriptChanged) { … }
TEST_F(PasswordAutofillAgentTest, RememberFieldPropertiesOnSubmit) { … }
TEST_F(PasswordAutofillAgentTest, FixEmptyFieldPropertiesOnSubmit) { … }
TEST_F(PasswordAutofillAgentTest,
RememberFieldPropertiesOnSameDocumentNavigation) { … }
TEST_F(PasswordAutofillAgentTest,
RememberFieldPropertiesOnSameDocumentNavigation_2) { … }
TEST_F(PasswordAutofillAgentTest,
RememberLastAutofilledUsernameAndPasswordOnSubmit_ScriptChanged) { … }
TEST_F(
PasswordAutofillAgentTest,
RememberLastTypedAfterAutofilledUsernameAndPasswordOnSubmit_ScriptChanged) { … }
TEST_F(PasswordAutofillAgentTest, RememberAutofilledUsername) { … }
TEST_F(PasswordAutofillAgentTest,
RememberUsernameGeneratedBasingOnTypedFields) { … }
TEST_F(PasswordAutofillAgentTest, DontFillFormWithNoUsername) { … }
TEST_F(PasswordAutofillAgentTest, ShowPopupOnEmptyPasswordField) { … }
TEST_F(PasswordAutofillAgentTest, ShowPopupOnAutofilledPasswordField) { … }
TEST_F(PasswordAutofillAgentTest, NotShowPopupPasswordField) { … }
TEST_F(PasswordAutofillAgentTest,
FillOnAccountSelectOnlyReadonlyUnknownUsername) { … }
TEST_F(PasswordAutofillAgentTest, ReadonlyPasswordFieldOnSubmit) { … }
TEST_F(PasswordAutofillAgentTest, PasswordGenerationTriggered_TypedPassword) { … }
TEST_F(PasswordAutofillAgentTest,
PasswordGenerationTriggered_GeneratedPassword) { … }
TEST_F(PasswordAutofillAgentTest,
ResetPasswordGenerationWhenFieldIsAutofilled) { … }
TEST_F(PasswordAutofillAgentTest, PasswordGenerationSupersedesAutofill) { … }
TEST_F(PasswordAutofillAgentTest, CanShowSuggestionsAfterManualGeneration) { … }
TEST_F(PasswordAutofillAgentTest, FillSuggestionPasswordChangeForms) { … }
TEST_F(PasswordAutofillAgentTest,
SuggestionsOnUsernameFieldOfChangePasswordForm) { … }
TEST_F(PasswordAutofillAgentTest,
SuggestionsOnPasswordFieldOfChangePasswordForm) { … }
TEST_F(PasswordAutofillAgentTest, NotAutofillNoUsername) { … }
TEST_F(PasswordAutofillAgentTest,
AutofillNoUsernameWhenOtherCredentialsStored) { … }
TEST_F(PasswordAutofillAgentTest, NoForm_PromptForAJAXSubmitWithoutNavigation) { … }
TEST_F(PasswordAutofillAgentTest,
NoForm_PromptForAJAXSubmitWithoutNavigation_2) { … }
TEST_F(PasswordAutofillAgentTest, PromptForAJAXSubmitAfterHidingParentElement) { … }
TEST_F(PasswordAutofillAgentTest,
PromptForAJAXSubmitAfterDeletingParentElement) { … }
TEST_F(PasswordAutofillAgentTest,
NoForm_NoPromptForAJAXSubmitWithoutNavigationAndElementsVisible) { … }
TEST_F(PasswordAutofillAgentTest,
NoForm_NoPromptForAJAXSubmitWithoutNavigationAndNewElementAppeared) { … }
TEST_F(PasswordAutofillAgentTest,
NoForm_NoPromptForAJAXSubmitWithoutNavigationAndNewElementAppeared_2) { … }
TEST_F(PasswordAutofillAgentTest,
NoAction_NoPromptForAJAXSubmitWithoutNavigationAndNewElementAppeared) { … }
TEST_F(PasswordAutofillAgentTest,
NoAction_NoPromptForAJAXSubmitWithoutNavigationAndNewElementAppeared_2) { … }
TEST_F(PasswordAutofillAgentTest, DriverIsInformedAboutUnfillableField) { … }
TEST_F(PasswordAutofillAgentTest, DriverIsInformedAboutFillableFields) { … }
TEST_F(PasswordAutofillAgentTest, DriverIsInformedAboutFillableSearchField) { … }
TEST_F(PasswordAutofillAgentTest,
DriverInformedAboutWebAuthnIfNotPasswordOrUsername) { … }
TEST_F(PasswordAutofillAgentTest, DriverIsInformedAboutFillableTextArea) { … }
TEST_F(PasswordAutofillAgentTest,
SuggestionsOnFormContainingAmbiguousOrEmptyNames) { … }
TEST_F(PasswordAutofillAgentTest, RememberChosenUsernamePassword) { … }
TEST_F(PasswordAutofillAgentTest, ShowSuggestionForNonUsernameFieldForms) { … }
TEST_F(PasswordAutofillAgentTest,
UsernameChangedAfterPasswordInput_AJAXSucceeded) { … }
TEST_F(PasswordAutofillAgentTest,
UsernameChangedAfterPasswordInput_AJAXSucceeded_2) { … }
TEST_F(PasswordAutofillAgentTest,
UsernameChangedAfterPasswordInput_FormSubmitted) { … }
TEST_F(PasswordAutofillAgentTest, SuggestPasswordFieldSignInForm) { … }
#if !BUILDFLAG(IS_ANDROID)
TEST_F(PasswordAutofillAgentTest, SuggestMultiplePasswordFields) { … }
#endif
TEST_F(PasswordAutofillAgentTest, ShowAutofillSignaturesFlag) { … }
TEST_F(PasswordAutofillAgentTest,
SameDocumentNavigationSubmissionUsernameIsEmpty) { … }
#if BUILDFLAG(SAFE_BROWSING_DB_LOCAL)
TEST_F(PasswordAutofillAgentTest,
CheckSafeBrowsingReputationWhenUserStartsFillingUsernamePassword) { … }
#endif
TEST_F(PasswordAutofillAgentTest, AutocompleteWhenPageUrlIsChanged) { … }
TEST_F(PasswordAutofillAgentTest, NoForm_MultipleAJAXEventsWithoutSubmission) { … }
TEST_F(PasswordAutofillAgentTest, ManualFallbackForSaving) { … }
TEST_F(PasswordAutofillAgentTest, ManualFallbackForSaving_PasswordChangeForm) { … }
TEST_F(PasswordAutofillAgentTest, GaiaReauthenticationFormIgnored) { … }
TEST_F(PasswordAutofillAgentTest,
UpdateSuggestionsIfNewerCredentialsAreSupplied) { … }
TEST_F(PasswordAutofillAgentTest, SuggestLatestCredentials) { … }
TEST_F(PasswordAutofillAgentTest, PSLMatchedPasswordIsNotAutofill) { … }
TEST_F(PasswordAutofillAgentTest, FillOnLoadWith) { … }
TEST_F(PasswordAutofillAgentTest, FillOnLoadNoForm) { … }
TEST_F(PasswordAutofillAgentTest, FillOnLoadNoUsername) { … }
TEST_F(PasswordAutofillAgentTest, MayUsePlaceholderNoPlaceholder) { … }
TEST_F(PasswordAutofillAgentTest,
MayUsePlaceholderAndPlaceholderOnFormDisabled) { … }
TEST_F(PasswordAutofillAgentTest,
MayUsePlaceholderAndPlaceholderOnFormEnabled) { … }
TEST_F(PasswordAutofillAgentTest, NoMayUsePlaceholderAndPlaceholderOnForm) { … }
TEST_F(PasswordAutofillAgentTest, AutofillsAfterUserGesture) { … }
TEST_F(PasswordAutofillAgentTest, RestoresAfterJavaScriptModification) { … }
TEST_F(PasswordAutofillAgentTest, DoNotRestoreWhenFormStructureWasChanged) { … }
TEST_F(PasswordAutofillAgentTest, FillOnLoadSingleUsername) { … }
TEST_F(PasswordAutofillAgentTest, SingleUsernamePreviewSuggestion) { … }
TEST_F(PasswordAutofillAgentTest, SingleUsernameFillSuggestion) { … }
TEST_F(PasswordAutofillAgentTest, SingleUsernameClearPreview) { … }
TEST_F(PasswordAutofillAgentTest, NoUsernameCredential) { … }
TEST_F(PasswordAutofillAgentTest, NoRefillOfUserInput) { … }
TEST_F(PasswordAutofillAgentTest, XhrSubmissionAfterFillingSuggestion) { … }
TEST_F(PasswordAutofillAgentTest, NoXhrSubmissionAfterFillingOnPageload) { … }
TEST_F(PasswordAutofillAgentTest, ModifyNonPasswordField) { … }
TEST_F(PasswordAutofillAgentTest, ModifyNonPasswordFieldOneSymbol) { … }
TEST_F(PasswordAutofillAgentTest, ModifyNonPasswordFieldTooManySymbols) { … }
TEST_F(PasswordAutofillAgentTest, ModifyNonPasswordFieldOTPAutocomplete) { … }
TEST_F(PasswordAutofillAgentTest, ModifyNonPasswordFieldOTPName) { … }
TEST_F(PasswordAutofillAgentTest, ModifyNonPasswordFieldShortName) { … }
TEST_F(PasswordAutofillAgentTest, ModifySearchField) { … }
TEST_F(PasswordAutofillAgentTest,
ProvisionalPasswordSavingWhenFormTagHostsShadowDom) { … }
TEST_F(PasswordAutofillAgentTest,
PasswordSuggestionFillingWhenFormTagHostsShadowDom) { … }
TEST_F(PasswordAutofillAgentTest, PasswordGenerationWhenFormTagHostsShadowDom) { … }
TEST_F(PasswordAutofillAgentTest, JSFieldModificationPasswordForm) { … }
TEST_F(PasswordAutofillAgentTest, JSFieldModificationUnrelatedField) { … }
TEST_F(PasswordAutofillAgentTest, TimesReceivedFillDataForFormMetric) { … }
TEST_F(PasswordAutofillAgentTest,
ShowSuggestionsOnParsingAutofocusedPasswordForm) { … }
TEST_F(PasswordAutofillAgentTest,
ShowSuggestionsOnParsingAutofocusedWebAuthnForm) { … }
TEST_F(PasswordAutofillAgentTest,
DoNotShowSuggestionsOnParsingFocusedFormSecondTime) { … }
TEST_F(PasswordAutofillAgentTest,
DoNotShowSuggestionsOnParsingFormWithoutFocus) { … }
TEST_F(PasswordAutofillAgentTest, InformingBrowserAboutUsernameTextFields) { … }
TEST_F(PasswordAutofillAgentTest, InformingBrowserAboutIrrelevantTextFields) { … }
TEST_F(PasswordAutofillAgentTest, NoFillingFallbackForBannedFields) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(PasswordAutofillAgentTest, TriggerFormSubmission_HiddenPasswordField) {
const char kUsernameFirstFormHTML[] =
"<script>"
" function on_keypress(event) {"
" if (event.which === 13) {"
" var field = document.getElementById('password');"
" field.parentElement.removeChild(field);"
" }"
" }"
"</script>"
"<INPUT type='text' id='username' onkeypress='on_keypress(event)'/>"
"<INPUT type='password' id='password' style='display:none'/>";
LoadHTML(kUsernameFirstFormHTML);
base::RunLoop().RunUntilIdle();
UpdateUsernameAndPasswordElements();
fill_data_.wait_for_username = true;
SimulateOnFillPasswordForm(fill_data_);
SimulateElementClick(username_element_);
password_autofill_agent_->FillPasswordSuggestion(kAliceUsername16,
kAlicePassword16);
base::RunLoop().RunUntilIdle();
password_autofill_agent_->TriggerFormSubmission();
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(fake_driver_.called_dynamic_form_submission());
}
class PasswordAutofillAgentFormPresenceVariationTest
: public PasswordAutofillAgentTest,
public testing::WithParamInterface<bool> {};
TEST_P(PasswordAutofillAgentFormPresenceVariationTest, TriggerFormSubmission) {
bool has_form_tag = GetParam();
LoadHTML(has_form_tag ? kFormHTML : kNoFormHTML);
base::RunLoop().RunUntilIdle();
UpdateUsernameAndPasswordElements();
fill_data_.wait_for_username = true;
SimulateOnFillPasswordForm(fill_data_);
SimulateElementClick(username_element_);
password_autofill_agent_->FillPasswordSuggestion(kAliceUsername16,
kAlicePassword16);
base::RunLoop().RunUntilIdle();
password_autofill_agent_->TriggerFormSubmission();
base::RunLoop().RunUntilIdle();
if (has_form_tag)
EXPECT_TRUE(fake_driver_.called_password_form_submitted());
else
EXPECT_TRUE(fake_driver_.called_dynamic_form_submission());
fake_driver_.reset_password_forms_calls();
}
INSTANTIATE_TEST_SUITE_P(FormPresenceVariation,
PasswordAutofillAgentFormPresenceVariationTest,
testing::Bool());
#endif
}
}