Add test for encoding text/plain in forms

This commit is contained in:
Keith Yeung 2016-05-01 03:13:42 -04:00
parent d1c0af9ae7
commit 5e078870a2
2 changed files with 26 additions and 0 deletions

View file

@ -4,6 +4,11 @@ def main(request, response):
return 'OK'
else:
return 'FAIL'
elif request.headers.get('Content-Type') == 'text/plain':
if request.body == 'qux=baz\r\n':
return 'OK'
else:
return 'FAIL'
else:
if request.POST.first('foo') == 'bar':
return 'OK'

View file

@ -18,6 +18,13 @@ var simple_tests = [
submitelement: "",
submitaction: function(doc) { doc.getElementById("testform").submit(); }
},
{
name: "form submission from form should navigate to url with text/plain",
input: "<textarea name=qux>baz</textarea>",
enctype: "text/plain",
submitelement: "",
submitaction: function(doc) { doc.getElementById("testform").submit(); }
},
{
name: "form submission from button should navigate to url with x-www-form-urlencoded",
input: "<input name=foo value=bara>",
@ -32,6 +39,13 @@ var simple_tests = [
submitelement: "<button id=buttonsubmit type=\"submit\">Submit</button>",
submitaction: function(doc) { doc.getElementById("buttonsubmit").click(); }
},
{
name: "form submission from button should navigate to url with text/plain",
input: "<textarea name=qux>baz</textarea>",
enctype: "text/plain",
submitelement: "<button id=buttonsubmit type=\"submit\">Submit</button>",
submitaction: function(doc) { doc.getElementById("buttonsubmit").click(); }
},
{
name: "form submission from input should navigate to url with x-www-form-urlencoded",
input: "<input name=foo value=bara>",
@ -46,6 +60,13 @@ var simple_tests = [
submitelement: "<input id=inputsubmit type=\"submit\">Submit</input>",
submitaction: function(doc) { doc.getElementById("inputsubmit").click(); }
},
{
name: "form submission from input should navigate to url with text/plain",
input: "<input name=qux value=baz>",
enctype: "text/plain",
submitelement: "<input id=inputsubmit type=\"submit\">Submit</input>",
submitaction: function(doc) { doc.getElementById("inputsubmit").click(); }
}
];
simple_tests.forEach(function(test_obj) {
test_obj.test = async_test(test_obj.name);