mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #11056 - ConnorGBrewster:formsubmitter_test, r=KiChjang
Added tests for formsubmitter methods Fixes #11047. I decided to add on to the other test since this test would have overlap with testing `encytype` from submitting with various different element. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11056) <!-- Reviewable:end -->
This commit is contained in:
commit
3636b00e6f
1 changed files with 38 additions and 5 deletions
|
@ -5,14 +5,46 @@
|
||||||
<script>
|
<script>
|
||||||
var simple_tests = [
|
var simple_tests = [
|
||||||
{
|
{
|
||||||
name: "form submission should navigate to url with x-www-form-urlencoded",
|
name: "form submission from form should navigate to url with x-www-form-urlencoded",
|
||||||
input: "<input name=foo value=bara>",
|
input: "<input name=foo value=bara>",
|
||||||
enctype: "application/x-www-form-urlencoded"
|
enctype: "application/x-www-form-urlencoded",
|
||||||
|
submitelement: "",
|
||||||
|
submitaction: function(doc) { doc.getElementById("testform").submit(); }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "form submission should navigate to url with multipart/form-data",
|
name: "form submission from form should navigate to url with multipart/form-data",
|
||||||
input: "<textarea name=foo>bar</textarea>",
|
input: "<textarea name=foo>bar</textarea>",
|
||||||
enctype: "multipart/form-data"
|
enctype: "multipart/form-data",
|
||||||
|
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>",
|
||||||
|
enctype: "application/x-www-form-urlencoded",
|
||||||
|
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 multipart/form-data",
|
||||||
|
input: "<textarea name=foo>bar</textarea>",
|
||||||
|
enctype: "multipart/form-data",
|
||||||
|
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>",
|
||||||
|
enctype: "application/x-www-form-urlencoded",
|
||||||
|
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 multipart/form-data",
|
||||||
|
input: "<textarea name=foo>bar</textarea>",
|
||||||
|
enctype: "multipart/form-data",
|
||||||
|
submitelement: "<input id=inputsubmit type=\"submit\">Submit</input>",
|
||||||
|
submitaction: function(doc) { doc.getElementById("inputsubmit").click(); }
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
simple_tests.forEach(function(test_obj) {
|
simple_tests.forEach(function(test_obj) {
|
||||||
|
@ -29,6 +61,7 @@ function run_simple_test() {
|
||||||
testdocument.body.innerHTML =
|
testdocument.body.innerHTML =
|
||||||
"<form id=testform method=post action=\"form-submission.py\" enctype=\"" + test_obj.enctype + "\">" +
|
"<form id=testform method=post action=\"form-submission.py\" enctype=\"" + test_obj.enctype + "\">" +
|
||||||
test_obj.input +
|
test_obj.input +
|
||||||
|
test_obj.submitelement +
|
||||||
"</form>";
|
"</form>";
|
||||||
testframe.onload = function() {
|
testframe.onload = function() {
|
||||||
t.step(function (){
|
t.step(function (){
|
||||||
|
@ -38,7 +71,7 @@ function run_simple_test() {
|
||||||
t.done();
|
t.done();
|
||||||
run_simple_test();
|
run_simple_test();
|
||||||
};
|
};
|
||||||
testdocument.getElementById("testform").submit();
|
test_obj.submitaction(testdocument);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<iframe id=testframe src="/common/blank.html" onload="run_simple_test();"></iframe>
|
<iframe id=testframe src="/common/blank.html" onload="run_simple_test();"></iframe>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue