Add tests for submit entity body

This commit is contained in:
Keith Yeung 2016-04-25 05:40:54 -04:00
parent 16361086d9
commit e1091128cd
3 changed files with 62 additions and 0 deletions

View file

@ -35264,6 +35264,12 @@
"path": "html/dom/documents/dom-tree-accessors/Document.body.html", "path": "html/dom/documents/dom-tree-accessors/Document.body.html",
"url": "/html/dom/documents/dom-tree-accessors/Document.body.html" "url": "/html/dom/documents/dom-tree-accessors/Document.body.html"
} }
],
"html/semantics/forms/form-submission-0/submit-entity-body.html": [
{
"path": "html/semantics/forms/form-submission-0/submit-entity-body.html",
"url": "/html/semantics/forms/form-submission-0/submit-entity-body.html"
}
] ]
} }
}, },

View file

@ -0,0 +1,12 @@
def main(request, response):
if request.headers.get('Content-Type') == 'application/x-www-form-urlencoded':
if request.body == 'foo=bara':
return 'OK'
else:
return 'FAIL'
else:
if request.POST.first('foo') == 'bar':
return 'OK'
else:
return 'FAIL'

View file

@ -0,0 +1,44 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var simple_tests = [
{
name: "form submission should navigate to url with x-www-form-urlencoded",
input: "<input name=foo value=bara>",
enctype: "application/x-www-form-urlencoded"
},
{
name: "form submission should navigate to url with multipart/form-data",
input: "<textarea name=foo>bar</textarea>",
enctype: "multipart/form-data"
},
];
simple_tests.forEach(function(test_obj) {
test_obj.test = async_test(test_obj.name);
});
function run_simple_test() {
if (simple_tests.length == 0) {
return;
}
var test_obj = simple_tests.pop();
var t = test_obj.test;
var testframe = document.getElementById("testframe");
var testdocument = testframe.contentWindow.document;
testdocument.body.innerHTML =
"<form id=testform method=post action=\"form-submission.py\" enctype=\"" + test_obj.enctype + "\">" +
test_obj.input +
"</form>";
testframe.onload = function() {
t.step(function (){
var response = testframe.contentDocument.documentElement.textContent;
assert_equals(response, "OK");
});
t.done();
run_simple_test();
};
testdocument.getElementById("testform").submit();
}
</script>
<iframe id=testframe src="/common/blank.html" onload="run_simple_test();"></iframe>