#include "components/autofill/content/renderer/form_autofill_util.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/content/renderer/test_utils.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_data_validation.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/field_data_manager.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-shared.h"
#include "components/autofill/core/common/unique_ids.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/test/render_view_test.h"
#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.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_element.h"
#include "third_party/blink/public/web/web_element_collection.h"
#include "third_party/blink/public/web/web_form_control_element.h"
#include "third_party/blink/public/web/web_form_element.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_remote_frame.h"
#include "third_party/blink/public/web/web_select_element.h"
#include "third_party/blink/public/web/web_view.h"
namespace autofill::form_util {
namespace {
ButtonTitleType;
WebDocument;
WebElement;
WebElementCollection;
WebFormControlElement;
WebFormElement;
WebInputElement;
WebLocalFrame;
WebNode;
WebString;
WebVector;
_;
AllOf;
ElementsAre;
Field;
IsEmpty;
IsFalse;
IsTrue;
Optional;
Pair;
Pointwise;
Property;
Values;
struct AutofillFieldUtilCase { … };
const char* kPoorMansPlaceholderFullOverlap = …;
const char* kPoorMansPlaceholderPartialOverlap = …;
const char* kPoorMansPlaceholderNoOverlap = …;
const char* kPoorMansPlaceholderNoOverlap2 = …;
const char* kPoorMansPlaceholderPossiblyErrorMessage = …;
const char* kPoorMansPlaceholderNoHorizontalContainment = …;
void VerifyButtonTitleCache(const WebFormElement& form_target,
const ButtonTitleList& expected_button_titles,
const ButtonTitlesCache& actual_cache) { … }
bool HaveSameFormControlId(const WebFormControlElement& element,
const FormFieldData& field) { … }
class FormAutofillUtilsTest : public content::RenderViewTest { … };
TEST_F(FormAutofillUtilsTest, WebFormElementToFormData_IdAndNames) { … }
TEST_F(FormAutofillUtilsTest, ExtractFormDataMeasuresTotalTime) { … }
TEST_F(FormAutofillUtilsTest,
ExtractFormDataMeasuresDurationOfLabelExtraction) { … }
TEST_F(FormAutofillUtilsTest, TruncateLargeOptionValuesAndContents) { … }
TEST_F(FormAutofillUtilsTest, ExtractFormData_SelectOptionValueAndText) { … }
TEST_F(FormAutofillUtilsTest, FindChildTextTest) { … }
TEST_F(FormAutofillUtilsTest, FindChildTextSkipElementTest) { … }
TEST_F(FormAutofillUtilsTest, InferLabelForElementTest) { … }
TEST_F(FormAutofillUtilsTest, InferLabelSourceTest) { … }
TEST_F(FormAutofillUtilsTest, GetButtonTitles) { … }
TEST_F(FormAutofillUtilsTest, GetButtonTitles_TooLongTitle) { … }
TEST_F(FormAutofillUtilsTest, GetButtonTitles_NoCache) { … }
TEST_F(FormAutofillUtilsTest, GetButtonTitles_NoForm) { … }
TEST_F(FormAutofillUtilsTest, IsEnabled) { … }
TEST_F(FormAutofillUtilsTest, IsReadonly) { … }
TEST_F(FormAutofillUtilsTest, IsFocusable) { … }
TEST_F(FormAutofillUtilsTest, FindFormByUniqueId) { … }
struct FindFormControlTestParam { … };
class ParameterizedGetFormControlByRendererIdTest
: public FormAutofillUtilsTest,
public testing::WithParamInterface<FindFormControlTestParam> { … };
TEST_P(ParameterizedGetFormControlByRendererIdTest,
GetFormControlByRendererId) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(FormAutofillUtilsTest, GetAriaLabel) { … }
TEST_F(FormAutofillUtilsTest, GetAriaLabelledBySingle) { … }
TEST_F(FormAutofillUtilsTest, GetAriaLabelledByMulti) { … }
TEST_F(FormAutofillUtilsTest, GetAriaLabelledByTakesPrecedence) { … }
TEST_F(FormAutofillUtilsTest, GetAriaLabelledByInvalid) { … }
TEST_F(FormAutofillUtilsTest, GetAriaLabelledByFallback) { … }
TEST_F(FormAutofillUtilsTest, GetAriaDescribedBySingle) { … }
TEST_F(FormAutofillUtilsTest, GetAriaDescribedByMulti) { … }
TEST_F(FormAutofillUtilsTest, GetAriaDescribedByInvalid) { … }
TEST_F(FormAutofillUtilsTest, IsOwnedByFrame) { … }
TEST_F(FormAutofillUtilsTest, ExtractFormData_IsActionEmptyFalse) { … }
TEST_F(FormAutofillUtilsTest, ExtractFormData_IsActionEmptyTrue) { … }
TEST_F(FormAutofillUtilsTest,
FindFormAndFieldForFormControlElement_ExtractBounds) { … }
TEST_F(FormAutofillUtilsTest,
FindFormAndFieldForFormControlElement_NotExtractBounds) { … }
TEST_F(FormAutofillUtilsTest,
FindFormAndFieldForFormControlElement_ExtractUnownedBounds) { … }
TEST_F(FormAutofillUtilsTest,
FindFormAndFieldForFormControlElement_GetDataListSuggestions) { … }
TEST_F(FormAutofillUtilsTest,
FindFormAndFieldForFormControlElement_GetDataListSuggestionsWithLabels) { … }
TEST_F(FormAutofillUtilsTest,
FindFormAndFieldForFormControlElement_ExtractDataList) { … }
TEST_F(FormAutofillUtilsTest,
FindFormAndFieldForFormControlElement_NotExtractDataList) { … }
TEST_F(FormAutofillUtilsTest,
FindFormAndFieldForFormControlElement_Disconnected) { … }
TEST_F(FormAutofillUtilsTest, IsVisibleIframeTest) { … }
TEST_F(FormAutofillUtilsTest, IsWebElementVisibleTest) { … }
TEST_F(FormAutofillUtilsTest, GetClosestAncestorFormElement) { … }
TEST_F(FormAutofillUtilsTest, IsDomPredecessorTest) { … }
struct FieldOrFrame { … };
struct FieldFramesTestParam { … };
class FieldFramesTest
: public FormAutofillUtilsTest,
public testing::WithParamInterface<FieldFramesTestParam> { … };
TEST_F(FormAutofillUtilsTest, GetFormFieldElements_Unowned) { … }
TEST_P(FieldFramesTest, ExtractFormData_ExtractFieldsAndFrames) { … }
INSTANTIATE_TEST_SUITE_P(
FormAutofillUtilsTest,
FieldFramesTest,
testing::ValuesIn([] { … };
TEST_F(FormAutofillUtilsTest, ExtractFormData_WebFormElementToFormData) { … }
TEST_F(FormAutofillUtilsTest, ExtractFormData_ExtractNoFramesIfTooManyIframes) { … }
TEST_F(FormAutofillUtilsTest, ExtractNoFieldsOrFramesIfTooManyFields) { … }
TEST_F(FormAutofillUtilsTest, TraverseDomForFourDigitCombinations_NoMatches) { … }
TEST_F(FormAutofillUtilsTest,
TraverseDomForFourDigitCombinations_MatchesFound) { … }
TEST_F(FormAutofillUtilsTest,
TraverseDomForFourDigitCombinations_MatchesFoundWithDuplicates) { … }
TEST_F(FormAutofillUtilsTest,
TraverseDomForFourDigitCombinations_YearsRemoved) { … }
MATCHER(SameNode, "") { … }
void PrefixTraverseAndAppend(WebNode node, std::vector<WebNode>& out) { … }
TEST_F(FormAutofillUtilsTest, NextWebNode_Forward) { … }
TEST_F(FormAutofillUtilsTest, NextWebNode_Backward) { … }
TEST_F(FormAutofillUtilsTest, GetMaxLength) { … }
TEST_F(FormAutofillUtilsTest, ContentEditableWritingSuggestionsFalseInherited) { … }
TEST_F(FormAutofillUtilsTest, ContentEditableWritingSuggestionsFalse) { … }
TEST_F(FormAutofillUtilsTest, FindFormForContentEditableSuccess) { … }
TEST_F(FormAutofillUtilsTest, FindFormForContentEditableAbridgedSuccess) { … }
TEST_F(FormAutofillUtilsTest, FindFormForContentEditableFailures) { … }
TEST_F(FormAutofillUtilsTest, ExtractFormData_OwnedForm) { … }
TEST_F(FormAutofillUtilsTest, ExtractFormData_UnownedForm) { … }
TEST_F(FormAutofillUtilsTest, GetOwningFormInLightDom) { … }
TEST_F(FormAutofillUtilsTest, GetOwningFormInLightDomWithExplicitAssociation) { … }
TEST_F(FormAutofillUtilsTest, GetOwningFormInShadowDomWithoutFormInShadowDom) { … }
TEST_F(FormAutofillUtilsTest, GetOwningFormInShadowDomWithFormInShadowDom) { … }
TEST_F(FormAutofillUtilsTest,
GetOwningFormInShadowDomWithFormInShadowDomWithMultipleLevels) { … }
TEST_F(FormAutofillUtilsTest,
GetOwningFormInShadowDomWithFormInShadowDomAndExplicitAssociation) { … }
TEST_F(FormAutofillUtilsTest, GetOwningFormWithNestedFormsInLightDom) { … }
TEST_F(FormAutofillUtilsTest, GetOwnedFormControlsRequiresConnectedness) { … }
}
}