Commit 8d0135f1 authored by Shanmuga Pandi M's avatar Shanmuga Pandi M Committed by Commit Bot

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

This patch will show deprecate warning for the extra form data which was 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: I565132d6ef8c6d4a93ce5447e5d18d7f7f8c1910
Reviewed-on: https://chromium-review.googlesource.com/896740Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Shanmuga Pandi <shanmuga.m@samsung.com>
Cr-Commit-Position: refs/heads/master@{#534004}
parent b8c77d9b
This is a testharness.js-based test.
FAIL Image submit button should not add extra form data if 'value' attribute is present with non-empty value assert_equals: expected "http://web-platform.test:8001/html/semantics/forms/the-input-element/resources/image-submit-click.html?name.x=0&name.y=0" but got "http://web-platform.test:8001/html/semantics/forms/the-input-element/resources/image-submit-click.html?name.x=0&name.y=0&name=value"
Harness: the test ran to completion.
<!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>
\ No newline at end of file
<!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>
\ No newline at end of file
CONSOLE WARNING: line 63: Extra form data if value attribute is present with non-empty value for <input type='image'> is deprecated and will be removed in M68, around July 2018. See https://www.chromestatus.com/features/5672688152477696 for more details.
CONSOLE WARNING: line 73: Extra form data if value attribute is present with non-empty value for <input type='image'> is deprecated and will be removed in M68, around July 2018. See https://www.chromestatus.com/features/5672688152477696 for more details.
CONSOLE WARNING: line 84: Extra form data if value attribute is present with non-empty value for <input type='image'> is deprecated and will be removed in M68, around July 2018. See https://www.chromestatus.com/features/5672688152477696 for more details.
CONSOLE WARNING: line 109: Extra form data if value attribute is present with non-empty value for <input type='image'> is deprecated and will be removed in M68, around July 2018. See https://www.chromestatus.com/features/5672688152477696 for more details.
CONSOLE WARNING: line 120: Extra form data if value attribute is present with non-empty value for <input type='image'> is deprecated and will be removed in M68, around July 2018. See https://www.chromestatus.com/features/5672688152477696 for more details.
PASS successfullyParsed is true
......
......@@ -623,6 +623,13 @@ DeprecationInfo GetDeprecationInfo(WebFeature feature) {
replacedWillBeRemoved("Expressing a position using 3 parts",
"<position> syntax", M68, "5116559680864256")};
case WebFeature::kImageInputTypeFormDataWithNonEmptyValue:
return {"ImageInputTypeFormDataWithNonEmptyValue", M68,
willBeRemoved("Extra form data if value attribute "
"is present with non-empty "
"value for <input type='image'>",
M68, "5672688152477696")};
// Features that aren't deprecated don't have a deprecation message.
default:
return {"NotDeprecated", Unknown, ""};
......
......@@ -26,6 +26,7 @@
#include "core/dom/ShadowRoot.h"
#include "core/dom/SyncReattachContext.h"
#include "core/events/MouseEvent.h"
#include "core/frame/Deprecation.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLImageFallbackHelper.h"
#include "core/html/HTMLImageLoader.h"
......@@ -75,7 +76,8 @@ void ImageInputType::AppendToFormData(FormData& form_data) const {
form_data.append(name + dot_y_string, click_location_.Y());
if (!GetElement().value().IsEmpty()) {
UseCounter::Count(GetElement().GetDocument(),
Deprecation::CountDeprecation(
GetElement().GetDocument(),
WebFeature::kImageInputTypeFormDataWithNonEmptyValue);
form_data.append(name, GetElement().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