Commit 7300efea authored by Roger McFarlane's avatar Roger McFarlane Committed by Commit Bot

[autofill] Only consider forms from HTTP(S) origins.

Autofill will not query/upload form information for form URLS
having a non HTTP(S) scheme.

Bug: 607907, 894428
Change-Id: Ic03afbec002e3cf005d22ac25fd96e90b0be1273
Reviewed-on: https://chromium-review.googlesource.com/c/1257184
Commit-Queue: Roger McFarlane <rogerm@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598824}
parent 75419b85
...@@ -147,6 +147,8 @@ public abstract class ChromeFeatureList { ...@@ -147,6 +147,8 @@ public abstract class ChromeFeatureList {
} }
// Alphabetical: // Alphabetical:
public static final String AUTOFILL_ALLOW_NON_HTTP_ACTIVATION =
"AutofillAllowNonHttpActivation";
public static final String ADJUST_WEBAPK_INSTALLATION_SPACE = "AdjustWebApkInstallationSpace"; public static final String ADJUST_WEBAPK_INSTALLATION_SPACE = "AdjustWebApkInstallationSpace";
public static final String ANDROID_PAY_INTEGRATION_V1 = "AndroidPayIntegrationV1"; public static final String ANDROID_PAY_INTEGRATION_V1 = "AndroidPayIntegrationV1";
public static final String ANDROID_PAY_INTEGRATION_V2 = "AndroidPayIntegrationV2"; public static final String ANDROID_PAY_INTEGRATION_V2 = "AndroidPayIntegrationV2";
......
...@@ -20,10 +20,12 @@ import org.chromium.base.test.util.Feature; ...@@ -20,10 +20,12 @@ import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure; import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.content_public.browser.ImeAdapter; import org.chromium.content_public.browser.ImeAdapter;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
...@@ -141,6 +143,9 @@ public class AutofillPopupTest { ...@@ -141,6 +143,9 @@ public class AutofillPopupTest {
AutofillLogger.setLoggerForTesting( AutofillLogger.setLoggerForTesting(
logEntry -> mAutofillLoggedEntries.add(logEntry) logEntry -> mAutofillLoggedEntries.add(logEntry)
); );
// TODO(crbug.com/894428) - fix this suite to use the embedded test server instead of
// data urls.
Features.getInstance().enable(ChromeFeatureList.AUTOFILL_ALLOW_NON_HTTP_ACTIVATION);
} }
private void loadAndFillForm(final String formDataUrl, final String inputText) private void loadAndFillForm(final String formDataUrl, final String inputText)
......
...@@ -8,6 +8,7 @@ import android.support.test.filters.MediumTest; ...@@ -8,6 +8,7 @@ import android.support.test.filters.MediumTest;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -18,10 +19,12 @@ import org.chromium.base.test.util.Feature; ...@@ -18,10 +19,12 @@ import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure; import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
...@@ -43,6 +46,13 @@ public class AutofillPopupWithKeyboardTest { ...@@ -43,6 +46,13 @@ public class AutofillPopupWithKeyboardTest {
public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule<>(ChromeActivity.class); new ChromeActivityTestRule<>(ChromeActivity.class);
@Before
public void setUp() throws Exception {
// TODO(crbug.com/894428) - fix this suite to use the embedded test server instead of
// data urls.
Features.getInstance().enable(ChromeFeatureList.AUTOFILL_ALLOW_NON_HTTP_ACTIVATION);
}
/** /**
* Test that showing autofill popup and keyboard will not hide the autofill popup. * Test that showing autofill popup and keyboard will not hide the autofill popup.
*/ */
......
...@@ -25,6 +25,7 @@ import android.view.View; ...@@ -25,6 +25,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.junit.After; import org.junit.After;
import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -65,6 +66,13 @@ public class ManualFillingIntegrationTest { ...@@ -65,6 +66,13 @@ public class ManualFillingIntegrationTest {
private final ManualFillingTestHelper mHelper = new ManualFillingTestHelper(mActivityTestRule); private final ManualFillingTestHelper mHelper = new ManualFillingTestHelper(mActivityTestRule);
@Before
public void setUp() throws Exception {
// TODO(crbug.com/894428) - fix this suite to use the embedded test server instead of
// data urls.
Features.getInstance().enable(ChromeFeatureList.AUTOFILL_ALLOW_NON_HTTP_ACTIVATION);
}
@After @After
public void tearDown() { public void tearDown() {
mHelper.clear(); mHelper.clear();
......
...@@ -32,6 +32,7 @@ import org.hamcrest.Description; ...@@ -32,6 +32,7 @@ import org.hamcrest.Description;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -46,6 +47,7 @@ import org.chromium.chrome.browser.ChromeSwitches; ...@@ -46,6 +47,7 @@ import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryData.Item; import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryData.Item;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule; import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
...@@ -66,6 +68,13 @@ public class PasswordAccessoryIntegrationTest { ...@@ -66,6 +68,13 @@ public class PasswordAccessoryIntegrationTest {
private final ManualFillingTestHelper mHelper = new ManualFillingTestHelper(mActivityTestRule); private final ManualFillingTestHelper mHelper = new ManualFillingTestHelper(mActivityTestRule);
@Before
public void setUp() throws Exception {
// TODO(crbug.com/894428) - fix this suite to use the embedded test server instead of
// data urls.
Features.getInstance().enable(ChromeFeatureList.AUTOFILL_ALLOW_NON_HTTP_ACTIVATION);
}
@After @After
public void tearDown() { public void tearDown() {
mHelper.clear(); mHelper.clear();
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
#include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager_observer.h" #include "components/autofill/core/browser/personal_data_manager_observer.h"
#include "components/autofill/core/common/autofill_features.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "content/public/test/url_loader_interceptor.h" #include "content/public/test/url_loader_interceptor.h"
...@@ -124,11 +126,27 @@ class WindowedNetworkObserver { ...@@ -124,11 +126,27 @@ class WindowedNetworkObserver {
class AutofillServerTest : public InProcessBrowserTest { class AutofillServerTest : public InProcessBrowserTest {
public: public:
void SetUp() override {
// Enable data-url support.
// TODO(crbug.com/894428) - fix this suite to use the embedded test server
// instead of data urls.
scoped_feature_list_.InitAndEnableFeature(
features::kAutofillAllowNonHttpActivation);
// Note that features MUST be enabled/disabled before continuing with
// SetUp(); otherwise, the feature state doesn't propagate to the test
// browser instance.
InProcessBrowserTest::SetUp();
}
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
// Enable finch experiment for sending field metadata. // Enable finch experiment for sending field metadata.
command_line->AppendSwitchASCII( command_line->AppendSwitchASCII(
::switches::kForceFieldTrials, "AutofillFieldMetadata/Enabled/"); ::switches::kForceFieldTrials, "AutofillFieldMetadata/Enabled/");
} }
private:
base::test::ScopedFeatureList scoped_feature_list_;
}; };
// Regression test for http://crbug.com/177419 // Regression test for http://crbug.com/177419
......
...@@ -2907,6 +2907,9 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_ComponentizedNumbers) { ...@@ -2907,6 +2907,9 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_ComponentizedNumbers) {
// Verify only the first complete number is filled when there are multiple // Verify only the first complete number is filled when there are multiple
// componentized number fields. // componentized number fields.
FormData form_with_multiple_componentized_phone_fields; FormData form_with_multiple_componentized_phone_fields;
form_with_multiple_componentized_phone_fields.origin =
GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
field.max_length = 10; field.max_length = 10;
...@@ -3004,6 +3007,8 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_WholeNumbers) { ...@@ -3004,6 +3007,8 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_WholeNumbers) {
std::string guid(work_profile->guid()); std::string guid(work_profile->guid());
FormData form_with_multiple_whole_number_fields; FormData form_with_multiple_whole_number_fields;
form_with_multiple_whole_number_fields.origin = GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
field.max_length = 10; field.max_length = 10;
...@@ -3085,6 +3090,9 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_FillPartsOnceOnly) { ...@@ -3085,6 +3090,9 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_FillPartsOnceOnly) {
// Verify only the first complete number is filled when there are multiple // Verify only the first complete number is filled when there are multiple
// componentized number fields. // componentized number fields.
FormData form_with_multiple_componentized_phone_fields; FormData form_with_multiple_componentized_phone_fields;
form_with_multiple_componentized_phone_fields.origin =
GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
field.max_length = 10; field.max_length = 10;
...@@ -3188,6 +3196,8 @@ TEST_F(AutofillManagerTest, ...@@ -3188,6 +3196,8 @@ TEST_F(AutofillManagerTest,
std::string guid(work_profile->guid()); std::string guid(work_profile->guid());
FormData form_with_misclassified_extension; FormData form_with_misclassified_extension;
form_with_misclassified_extension.origin = GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
field.max_length = 10; field.max_length = 10;
...@@ -3278,6 +3288,8 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_BestEfforFilling) { ...@@ -3278,6 +3288,8 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_BestEfforFilling) {
std::string guid(work_profile->guid()); std::string guid(work_profile->guid());
FormData form_with_no_complete_number; FormData form_with_no_complete_number;
form_with_no_complete_number.origin = GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
field.max_length = 10; field.max_length = 10;
...@@ -3363,6 +3375,8 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_FocusOnSecondPhoneNumber) { ...@@ -3363,6 +3375,8 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_FocusOnSecondPhoneNumber) {
std::string guid(work_profile->guid()); std::string guid(work_profile->guid());
FormData form_with_multiple_whole_number_fields; FormData form_with_multiple_whole_number_fields;
form_with_multiple_whole_number_fields.origin = GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
field.max_length = 10; field.max_length = 10;
...@@ -3448,6 +3462,8 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_HiddenFieldShouldNotCount) { ...@@ -3448,6 +3462,8 @@ TEST_F(AutofillManagerTest, FillFirstPhoneNumber_HiddenFieldShouldNotCount) {
std::string guid(work_profile->guid()); std::string guid(work_profile->guid());
FormData form_with_multiple_whole_number_fields; FormData form_with_multiple_whole_number_fields;
form_with_multiple_whole_number_fields.origin = GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
field.max_length = 10; field.max_length = 10;
...@@ -3601,6 +3617,8 @@ TEST_F(AutofillManagerTest, ...@@ -3601,6 +3617,8 @@ TEST_F(AutofillManagerTest,
std::string guid(work_profile->guid()); std::string guid(work_profile->guid());
FormData form_with_multiple_sections; FormData form_with_multiple_sections;
form_with_multiple_sections.origin = GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
field.max_length = 10; field.max_length = 10;
...@@ -3800,6 +3818,8 @@ TEST_F(AutofillManagerTest, FormChangesAddField) { ...@@ -3800,6 +3818,8 @@ TEST_F(AutofillManagerTest, FormChangesAddField) {
TEST_F(AutofillManagerTest, FormChangesVisibilityOfFields) { TEST_F(AutofillManagerTest, FormChangesVisibilityOfFields) {
// Set up our form data. // Set up our form data.
FormData form; FormData form;
form.origin = GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
// Default is zero, have to set to a number autofill can process. // Default is zero, have to set to a number autofill can process.
...@@ -4238,6 +4258,7 @@ TEST_F(AutofillManagerTest, OnLoadedServerPredictions_ResetManager) { ...@@ -4238,6 +4258,7 @@ TEST_F(AutofillManagerTest, OnLoadedServerPredictions_ResetManager) {
TEST_F(AutofillManagerTest, DetermineHeuristicsWithOverallPrediction) { TEST_F(AutofillManagerTest, DetermineHeuristicsWithOverallPrediction) {
// Set up our form data. // Set up our form data.
FormData form; FormData form;
form.origin = GURL("https://www.myform.com");
FormFieldData field; FormFieldData field;
test::CreateTestFormField("First Name", "firstname", "", "text", &field); test::CreateTestFormField("First Name", "firstname", "", "text", &field);
form.fields.push_back(field); form.fields.push_back(field);
......
...@@ -3173,6 +3173,7 @@ TEST_F(AutofillMetricsTest, PolledCreditCardSuggestions_DebounceLogs) { ...@@ -3173,6 +3173,7 @@ TEST_F(AutofillMetricsTest, PolledCreditCardSuggestions_DebounceLogs) {
// Set up the form data. // Set up the form data.
FormData form; FormData form;
form.name = ASCIIToUTF16("TestForm"); form.name = ASCIIToUTF16("TestForm");
form.origin = GURL("http://www.foo.com/");
FormFieldData field; FormFieldData field;
std::vector<ServerFieldType> field_types; std::vector<ServerFieldType> field_types;
......
...@@ -61,6 +61,14 @@ const char kShippingMode[] = "shipping"; ...@@ -61,6 +61,14 @@ const char kShippingMode[] = "shipping";
const int kCommonNamePrefixRemovalFieldThreshold = 3; const int kCommonNamePrefixRemovalFieldThreshold = 3;
const int kMinCommonNamePrefixLength = 16; const int kMinCommonNamePrefixLength = 16;
// Returns true if the scheme given by |url| is one for which autfill is allowed
// to activate. By default this only returns true for HTTP and HTTPS.
bool HasAllowedScheme(const GURL& url) {
return url.SchemeIsHTTPOrHTTPS() ||
base::FeatureList::IsEnabled(
features::kAutofillAllowNonHttpActivation);
}
// Helper for |EncodeUploadRequest()| that creates a bit field corresponding to // Helper for |EncodeUploadRequest()| that creates a bit field corresponding to
// |available_field_types| and returns the hex representation as a string. // |available_field_types| and returns the hex representation as a string.
std::string EncodeFieldTypes(const ServerFieldTypeSet& available_field_types) { std::string EncodeFieldTypes(const ServerFieldTypeSet& available_field_types) {
...@@ -690,6 +698,10 @@ void FormStructure::UpdateAutofillCount() { ...@@ -690,6 +698,10 @@ void FormStructure::UpdateAutofillCount() {
} }
bool FormStructure::ShouldBeParsed() const { bool FormStructure::ShouldBeParsed() const {
// Exclude URLs not on the web via HTTP(S).
if (!HasAllowedScheme(source_url_))
return false;
size_t min_required_fields = size_t min_required_fields =
std::min({MinRequiredFieldsForHeuristics(), MinRequiredFieldsForQuery(), std::min({MinRequiredFieldsForHeuristics(), MinRequiredFieldsForQuery(),
MinRequiredFieldsForUpload()}); MinRequiredFieldsForUpload()});
...@@ -718,6 +730,7 @@ bool FormStructure::ShouldBeParsed() const { ...@@ -718,6 +730,7 @@ bool FormStructure::ShouldBeParsed() const {
bool FormStructure::ShouldRunHeuristics() const { bool FormStructure::ShouldRunHeuristics() const {
return active_field_count() >= MinRequiredFieldsForHeuristics() && return active_field_count() >= MinRequiredFieldsForHeuristics() &&
HasAllowedScheme(source_url_) &&
(is_form_tag_ || is_formless_checkout_ || (is_form_tag_ || is_formless_checkout_ ||
!base::FeatureList::IsEnabled( !base::FeatureList::IsEnabled(
features::kAutofillRestrictUnownedFieldsToFormlessCheckout)); features::kAutofillRestrictUnownedFieldsToFormlessCheckout));
......
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
namespace autofill { namespace autofill {
namespace features { namespace features {
// Controls whether autofill activates on non-HTTP(S) pages. Useful for
// automated with data URLS in cases where it's too difficult to use the
// embedded test server. Generally avoid using.
//
const base::Feature kAutofillAllowNonHttpActivation{
"AutofillAllowNonHttpActivation", base::FEATURE_DISABLED_BY_DEFAULT};
// Controls whether the AddressNormalizer is supplied. If available, it may be // Controls whether the AddressNormalizer is supplied. If available, it may be
// used to normalize address and will incur fetching rules from the server. // used to normalize address and will incur fetching rules from the server.
const base::Feature kAutofillAddressNormalizer{ const base::Feature kAutofillAddressNormalizer{
......
...@@ -21,6 +21,7 @@ namespace autofill { ...@@ -21,6 +21,7 @@ namespace autofill {
namespace features { namespace features {
// All features in alphabetical order. // All features in alphabetical order.
extern const base::Feature kAutofillAllowNonHttpActivation;
extern const base::Feature kAutofillAddressNormalizer; extern const base::Feature kAutofillAddressNormalizer;
extern const base::Feature kAutofillAlwaysFillAddresses; extern const base::Feature kAutofillAlwaysFillAddresses;
extern const base::Feature kAutofillCacheQueryResponses; extern const base::Feature kAutofillCacheQueryResponses;
......
...@@ -89,6 +89,8 @@ enum SavePromptInteraction { SAVE, NEVER, NO_INTERACTION }; ...@@ -89,6 +89,8 @@ enum SavePromptInteraction { SAVE, NEVER, NO_INTERACTION };
PasswordForm CreateMinimalCrowdsourcableForm( PasswordForm CreateMinimalCrowdsourcableForm(
const PasswordForm& observed_form) { const PasswordForm& observed_form) {
PasswordForm form = observed_form; PasswordForm form = observed_form;
form.origin = GURL("https://www.foo.com/login");
form.form_data.origin = form.origin;
autofill::FormFieldData field; autofill::FormFieldData field;
field.name = ASCIIToUTF16("email"); field.name = ASCIIToUTF16("email");
field.form_control_type = "text"; field.form_control_type = "text";
...@@ -4514,6 +4516,9 @@ TEST_F(PasswordFormManagerTest, FirstLoginVote_NoUsernameSubmitted) { ...@@ -4514,6 +4516,9 @@ TEST_F(PasswordFormManagerTest, FirstLoginVote_NoUsernameSubmitted) {
// User submits credentials for the observed form. // User submits credentials for the observed form.
PasswordForm submitted_form = *observed_form(); PasswordForm submitted_form = *observed_form();
submitted_form.origin = GURL("https://www.foo.com/login");
submitted_form.form_data.origin = submitted_form.origin;
autofill::FormFieldData field; autofill::FormFieldData field;
field.name = ASCIIToUTF16("password1"); field.name = ASCIIToUTF16("password1");
field.form_control_type = "password"; field.form_control_type = "password";
...@@ -4603,6 +4608,8 @@ TEST_F(PasswordFormManagerTest, FirstLoginVote_KnownValue) { ...@@ -4603,6 +4608,8 @@ TEST_F(PasswordFormManagerTest, FirstLoginVote_KnownValue) {
observed_form()->password_element = ASCIIToUTF16("password"); observed_form()->password_element = ASCIIToUTF16("password");
// User submits credentials for the observed form. // User submits credentials for the observed form.
PasswordForm submitted_form = *observed_form(); PasswordForm submitted_form = *observed_form();
submitted_form.origin = GURL("https://www.foo.com/login");
submitted_form.form_data.origin = submitted_form.origin;
submitted_form.username_value = saved_match()->username_value; submitted_form.username_value = saved_match()->username_value;
submitted_form.password_value = saved_match()->password_value; submitted_form.password_value = saved_match()->password_value;
submitted_form.form_data.fields[0].value = submitted_form.username_value; submitted_form.form_data.fields[0].value = submitted_form.username_value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment