summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 17:24:05 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 17:24:05 +0000
commitada3b7edfa206d22f2080ad287805d6a636190ec (patch)
tree8d598083cf63a7be589d4cb8fa77c2fd22ee7bb8 /chrome/renderer
parent04b0c9332361ac2f7de9455d0df15290db94c693 (diff)
downloadchromium_src-ada3b7edfa206d22f2080ad287805d6a636190ec.zip
chromium_src-ada3b7edfa206d22f2080ad287805d6a636190ec.tar.gz
chromium_src-ada3b7edfa206d22f2080ad287805d6a636190ec.tar.bz2
AutoFill: Use setSuggestedValue() instead of setPlaceholder() when previewing
forms. This protects the user's data from javascript that can read placeholder values. BUG=48233 TEST=FormManagerTest.PreviewForm Review URL: http://codereview.chromium.org/2845041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52091 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/form_manager.cc4
-rw-r--r--chrome/renderer/form_manager_unittest.cc24
2 files changed, 14 insertions, 14 deletions
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc
index e2d0c65..c67b8f9 100644
--- a/chrome/renderer/form_manager.cc
+++ b/chrome/renderer/form_manager.cc
@@ -603,7 +603,7 @@ bool FormManager::ClearPreviewedForm(const FormData& form) {
if (!input_element.value().isEmpty())
continue;
- input_element.setPlaceholder(string16());
+ input_element.setSuggestedValue(string16());
input_element.setAutofilled(false);
}
@@ -857,7 +857,7 @@ void FormManager::PreviewFormField(WebKit::WebFormControlElement* field,
// If the maxlength attribute contains a negative value, maxLength()
// returns the default maxlength value.
- input_element.setPlaceholder(
+ input_element.setSuggestedValue(
data->value().substr(0, input_element.maxLength()));
input_element.setAutofilled(true);
}
diff --git a/chrome/renderer/form_manager_unittest.cc b/chrome/renderer/form_manager_unittest.cc
index 88011b6..3d44e71 100644
--- a/chrome/renderer/form_manager_unittest.cc
+++ b/chrome/renderer/form_manager_unittest.cc
@@ -564,36 +564,36 @@ TEST_F(FormManagerTest, PreviewForm) {
WebInputElement firstname =
document.getElementById("firstname").to<WebInputElement>();
EXPECT_TRUE(firstname.isAutofilled());
- EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.placeholder());
+ EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.suggestedValue());
WebInputElement lastname =
document.getElementById("lastname").to<WebInputElement>();
EXPECT_TRUE(lastname.isAutofilled());
- EXPECT_EQ(ASCIIToUTF16("Earp"), lastname.placeholder());
+ EXPECT_EQ(ASCIIToUTF16("Earp"), lastname.suggestedValue());
// Hidden fields are not previewed.
WebInputElement imhidden =
document.getElementById("imhidden").to<WebInputElement>();
EXPECT_FALSE(imhidden.isAutofilled());
- EXPECT_TRUE(imhidden.placeholder().isEmpty());
+ EXPECT_TRUE(imhidden.suggestedValue().isEmpty());
// Non-empty fields are not previewed.
WebInputElement notempty =
document.getElementById("notempty").to<WebInputElement>();
EXPECT_FALSE(notempty.isAutofilled());
- EXPECT_TRUE(notempty.placeholder().isEmpty());
+ EXPECT_TRUE(notempty.suggestedValue().isEmpty());
// autocomplete=off fields are not previewed.
WebInputElement noautocomplete =
document.getElementById("noautocomplete").to<WebInputElement>();
EXPECT_FALSE(noautocomplete.isAutofilled());
- EXPECT_TRUE(noautocomplete.placeholder().isEmpty());
+ EXPECT_TRUE(noautocomplete.suggestedValue().isEmpty());
// Disabled fields are not previewed.
WebInputElement notenabled =
document.getElementById("notenabled").to<WebInputElement>();
EXPECT_FALSE(notenabled.isAutofilled());
- EXPECT_TRUE(notenabled.placeholder().isEmpty());
+ EXPECT_TRUE(notenabled.suggestedValue().isEmpty());
}
TEST_F(FormManagerTest, Reset) {
@@ -2333,24 +2333,24 @@ TEST_F(FormManagerTest, ClearPreviewedForm) {
web_frame->document().getElementById("email").to<WebInputElement>();
email.setAutofilled(true);
- // Set the placeholder values on two of the elements.
- lastname.setPlaceholder(ASCIIToUTF16("Earp"));
- email.setPlaceholder(ASCIIToUTF16("wyatt@earp.com"));
+ // Set the suggested values on two of the elements.
+ lastname.setSuggestedValue(ASCIIToUTF16("Earp"));
+ email.setSuggestedValue(ASCIIToUTF16("wyatt@earp.com"));
// Clear the previewed fields.
EXPECT_TRUE(form_manager.ClearPreviewedForm(forms[0]));
// Fields with non-empty values are not modified.
EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.value());
- EXPECT_TRUE(firstname.placeholder().isEmpty());
+ EXPECT_TRUE(firstname.suggestedValue().isEmpty());
EXPECT_TRUE(firstname.isAutofilled());
// Verify the previewed fields are cleared.
EXPECT_TRUE(lastname.value().isEmpty());
- EXPECT_TRUE(lastname.placeholder().isEmpty());
+ EXPECT_TRUE(lastname.suggestedValue().isEmpty());
EXPECT_FALSE(lastname.isAutofilled());
EXPECT_TRUE(email.value().isEmpty());
- EXPECT_TRUE(email.placeholder().isEmpty());
+ EXPECT_TRUE(email.suggestedValue().isEmpty());
EXPECT_FALSE(email.isAutofilled());
}