send-redirect-no-location.htm (1490B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>XMLHttpRequest: send() - Redirects (no Location header)</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following::dl[1]/dt[2]" /> 8 <!-- 9 NOTE: the XHR spec does not really handle this scenario. It's handled in the Fetch spec: 10 "If response's headers do not contain a header whose name is Location, return response." 11 --> 12 </head> 13 <body> 14 <div id="log"></div> 15 <script> 16 function redirect(code) { 17 var test = async_test(document.title + " (" + code + ")") 18 test.step(function() { 19 var client = new XMLHttpRequest() 20 client.onreadystatechange = function() { 21 test.step(function() { 22 if(client.readyState == 4) { 23 assert_equals(client.status + "", code) 24 assert_equals(client.statusText, "ABE ODDYSSEE") 25 assert_equals(client.responseXML.documentElement.localName, "x") 26 test.done() 27 } 28 }) 29 } 30 client.open("GET", "resources/status.py?content=<x>x<\/x>&type=text/xml&text=ABE ODDYSSEE&code=" + code) 31 client.send(null) 32 }) 33 } 34 redirect("301") 35 redirect("302") 36 redirect("303") 37 redirect("307") 38 </script> 39 </body> 40 </html>