| Hallvord Reiar M. Steen | 2ac0130 | 2013-07-03 14:15:36 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>XMLHttpRequest: send() - "Basic" authenticated requests with user name and password passed to open() in first request, without in second</title> |
| 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| James Graham | 234a672 | 2013-09-17 17:54:38 | [diff] [blame] | 7 | <script src="/common/utils.js"></script> |
| Ms2ger | 91fef14 | 2014-11-01 09:24:37 | [diff] [blame] | 8 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol[1]/li[9]/ol[1]/li[1] following::ol[1]/li[9]/ol[1]/li[2]" /> |
| 9 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::code[contains(@title,'http-authorization')]/.." /> |
| Hallvord Reiar M. Steen | 2ac0130 | 2013-07-03 14:15:36 | [diff] [blame] | 10 | </head> |
| 11 | <body> |
| 12 | <div id="log"></div> |
| 13 | <script> |
| 14 | test(function() { |
| 15 | var client = new XMLHttpRequest(), |
| James Graham | 234a672 | 2013-09-17 17:54:38 | [diff] [blame] | 16 | urlstart = location.host + location.pathname.replace(/\/[^\/]*$/, '/'), |
| 17 | user = token() |
| 18 | client.open("GET", location.protocol+'//'+urlstart + "resources/auth1/auth.py", false, user, 'pass') |
| 19 | client.setRequestHeader("x-user", user) |
| Hallvord Reiar M. Steen | 2ac0130 | 2013-07-03 14:15:36 | [diff] [blame] | 20 | client.send(null) |
| 21 | // Repeat request but *without* credentials in the open() call. |
| 22 | // Is the UA supposed to cache credentials from above request and use them? Yes. |
| James Graham | 234a672 | 2013-09-17 17:54:38 | [diff] [blame] | 23 | client.open("GET", location.protocol+'//'+urlstart + "resources/auth1/auth.py", false) |
| 24 | client.setRequestHeader("x-user", user) |
| Hallvord Reiar M. Steen | 2ac0130 | 2013-07-03 14:15:36 | [diff] [blame] | 25 | client.send(null) |
| 26 | |
| James Graham | 234a672 | 2013-09-17 17:54:38 | [diff] [blame] | 27 | assert_equals(client.responseText, user + "\n" + 'pass') |
| Hallvord Reiar M. Steen | 826e780 | 2013-07-03 15:09:07 | [diff] [blame] | 28 | //assert_equals(client.getResponseHeader('x-challenge'), 'DID-NOT') |
| Hallvord Reiar M. Steen | 2ac0130 | 2013-07-03 14:15:36 | [diff] [blame] | 29 | |
| 30 | }, document.title) |
| 31 | </script> |
| 32 | </body> |
| 33 | </html> |