Skip to content

Commit

Permalink
Add WPT test for 302 Found
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Oct 15, 2018
1 parent 3b1bfa3 commit 65016d1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/wpt/metadata/MANIFEST.json
Expand Up @@ -282894,6 +282894,11 @@
{}
]
],
"fetch/redirect-navigate/302-found-post-handler.py": [
[
{}
]
],
"fetch/sec-metadata/README.md": [
[
{}
Expand Down Expand Up @@ -359037,6 +359042,12 @@
{}
]
],
"fetch/redirect-navigate/302-found-post.html": [
[
"/fetch/redirect-navigate/302-found-post.html",
{}
]
],
"fetch/sec-metadata/embed.tentative.https.sub.html": [
[
"/fetch/sec-metadata/embed.tentative.https.sub.html",
Expand Down Expand Up @@ -601108,6 +601119,14 @@
"faaee86734e93bb514095e34671a57e00bcbcd98",
"testharness"
],
"fetch/redirect-navigate/302-found-post-handler.py": [
"23bf4b2c522b7c00ab6bd0fc3eb99f0737d512ec",
"support"
],
"fetch/redirect-navigate/302-found-post.html": [
"854cd329a8f12052bb79f35dd80268f246a52afd",
"testharness"
],
"fetch/sec-metadata/README.md": [
"c460aa1ecb941118b6999209ba4601eb145a61b9",
"support"
Expand Down
@@ -0,0 +1,13 @@
def main(request, response):
if request.method == "POST":
response.add_required_headers = False
response.writer.write_status(302)
response.writer.write_header("Location", request.url)
response.writer.end_headers()
response.writer.write("")
elif request.method == "GET":
return ([("Content-Type", "text/plain")],
"OK")
else:
return ([("Content-Type", "text/plain")],
"FAIL")
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<!-- Step 1: send POST request to a URL which will then 302 Found redirect -->
<title>HTTP 302 Found POST Navigation Test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
window.addEventListener("load", function() {
var frame = document.getElementById("frame");
var link = new URL("302-found-post-handler.py", window.location.href);
frame.contentWindow.document.body.innerHTML = '<form action="' + link.href + '" method="POST" id="form"><input name="n"></form>';
frame.contentWindow.document.getElementById("form").submit();
frame.addEventListener("load", t.step_func_done(function() {
assert_equals(frame.contentWindow.document.body.textContent, "OK");
}));
});
}, "HTTP 302 Found POST Navigation");
</script>
<body>
<iframe id="frame" src="about:blank"></iframe>

0 comments on commit 65016d1

Please sign in to comment.