send-authentication-basic-cors.htm (1573B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>XMLHttpRequest: send() - "Basic" authenticated CORS requests with user name and password passed to open() (asserts failure)</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/#the-open()-method" data-tested-assertations="following::ol[1]/li[9]/ol[1]/li[1] following::ol[1]/li[9]/ol[1]/li[2]" /> 8 <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::code[contains(@title,'http-authorization')]/.." /> 9 </head> 10 <body> 11 <div id="log"></div> 12 <script> 13 var test = async_test() 14 test.step(function() { 15 var client = new XMLHttpRequest(), 16 urlstart = 'www1.'+location.host + location.pathname.replace(/\/[^\/]*$/, '/') 17 client.withCredentials = true 18 client.open("GET", location.protocol+'//'+urlstart + "resources/auth1/corsenabled.py", true, 'user', 'pass') 19 client.setRequestHeader("x-user", 'user') 20 client.setRequestHeader("x-pass", 'pass') 21 client.onreadystatechange = function(){ 22 if (client.readyState === 4) { 23 test.step(function(){ 24 assert_equals(client.responseText, '') 25 assert_equals(client.status, 0) 26 assert_equals(client.getResponseHeader('x-challenge'), null) 27 test.done() 28 }) 29 } 30 } 31 client.send(null) 32 }, document.title) 33 </script> 34 </body> 35 </html>