Skip to content

Commit

Permalink
Revert of Limit form-less Autofilling to pages that look like checkou…
Browse files Browse the repository at this point in the history
…t pages. (patchset #7 id:120001 of https://codereview.chromium.org/1081803003/)

Reason for revert:
Caused compile error on Win x64 GN bot

Original issue's description:
> Limit form-less Autofilling to pages that look like checkout pages.
>
> This should hopefully stem the tide of false positives on non-checkout pages, while preserving desired behavior on Best Buy and Apple checkout.
>
> Fixing FormStructureBrowserTests: I went back and added <form>s that were present in the source pages but not in the local copies. I also added the original <title> tags, except for ones that did /not/ include any of the checkout keywords. For these, I added the checkout keywords to the title, so that the test still had some value (instead of passing trivially because the title was "Google Calendar" and not something like "Payment information").
>
> BUG=471090,477466
>
> Committed: https://crrev.com/aa3219ce27ef5471c19670fe5145b136925cbc89
> Cr-Commit-Position: refs/heads/master@{#327108}

TBR=thestig@chromium.org,brettw@chromium.org,estade@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=471090,477466

Review URL: https://codereview.chromium.org/1106313002

Cr-Commit-Position: refs/heads/master@{#327116}
  • Loading branch information
mohsen authored and Commit bot committed Apr 27, 2015
1 parent b70e516 commit f44602c
Show file tree
Hide file tree
Showing 32 changed files with 90 additions and 920 deletions.
58 changes: 19 additions & 39 deletions chrome/renderer/autofill/form_autofill_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const char kFormHtml[] =
"</FORM>";

const char kUnownedFormHtml[] =
"<HEAD><TITLE>enter shipping info</TITLE></HEAD>"
"<INPUT type='text' id='firstname'/>"
"<INPUT type='text' id='lastname'/>"
"<INPUT type='hidden' id='imhidden'/>"
Expand Down Expand Up @@ -1038,7 +1037,6 @@ class FormAutofillTest : public ChromeRenderViewTest {
EXPECT_TRUE(
FindFormAndFieldForFormControlElement(firstname, &form, &field));
EXPECT_EQ(GURL(web_frame->document().url()), form.origin);
EXPECT_FALSE(form.origin.is_empty());
if (!unowned) {
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL("http://buh.com"), form.action);
Expand Down Expand Up @@ -1133,7 +1131,6 @@ class FormAutofillTest : public ChromeRenderViewTest {
EXPECT_TRUE(
FindFormAndFieldForFormControlElement(firstname, &form, &field));
EXPECT_EQ(GURL(web_frame->document().url()), form.origin);
EXPECT_FALSE(form.origin.is_empty());
if (!unowned) {
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL("http://buh.com"), form.action);
Expand Down Expand Up @@ -1921,7 +1918,6 @@ TEST_F(FormAutofillTest, WebFormElementToFormData) {
&field));
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL(frame->document().url()), form.origin);
EXPECT_FALSE(form.origin.is_empty());
EXPECT_EQ(GURL("http://cnn.com"), form.action);

const std::vector<FormFieldData>& fields = form.fields;
Expand Down Expand Up @@ -2034,7 +2030,6 @@ TEST_F(FormAutofillTest, ExtractMultipleForms) {
const FormData& form = forms[0];
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL(web_frame->document().url()), form.origin);
EXPECT_FALSE(form.origin.is_empty());
EXPECT_EQ(GURL("http://cnn.com"), form.action);

const std::vector<FormFieldData>& fields = form.fields;
Expand All @@ -2060,7 +2055,6 @@ TEST_F(FormAutofillTest, ExtractMultipleForms) {
const FormData& form2 = forms[1];
EXPECT_EQ(ASCIIToUTF16("TestForm2"), form2.name);
EXPECT_EQ(GURL(web_frame->document().url()), form2.origin);
EXPECT_FALSE(form.origin.is_empty());
EXPECT_EQ(GURL("http://zoo.com"), form2.action);

const std::vector<FormFieldData>& fields2 = form2.fields;
Expand Down Expand Up @@ -2283,7 +2277,6 @@ TEST_F(FormAutofillTest, FindFormForInputElement) {

TEST_F(FormAutofillTest, FindFormForInputElementForUnownedForm) {
TestFindFormForInputElement(
"<HEAD><TITLE>delivery recipient</TITLE></HEAD>"
"<INPUT type='text' id='firstname' value='John'/>"
"<INPUT type='text' id='lastname' value='Smith'/>"
"<INPUT type='text' id='email' value='john@example.com'"
Expand Down Expand Up @@ -2311,7 +2304,6 @@ TEST_F(FormAutofillTest, FindFormForTextAreaElement) {

TEST_F(FormAutofillTest, FindFormForTextAreaElementForUnownedForm) {
TestFindFormForTextAreaElement(
"<HEAD><TITLE>delivery address</TITLE></HEAD>"
"<INPUT type='text' id='firstname' value='John'/>"
"<INPUT type='text' id='lastname' value='Smith'/>"
"<INPUT type='text' id='email' value='john@example.com'"
Expand Down Expand Up @@ -3379,7 +3371,6 @@ TEST_F(FormAutofillTest, FillFormMaxLength) {

TEST_F(FormAutofillTest, FillFormMaxLengthForUnownedForm) {
TestFillFormMaxLength(
"<HEAD><TITLE>delivery recipient info</TITLE></HEAD>"
"<INPUT type='text' id='firstname' maxlength='5'/>"
"<INPUT type='text' id='lastname' maxlength='7'/>"
"<INPUT type='text' id='email' maxlength='9'/>"
Expand All @@ -3392,7 +3383,6 @@ TEST_F(FormAutofillTest, FillFormMaxLengthForUnownedForm) {
// maxlength (defined in WebKit.)
TEST_F(FormAutofillTest, FillFormNegativeMaxLength) {
TestFillFormNegativeMaxLength(
"<HEAD><TITLE>delivery recipient info</TITLE></HEAD>"
"<FORM name='TestForm' action='http://buh.com' method='post'>"
" <INPUT type='text' id='firstname' maxlength='-1'/>"
" <INPUT type='text' id='lastname' maxlength='-10'/>"
Expand All @@ -3404,7 +3394,6 @@ TEST_F(FormAutofillTest, FillFormNegativeMaxLength) {

TEST_F(FormAutofillTest, FillFormNegativeMaxLengthForUnownedForm) {
TestFillFormNegativeMaxLength(
"<HEAD><TITLE>delivery recipient info</TITLE></HEAD>"
"<INPUT type='text' id='firstname' maxlength='-1'/>"
"<INPUT type='text' id='lastname' maxlength='-10'/>"
"<INPUT type='text' id='email' maxlength='-13'/>"
Expand All @@ -3425,7 +3414,6 @@ TEST_F(FormAutofillTest, FillFormEmptyName) {

TEST_F(FormAutofillTest, FillFormEmptyNameForUnownedForm) {
TestFillFormEmptyName(
"<HEAD><TITLE>delivery recipient info</TITLE></HEAD>"
"<INPUT type='text' id='firstname'/>"
"<INPUT type='text' id='lastname'/>"
"<INPUT type='text' id='email'/>"
Expand All @@ -3452,7 +3440,6 @@ TEST_F(FormAutofillTest, FillFormEmptyFormNames) {

TEST_F(FormAutofillTest, FillFormEmptyFormNamesForUnownedForm) {
TestFillFormEmptyFormNames(
"<HEAD><TITLE>enter delivery preferences</TITLE></HEAD>"
"<INPUT type='text' id='firstname'/>"
"<INPUT type='text' id='middlename'/>"
"<INPUT type='text' id='lastname'/>"
Expand All @@ -3476,6 +3463,7 @@ TEST_F(FormAutofillTest, ThreePartPhone) {
" <input type='submit' name='reply-send' value='Send'>"
"</FORM>");


WebFrame* frame = GetMainFrame();
ASSERT_NE(nullptr, frame);

Expand All @@ -3491,7 +3479,6 @@ TEST_F(FormAutofillTest, ThreePartPhone) {
nullptr));
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL(frame->document().url()), form.origin);
EXPECT_FALSE(form.origin.is_empty());
EXPECT_EQ(GURL("http://cnn.com"), form.action);

const std::vector<FormFieldData>& fields = form.fields;
Expand Down Expand Up @@ -3606,13 +3593,11 @@ TEST_F(FormAutofillTest, FillFormNonEmptyField) {
}

TEST_F(FormAutofillTest, FillFormNonEmptyFieldForUnownedForm) {
TestFillFormNonEmptyField(
"<HEAD><TITLE>delivery recipient info</TITLE></HEAD>"
"<INPUT type='text' id='firstname'/>"
"<INPUT type='text' id='lastname'/>"
"<INPUT type='text' id='email'/>"
"<INPUT type='submit' value='Send'/>",
true);
TestFillFormNonEmptyField("<INPUT type='text' id='firstname'/>"
"<INPUT type='text' id='lastname'/>"
"<INPUT type='text' id='email'/>"
"<INPUT type='submit' value='Send'/>",
true);
}

TEST_F(FormAutofillTest, ClearFormWithNode) {
Expand All @@ -3637,7 +3622,6 @@ TEST_F(FormAutofillTest, ClearFormWithNode) {

TEST_F(FormAutofillTest, ClearFormWithNodeForUnownedForm) {
TestClearFormWithNode(
"<HEAD><TITLE>store checkout</TITLE></HEAD>"
" <!-- Indented on purpose //-->"
" <INPUT type='text' id='firstname' value='Wyatt'/>"
" <INPUT type='text' id='lastname' value='Earp'/>"
Expand Down Expand Up @@ -3673,7 +3657,6 @@ TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOne) {

TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOneForUnownedForm) {
TestClearFormWithNodeContainingSelectOne(
"<HEAD><TITLE>store checkout</TITLE></HEAD>"
"<INPUT type='text' id='firstname' value='Wyatt'/>"
"<INPUT type='text' id='lastname' value='Earp'/>"
"<SELECT id='state' name='state'>"
Expand All @@ -3700,7 +3683,6 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) {

TEST_F(FormAutofillTest, ClearPreviewedFormWithElementForUnownedForm) {
TestClearPreviewedFormWithElement(
"<HEAD><TITLE>store checkout</TITLE></HEAD>"
"<INPUT type='text' id='firstname' value='Wyatt'/>"
"<INPUT type='text' id='lastname'/>"
"<INPUT type='text' id='email'/>"
Expand All @@ -3724,7 +3706,6 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) {
TEST_F(FormAutofillTest,
ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) {
TestClearPreviewedFormWithNonEmptyInitiatingNode(
"<HEAD><TITLE>shipping details</TITLE></HEAD>"
"<INPUT type='text' id='firstname' value='W'/>"
"<INPUT type='text' id='lastname'/>"
"<INPUT type='text' id='email'/>"
Expand All @@ -3748,7 +3729,6 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) {
TEST_F(FormAutofillTest,
ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) {
TestClearPreviewedFormWithAutofilledInitiatingNode(
"<HEAD><TITLE>shipping details</TITLE></HEAD>"
"<INPUT type='text' id='firstname' value='W'/>"
"<INPUT type='text' id='lastname'/>"
"<INPUT type='text' id='email'/>"
Expand All @@ -3771,7 +3751,6 @@ TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) {

TEST_F(FormAutofillTest, ClearOnlyAutofilledFieldsForUnownedForm) {
TestClearOnlyAutofilledFields(
"<HEAD><TITLE>shipping details</TITLE></HEAD>"
"<INPUT type='text' id='firstname' value='Wyatt'/>"
"<INPUT type='text' id='lastname' value='Earp'/>"
"<INPUT type='email' id='email' value='wyatt@earp.com'/>"
Expand Down Expand Up @@ -3934,9 +3913,9 @@ TEST_F(FormAutofillTest,

const ExtractMask extract_mask =
static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS);
const GURL dummy_origin("http://www.example.com");

LoadHTML("<HEAD><TITLE>delivery info</TITLE></HEAD>"
"<DIV>"
LoadHTML("<DIV>"
" <FIELDSET>"
" <LABEL for='firstname'>First name:</LABEL>"
" <LABEL for='lastname'>Last name:</LABEL>"
Expand All @@ -3959,11 +3938,11 @@ TEST_F(FormAutofillTest,

FormData form;
EXPECT_TRUE(UnownedFormElementsAndFieldSetsToFormData(
fieldsets, control_elements, nullptr, frame->document(), extract_mask,
&form, nullptr));
fieldsets, control_elements, nullptr, dummy_origin, extract_mask, &form,
nullptr));

EXPECT_TRUE(form.name.empty());
EXPECT_EQ(frame->document().url(), form.origin);
EXPECT_EQ(dummy_origin, form.origin);
EXPECT_FALSE(form.action.is_valid());

const std::vector<FormFieldData>& fields = form.fields;
Expand Down Expand Up @@ -3996,9 +3975,9 @@ TEST_F(FormAutofillTest,

const ExtractMask extract_mask =
static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS);
const GURL dummy_origin("http://www.example.com");

LoadHTML("<HEAD><TITLE>shipping details</TITLE></HEAD>"
"<DIV>"
LoadHTML("<DIV>"
" <FIELDSET>"
" <LABEL for='firstname'>First name:</LABEL>"
" <LABEL for='lastname'>Last name:</LABEL>"
Expand All @@ -4019,11 +3998,11 @@ TEST_F(FormAutofillTest,

FormData form;
EXPECT_TRUE(UnownedFormElementsAndFieldSetsToFormData(
fieldsets, control_elements, nullptr, frame->document(), extract_mask,
&form, nullptr));
fieldsets, control_elements, nullptr, dummy_origin, extract_mask, &form,
nullptr));

EXPECT_TRUE(form.name.empty());
EXPECT_EQ(frame->document().url(), form.origin);
EXPECT_EQ(dummy_origin, form.origin);
EXPECT_FALSE(form.action.is_valid());

const std::vector<FormFieldData>& fields = form.fields;
Expand Down Expand Up @@ -4055,6 +4034,7 @@ TEST_F(FormAutofillTest, UnownedFormElementsAndFieldSetsToFormDataWithForm) {

const ExtractMask extract_mask =
static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS);
const GURL dummy_origin("http://www.example.com");

LoadHTML(kFormHtml);

Expand All @@ -4068,8 +4048,8 @@ TEST_F(FormAutofillTest, UnownedFormElementsAndFieldSetsToFormDataWithForm) {

FormData form;
EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData(
fieldsets, control_elements, nullptr, frame->document(), extract_mask,
&form, nullptr));
fieldsets, control_elements, nullptr, dummy_origin, extract_mask, &form,
nullptr));
}

} // namespace autofill
2 changes: 1 addition & 1 deletion chrome/test/data/autofill/autofill_noform_dynamic.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Autofill test with dynamically created fields, and without a form tag. -->
<html>
<head>
<title>Dynamic Autofill Test - No Form - Collects address information</title>
<title>Dynamic Autofill Test - No Form</title>
<script>
function AddFields() {
var fields = document.getElementById("fields");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<head><title>L.L.Bean Secure Checkout:</title></head>
<form id="stepShippingForm" name="stepShippingForm" class="formElements container_12" autocomplete="off">
<div>
<div><select id="shipPersonTitle" name="_1_personTitle" selectedtitle=""> <option value="" selected="selected">Title (optional)</option> <option value="Mr."> Mr.</option> <option value="Mrs."> Mrs.</option> <option value="Ms."> Ms.</option> <option value="Dr."> Dr.</option> <option value="Sir"> Sir</option> </select> </div>
<div><label for="shipFirstName">First Name&nbsp; </label><input value="" id="shipFirstName" maxlength="20" name="_1_firstName" type="text" autocomplete="off" autocapitalize="on" autocorrect="off"> <span></span><div></div></div>
Expand Down Expand Up @@ -32,4 +30,3 @@
<div id="shipLocaleMessage"></div><br>
<div> <span> <div><input name="un_jtt_cktbtn_0" type="submit" value="Continue to Billing Address" myclass=""></div> </span> <div><a data-address="" data-step="payment">Return to Previous Recipient</a></div> <div><a data-address="" data-step="payment" href="/shoppingbag.html">Return to Shopping Bag</a></div> <div><a data-address="" data-step="payment" href="/checkout.html#payment">Cancel</a></div> </div>
</div>
</form>
3 changes: 0 additions & 3 deletions chrome/test/data/autofill/heuristics/input/b465571.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

<form id="checkoutCommand" class="stdForm" action="/checkout" method="post"> <fieldset id="shipAdr">
<ol>
<li>
<label for="address.name">* Name <span class="fText">(first and last)</span>: </label>
Expand Down Expand Up @@ -95,4 +93,3 @@
</span>
</li>
</ol>
</form>
2 changes: 1 addition & 1 deletion chrome/test/data/autofill/heuristics/input/bug_454366.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<head><title>Google+ - terms to make this test non-trivial: payment checkout address</title></head>
<head></head>
<body>
<input type="text name="hist_state" id="hist_state" style="display: none;">
<div class="g-h-f-ci g-h-f-Au">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<head><title>Google+ - terms to make this test non-trivial: payment checkout address</title></head>
<head></head>
<body>
<input type="text name="hist_state" id="hist_state" style="display: none;">
<div class="g-h-f-ci g-h-f-Au">
Expand Down
Loading

0 comments on commit f44602c

Please sign in to comment.