| Anne van Kesteren | 66b5417 | 2010-08-11 18:02:17 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>XMLHttpRequest: send() - conditional requests</title> |
| 5 | <script src="/resources/testharness.js"></script> |
| Ms2ger | 6f083e7 | 2012-08-05 08:38:14 | [diff] [blame] | 6 | <script src="/resources/testharnessreport.js"></script> |
| Ms2ger | 91fef14 | 2014-11-01 09:24:37 | [diff] [blame] | 7 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::code[contains(text(),'Modified')]/.." /> |
| Anne van Kesteren | 66b5417 | 2010-08-11 18:02:17 | [diff] [blame] | 8 | </head> |
| 9 | <body> |
| 10 | <div id="log"></div> |
| 11 | <script> |
| 12 | function request(type) { |
| 13 | test(function() { |
| 14 | var client = new XMLHttpRequest, |
| 15 | identifier = type == "tag" ? Math.random() : new Date().toGMTString(), |
| James Graham | 234a672 | 2013-09-17 17:54:38 | [diff] [blame] | 16 | url = "resources/conditional.py?" + type + "=" + identifier |
| Anne van Kesteren | 66b5417 | 2010-08-11 18:02:17 | [diff] [blame] | 17 | client.open("GET", url, false) |
| 18 | client.send(null) |
| 19 | assert_equals(client.status, 200) |
| 20 | assert_equals(client.statusText, "OK") |
| 21 | assert_equals(client.responseText, "MAYBE NOT") |
| 22 | client.open("GET", url, false) |
| 23 | client.setRequestHeader(type == "tag" ? "If-None-Match" : "If-Modified-Since", identifier) |
| 24 | client.send(null) |
| 25 | assert_equals(client.status, 304) |
| 26 | assert_equals(client.statusText, "SUPERCOOL") |
| 27 | assert_equals(client.responseText, "") |
| 28 | }, document.title + " (" + type + ")") |
| 29 | } |
| 30 | request("tag") |
| 31 | request("date") |
| 32 | </script> |
| 33 | </body> |
| 34 | </html> |