Skip to content

Instantly share code, notes, and snippets.

@KiChjang
Created April 25, 2016 09:15
Show Gist options
  • Save KiChjang/fd225a21b014181ed90b3d9e4ce38737 to your computer and use it in GitHub Desktop.
Save KiChjang/fd225a21b014181ed90b3d9e4ce38737 to your computer and use it in GitHub Desktop.
<!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>",
url: "resources/url-encoded.py"
},
];
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 method=post action=\"" + test_obj.url + "\">" +
test_obj.input +
"</form>";
testframe.onload = function() {
t.step(function (){
var response = testframe.contentWindow.document.documentElement.textContent;
assert_equals(response, "OK");
});
t.done();
run_simple_test();
};
testdocument.getElementById("testform").submit();
}
document.getElementById("testframe").onload = run_simple_test;
</script>
----- PYTHON ---------
def main(request, response):
if request.body == "foo=bara":
return [("Content-Type", "text/plain")], "OK"
else:
return [("Content-Type", "text/plain")], "FAIL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment