#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <stddef.h>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/feature_list.h"
#include "base/format_macros.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/test/base/chrome_render_view_test.h"
#include "components/autofill/content/renderer/autofill_agent_test_api.h"
#include "components/autofill/content/renderer/autofill_renderer_test.h"
#include "components/autofill/content/renderer/form_autofill_util.h"
#include "components/autofill/content/renderer/form_cache.h"
#include "components/autofill/content/renderer/test_utils.h"
#include "components/autofill/core/common/autocomplete_parsing_util.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_data_test_api.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 "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_autofill_state.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_script_source.h"
#include "third_party/blink/public/web/web_select_element.h"
#include "third_party/blink/public/web/web_select_list_element.h"
#if BUILDFLAG(IS_WIN)
#include "third_party/blink/public/web/win/web_font_rendering.h"
#endif
ASCIIToUTF16;
WebAutofillState;
WebDocument;
WebElement;
WebFormControlElement;
WebFormElement;
WebInputElement;
WebLocalFrame;
WebSelectElement;
WebString;
WebVector;
_;
ElementsAre;
Field;
Optional;
Pair;
Property;
namespace autofill::form_util {
namespace {
struct AutofillFieldCase { … };
struct WebElementDescriptor { … };
const char kFormHtml[] = …;
const char kUnownedFormHtml[] = …;
const char kUnownedUntitledFormHtml[] = …;
const char kUnownedNonEnglishFormHtml[] = …;
std::string RetrievalMethodToString(
const WebElementDescriptor::RetrievalMethod& method) { … }
bool ClickElement(const WebDocument& document,
const WebElementDescriptor& element_descriptor) { … }
void ApplyFieldsAction(
const blink::WebDocument& document,
base::span<const FormFieldData> fields,
mojom::ActionPersistence action_persistence,
mojom::FormActionType action_type = mojom::FormActionType::kFill) { … }
constexpr CallTimerState kCallTimerStateDummy = …;
FormData FindForm(const blink::WebFormControlElement& element) { … }
class FormAutofillTest : public test::AutofillRendererTest { … };
TEST_F(FormAutofillTest, WebFormControlElementToFormField) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompleteOff) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldMaxLength) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutofilled) { … }
TEST_F(FormAutofillTest, WebFormControlElementToClickableFormField) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldSelect) { … }
TEST_F(FormAutofillTest,
WebFormControlElementToFormFieldSelect_ExtraAttributes) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldLongSelect) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldSelectListAriaLabel) { … }
TEST_F(FormAutofillTest,
WebFormControlElementToFormFieldSelectListNestedNodes) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldTextArea) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldMonthInput) { … }
TEST_F(FormAutofillTest, WebFormControlElementToPasswordFormField) { … }
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) { … }
TEST_F(FormAutofillTest, DetectTextDirectionFromDirectStyle) { … }
TEST_F(FormAutofillTest, DetectTextDirectionFromDirectDIRAttribute) { … }
TEST_F(FormAutofillTest, DetectTextDirectionFromParentStyle) { … }
TEST_F(FormAutofillTest, DetectTextDirectionFromParentDIRAttribute) { … }
TEST_F(FormAutofillTest, DetectTextDirectionWhenStyleAndDIRAttributeMixed) { … }
TEST_F(FormAutofillTest, TextAlignOverridesDirection) { … }
TEST_F(FormAutofillTest,
DetectTextDirectionWhenParentHasBothDIRAttributeAndStyle) { … }
TEST_F(FormAutofillTest, DetectTextDirectionWhenAncestorHasInlineStyle) { … }
TEST_F(FormAutofillTest, WebFormElementToFormData) { … }
TEST_F(FormAutofillTest, WebFormElementConsiderNonControlLabelableElements) { … }
TEST_F(FormAutofillTest, WebFormElementToFormData_TooManyFields) { … }
TEST_F(FormAutofillTest, WebFormElementToFormData_AutocompleteOff_OnForm) { … }
TEST_F(FormAutofillTest, WebFormElementToFormData_AutocompleteOff_OnField) { … }
TEST_F(FormAutofillTest, WebFormElementToFormData_AutocompleteOff_OneTimeCode) { … }
TEST_F(FormAutofillTest, WebFormElementToFormData_CssClasses) { … }
TEST_F(FormAutofillTest, WebFormElementToFormData_IdAttributes) { … }
TEST_F(FormAutofillTest, ExtractForms) { … }
TEST_F(FormAutofillTest, ExtractMultipleForms) { … }
TEST_F(FormAutofillTest, OnlyExtractNewForms) { … }
TEST_F(FormAutofillTest, ExtractFormsNoFields) { … }
TEST_F(FormAutofillTest, WebFormElementToFormData_Autocomplete) { … }
TEST_F(FormAutofillTest, FindFormForInputElement) { … }
TEST_F(FormAutofillTest, FindFormForInputElementForUnownedForm) { … }
TEST_F(FormAutofillTest, FindFormForTextAreaElement) { … }
TEST_F(FormAutofillTest, FindFormForTextAreaElementForUnownedForm) { … }
TEST_F(FormAutofillTest, FillForm) { … }
TEST_F(FormAutofillTest, FillFormForUnownedForm) { … }
TEST_F(FormAutofillTest, FillFormForUnownedUntitledForm) { … }
TEST_F(FormAutofillTest, FillFormForUnownedNonEnglishForm) { … }
TEST_F(FormAutofillTest, FillFormForUnownedNonASCIIForm) { … }
TEST_F(FormAutofillTest, PreviewFormX) { … }
TEST_F(FormAutofillTest, PreviewFormForUnownedForm) { … }
TEST_F(FormAutofillTest, PreviewFormForUnownedUntitledForm) { … }
TEST_F(FormAutofillTest, PreviewFormForUnownedNonEnglishForm) { … }
TEST_F(FormAutofillTest, Labels) { … }
TEST_F(FormAutofillTest, LabelForAttribute) { … }
TEST_F(FormAutofillTest, LabelTextBehindInput) { … }
TEST_F(FormAutofillTest, LabelsWithSpans) { … }
TEST_F(FormAutofillTest, InvalidLabels) { … }
TEST_F(FormAutofillTest, OneLabelElement) { … }
TEST_F(FormAutofillTest, LabelsInferredFromText) { … }
TEST_F(FormAutofillTest, LabelsInferredFromParagraph) { … }
TEST_F(FormAutofillTest, LabelsInferredFromBold) { … }
TEST_F(FormAutofillTest, LabelsInferredPriorToImgOrBr) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableCell) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableCellTH) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableCellNested) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableEmptyTDs) { … }
TEST_F(FormAutofillTest, LabelsInferredFromPreviousTD) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableWithSpecialElements) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableLabels) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableTDInterveningElements) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableAdjacentElements) { … }
TEST_F(FormAutofillTest, LabelsInferredFromTableRow) { … }
TEST_F(FormAutofillTest, LabelsInferredFromListItem) { … }
TEST_F(FormAutofillTest, LabelsInferredFromDefinitionList) { … }
TEST_F(FormAutofillTest, LabelsInferredWithSameName) { … }
TEST_F(FormAutofillTest, LabelsInferredWithImageTags) { … }
TEST_F(FormAutofillTest, LabelsInferredFromDivTable) { … }
TEST_F(FormAutofillTest, LabelsInferredFromDivSiblingTable) { … }
TEST_F(FormAutofillTest, LabelsInferredFromLabelInDivTable) { … }
TEST_F(FormAutofillTest, LabelsInferredFromDefinitionListRatherThanDivTable) { … }
TEST_F(FormAutofillTest, FillFormMaxLength) { … }
TEST_F(FormAutofillTest, FillFormMaxLengthForUnownedForm) { … }
TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { … }
TEST_F(FormAutofillTest, FillFormNegativeMaxLengthForUnownedForm) { … }
TEST_F(FormAutofillTest, FillFormEmptyName) { … }
TEST_F(FormAutofillTest, FillFormEmptyNameForUnownedForm) { … }
TEST_F(FormAutofillTest, FillFormEmptyFormNames) { … }
TEST_F(FormAutofillTest, FillFormEmptyFormNamesForUnownedForm) { … }
TEST_F(FormAutofillTest, ThreePartPhone) { … }
TEST_F(FormAutofillTest, MaxLengthFields) { … }
TEST_F(FormAutofillTest, FillFormNonEmptyField) { … }
TEST_F(FormAutofillTest, FillFormNonEmptyFieldsWithDefaultValues) { … }
TEST_F(FormAutofillTest, FillFormModifyValues) { … }
TEST_F(FormAutofillTest, FillFormModifyInitiatingValue) { … }
TEST_F(FormAutofillTest, FillFormJSModifiesUserInputValue) { … }
TEST_F(FormAutofillTest, FillFormNonEmptyFieldsWithPlaceholderValues) { … }
TEST_F(FormAutofillTest, FillFormNonEmptyFieldForUnownedForm) { … }
TEST_F(FormAutofillTest, UndoAutofill) { … }
TEST_F(FormAutofillTest, ClearPreviewedElements) { … }
TEST_F(FormAutofillTest, ClearPreviewedFormWithElementForUnownedForm) { … }
TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) { … }
TEST_F(FormAutofillTest,
ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { … }
TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) { … }
TEST_F(FormAutofillTest,
ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { … }
TEST_F(FormAutofillTest, MultipleLabelsPerElement) { … }
TEST_F(FormAutofillTest, ClickElement) { … }
TEST_F(FormAutofillTest, SelectOneAsText) { … }
TEST_F(FormAutofillTest, UnownedFormElementsToFormDataWithoutForm) { … }
TEST_F(FormAutofillTest, UnownedFormElementsToFormDataWithForm) { … }
TEST_F(FormAutofillTest, FormlessForms) { … }
TEST_F(FormAutofillTest, FormCache_ExtractNewForms) { … }
TEST_F(FormAutofillTest, AriaLabelAndDescription) { … }
TEST_F(FormAutofillTest, AriaLabelAndDescription2) { … }
}
}