mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #7923 - eefriedman:url-encoded-test, r=nox
Add test for URL-encoded form submission. This turned out to be a little more complicated than I was hoping... but I can't really think of a better way to do this. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7923) <!-- Reviewable:end -->
This commit is contained in:
commit
d339d6d3d9
3 changed files with 61 additions and 1 deletions
|
@ -29947,7 +29947,16 @@
|
||||||
},
|
},
|
||||||
"local_changes": {
|
"local_changes": {
|
||||||
"deleted": [],
|
"deleted": [],
|
||||||
"items": {},
|
"items": {
|
||||||
|
"testharness": {
|
||||||
|
"html/semantics/forms/form-submission-0/url-encoded.html": [
|
||||||
|
{
|
||||||
|
"path": "html/semantics/forms/form-submission-0/url-encoded.html",
|
||||||
|
"url": "/html/semantics/forms/form-submission-0/url-encoded.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"reftest_nodes": {}
|
"reftest_nodes": {}
|
||||||
},
|
},
|
||||||
"reftest_nodes": {
|
"reftest_nodes": {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
[url-encoded.html]
|
||||||
|
type: testharness
|
||||||
|
[textarea.simple]
|
||||||
|
expected: FAIL
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<iframe id=testframe src="/common/blank.html"></iframe>
|
||||||
|
<script>
|
||||||
|
var simple_tests = [
|
||||||
|
{
|
||||||
|
name: "text.simple",
|
||||||
|
input: "<input name=foo value=bara>",
|
||||||
|
output: "foo=bara"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "textarea.simple",
|
||||||
|
input: "<textarea name=foo>bar</textarea>",
|
||||||
|
output: "foo=bar"
|
||||||
|
},
|
||||||
|
];
|
||||||
|
simple_tests.forEach(function(test_obj) {
|
||||||
|
test_obj.test = async_test(test_obj.name);
|
||||||
|
});
|
||||||
|
function run_simple_test() {
|
||||||
|
if (simple_tests.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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 action=\"/common/blank.html\">" +
|
||||||
|
test_obj.input +
|
||||||
|
"</form>";
|
||||||
|
testframe.onload = function() {
|
||||||
|
t.step(function (){
|
||||||
|
var get_url = testframe.contentWindow.location.toString();
|
||||||
|
var encoded = get_url.substr(get_url.indexOf("?") + 1);
|
||||||
|
assert_equals(encoded, test_obj.output);
|
||||||
|
});
|
||||||
|
t.done();
|
||||||
|
run_simple_test();
|
||||||
|
};
|
||||||
|
testdocument.getElementById("testform").submit();
|
||||||
|
}
|
||||||
|
document.getElementById("testframe").onload = run_simple_test;
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue