Commit f591d29e authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Revert "Remove extra form data, if "value" attribute present with non-empty value"

This reverts commit 9b477bca.

Reason for revert: We should deprecate the feature first.

Original change's description:
> Remove extra form data, if "value" attribute present with non-empty value
> 
> This patch removes the extra form data added, if "value" attribute
> present with non-empty value for <input type='image'>
> 
> Intent to Deprecate and Remove:
> https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/hp1_-1tgvDs
> 
> Bug: 753746
> Change-Id: I1de9a0c9babd9d16b45e5eefa780370fff8c75e9
> Reviewed-on: https://chromium-review.googlesource.com/896905
> Reviewed-by: Kent Tamura <tkent@chromium.org>
> Commit-Queue: Shanmuga Pandi <shanmuga.m@samsung.com>
> Cr-Commit-Position: refs/heads/master@{#533655}

TBR=tkent@chromium.org,foolip@chromium.org,shanmuga.m@samsung.com

Change-Id: I97c5987adba9eaa097808f7a35c54859217edd2e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 753746
Reviewed-on: https://chromium-review.googlesource.com/897264Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533910}
parent e0dea6a4
<!DOCTYPE html>
<meta charset="utf-8">
<title>Check form-data for image submit button with non-empty 'value' attribute</title>
<link rel="author" title="Shanmuga Pandi" href="mailto:shanmuga.m@samsung.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-form-data-set">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
// promise_test instead of async_test because this test use window.success, and so can't run at the same time.
promise_test(t => {
return new Promise(resolve => {
window.success = t.step_func(locationLoaded => {
const expected = (new URL("resources/image-submit-click.html?name.x=0&name.y=0", location.href)).href;
assert_equals(locationLoaded, expected);
resolve();
});
const iframe = document.createElement("iframe");
iframe.src = "resources/image-submit-click.html";
document.body.appendChild(iframe);
});
}, "Image submit button should not add extra form data if 'value' attribute is present with non-empty value");
</script>
<!DOCTYPE html>
<form>
<input type="image" name="name" value="value">
</form>
<script>
"use strict";
if (window.location.search.startsWith("?name.x")) {
// The action pointed to ourself, so the form submitted something
window.parent.success(window.location.href);
} else {
const input = document.querySelector("input");
input.click();
}
</script>
...@@ -62,8 +62,8 @@ function startTests() { ...@@ -62,8 +62,8 @@ function startTests() {
state.value = 'normal'; state.value = 'normal';
image.dispatchEvent(clickEvent); image.dispatchEvent(clickEvent);
} else if (query.indexOf('state=normal') != -1) { } else if (query.indexOf('state=normal') != -1) {
// Should have image.x=7&image.y=11. // Should have image.x=7&image.y=11&image=value.
if (query.indexOf('image.x=7&image.y=11') == -1) { if (query.indexOf('image.x=7&image.y=11&image=value') == -1) {
failAndDone('Normal submission failed: ' + query); failAndDone('Normal submission failed: ' + query);
return; return;
} }
...@@ -72,7 +72,7 @@ function startTests() { ...@@ -72,7 +72,7 @@ function startTests() {
state.value = 'click-method'; state.value = 'click-method';
image.click(); image.click();
} else if (query.indexOf('state=click-method') != -1) { } else if (query.indexOf('state=click-method') != -1) {
if (query.indexOf('image.x=0&image.y=0') == -1) { if (query.indexOf('image.x=0&image.y=0&image=value') == -1) {
failAndDone('Click method failed: ' + query); failAndDone('Click method failed: ' + query);
return; return;
} }
...@@ -87,7 +87,7 @@ function startTests() { ...@@ -87,7 +87,7 @@ function startTests() {
return; return;
} }
} else if (query.indexOf('state=keyboard') != -1) { } else if (query.indexOf('state=keyboard') != -1) {
if (query.indexOf('image.x=0&image.y=0') == -1) { if (query.indexOf('image.x=0&image.y=0&image=value') == -1) {
failAndDone('Activating with keyboard failed: ' + query); failAndDone('Activating with keyboard failed: ' + query);
return; return;
} }
...@@ -109,7 +109,7 @@ function startTests() { ...@@ -109,7 +109,7 @@ function startTests() {
eventSender.keyDown('Enter'); eventSender.keyDown('Enter');
} else if (query.indexOf('state=to-image-on-submit') != -1) { } else if (query.indexOf('state=to-image-on-submit') != -1) {
// Should have image.x and image.y, but their values are 0. // Should have image.x and image.y, but their values are 0.
if (query.indexOf('image.x=0&image.y=0') == -1) { if (query.indexOf('image.x=0&image.y=0&image=value') == -1) {
failAndDone('Changing to image on submit failed: ' + query); failAndDone('Changing to image on submit failed: ' + query);
return; return;
} }
...@@ -120,7 +120,7 @@ function startTests() { ...@@ -120,7 +120,7 @@ function startTests() {
image.dispatchEvent(clickEvent); image.dispatchEvent(clickEvent);
} else if (query.indexOf('state=to-image-on-click') != -1) { } else if (query.indexOf('state=to-image-on-click') != -1) {
// Same as the normal submission. // Same as the normal submission.
if (query.indexOf('image.x=7&image.y=11') == -1) { if (query.indexOf('image.x=7&image.y=11&image=value') == -1) {
failAndDone('Changing to image on click failed: ' + query); failAndDone('Changing to image on click failed: ' + query);
return; return;
} }
......
...@@ -73,6 +73,12 @@ void ImageInputType::AppendToFormData(FormData& form_data) const { ...@@ -73,6 +73,12 @@ void ImageInputType::AppendToFormData(FormData& form_data) const {
DEFINE_STATIC_LOCAL(String, dot_y_string, (".y")); DEFINE_STATIC_LOCAL(String, dot_y_string, (".y"));
form_data.append(name + dot_x_string, click_location_.X()); form_data.append(name + dot_x_string, click_location_.X());
form_data.append(name + dot_y_string, click_location_.Y()); form_data.append(name + dot_y_string, click_location_.Y());
if (!GetElement().value().IsEmpty()) {
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kImageInputTypeFormDataWithNonEmptyValue);
form_data.append(name, GetElement().value());
}
} }
String ImageInputType::ResultForDialogSubmit() const { String ImageInputType::ResultForDialogSubmit() const {
......
...@@ -1653,6 +1653,7 @@ enum WebFeature { ...@@ -1653,6 +1653,7 @@ enum WebFeature {
kFeaturePolicyAllowAttributeDeprecatedSyntax = 2145, kFeaturePolicyAllowAttributeDeprecatedSyntax = 2145,
kSuppressHistoryEntryWithoutUserGesture = 2146, kSuppressHistoryEntryWithoutUserGesture = 2146,
kImageInputTypeFormDataWithNonEmptyValue = 2147,
kWebAudioDezipperGainNodeGain = 2148, kWebAudioDezipperGainNodeGain = 2148,
kWebAudioDezipperStereoPannerNodePan = 2149, kWebAudioDezipperStereoPannerNodePan = 2149,
kWebAudioDezipperDelayNodeDelayTime = 2150, kWebAudioDezipperDelayNodeDelayTime = 2150,
......
...@@ -17534,7 +17534,7 @@ Called by update_net_error_codes.py.--> ...@@ -17534,7 +17534,7 @@ Called by update_net_error_codes.py.-->
<int value="2144" label="WebkitBoxLineClampDoesSomething"/> <int value="2144" label="WebkitBoxLineClampDoesSomething"/>
<int value="2145" label="FeaturePolicyAllowAttributeDeprecatedSyntax"/> <int value="2145" label="FeaturePolicyAllowAttributeDeprecatedSyntax"/>
<int value="2146" label="SuppressHistoryEntryWithoutUserGesture"/> <int value="2146" label="SuppressHistoryEntryWithoutUserGesture"/>
<int value="2147" label="OBSOLETE_ImageInputTypeFormDataWithNonEmptyValue"/> <int value="2147" label="ImageInputTypeFormDataWithNonEmptyValue"/>
<int value="2148" label="WebAudioDezipperGainNodeGain"/> <int value="2148" label="WebAudioDezipperGainNodeGain"/>
<int value="2149" label="WebAudioDezipperStereoPannerNodePan"/> <int value="2149" label="WebAudioDezipperStereoPannerNodePan"/>
<int value="2150" label="WebAudioDezipperDelayNodeDelayTime"/> <int value="2150" label="WebAudioDezipperDelayNodeDelayTime"/>
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