Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: LayoutTests/fast/forms/submit-add-remove-element.html

Issue 449823003: Form submitted from JS should not submit double values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/forms/submit-add-remove-element-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/forms/submit-add-remove-element.html
diff --git a/LayoutTests/fast/forms/submit-add-remove-element.html b/LayoutTests/fast/forms/submit-add-remove-element.html
new file mode 100644
index 0000000000000000000000000000000000000000..c54f4a335d592de11618f9e9d25fa602131eb59c
--- /dev/null
+++ b/LayoutTests/fast/forms/submit-add-remove-element.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<form method="GET" id="form" onsubmit="formSubmit();afterSubmit(form);" target="target">
+ <input type="text" id="textData" name="textData" value="a">
+ <input type="submit" id="submitButton" name="submitform" value="Step">
+</form>
+<iframe id="target" name="target"></iframe>
+<script>
+description('Test that form.submit() when submitted from JS, form element added and removed, should submit the form without added element');
+
+var hidden;
+function formSubmit(event)
+{
+ var textData = document.getElementById('textData');
+ var form = document.getElementById('form');
+ var submit = document.getElementById('submitButton');
+ textData.value = 'b';
+ hidden = document.createElement('hidden');
+ hidden.value = submit.value;
+ hidden.name = submit.name;
+ form.appendChild(hidden);
+ form.submit();
+ return true;
+}
+
+function afterSubmit(form)
+{
+ form.removeChild(hidden);
+}
+
+document.getElementById('target').onload = function(event) {
+ shouldBeEqualToString('event.target.contentWindow.location.search', '?textData=b&submitform=Step');
+ finishJSTest();
+}
tkent 2014/08/08 00:49:33 nit: Need ';' because this is substitution express
+
+window.onload = function() {
+ document.getElementById('submitButton').click();
+}
tkent 2014/08/08 00:49:32 Ditto.
+
+if (window.testRunner)
+ window.jsTestIsAsync = true;
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/forms/submit-add-remove-element-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698