Branch data Line data Source code
1 [ + ]: 1 : import assert from 'node:assert/strict'; 2 : 1 : import { XMLHttpRequest } from '../../../lib/whatwg-xhr.js'; 3 : 1 : 4 [ + ]: 1 : export default (activeURL) => { 5 : 1 : 6 : 1 : let xhr = new XMLHttpRequest(); 7 : 1 : 8 : 1 : assert.strictEqual(xhr.getAllResponseHeaders(), ''); 9 : 1 : 10 [ + ]: 1 : xhr.onreadystatechange = () => { 11 : 4 : let headers = xhr.getAllResponseHeaders().toLowerCase(); 12 : 4 : 13 [ + ]: 4 : if(xhr.readyState === 1){ 14 : 1 : assert.strictEqual(headers, ''); 15 : 1 : } 16 : 4 : 17 [ + ]: 4 : if(xhr.readyState > 1){ 18 : 3 : assert(headers.indexOf('200 ok') === -1); 19 : 3 : assert(headers.indexOf('http/1.') === -1); 20 : 3 : } 21 : 4 : 22 : 4 : if(xhr.readyState === 4) 23 [ + ]: 4 : assert(true); 24 : 1 : }; 25 : 1 : 26 : 1 : xhr.open('GET', `${activeURL}/headers.py`); 27 : 1 : xhr.send(); 28 : 1 : } 29 : 1 : 30 : 1 : /* 31 : 1 : * getallresponseheaders-status.htm 32 : 1 : * 33 : 1 : 34 : 1 : <!DOCTYPE html> 35 : 1 : <html> 36 : 1 : <head> 37 : 1 : <title>XMLHttpRequest: getAllResponseHeaders() excludes status</title> 38 : 1 : <script src="/resources/testharness.js"></script> 39 : 1 : <script src="/resources/testharnessreport.js"></script> 40 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-getallresponseheaders" data-tested-assertations="/following::OL[1]/LI[1] /following::OL[1]/LI[3]" /> 41 : 1 : </head> 42 : 1 : <body> 43 : 1 : <div id="log"></div> 44 : 1 : <script> 45 : 1 : async_test(function() { 46 : 1 : var client = new XMLHttpRequest() 47 : 1 : assert_equals(client.getAllResponseHeaders(), "") 48 : 1 : 49 : 1 : client.onreadystatechange = this.step_func(function() { 50 : 1 : var headers = client.getAllResponseHeaders().toLowerCase() 51 : 1 : if(client.readyState == 1) { 52 : 1 : assert_equals(headers, "") 53 : 1 : } 54 : 1 : if(client.readyState > 1) { 55 : 1 : assert_false(headers.indexOf("200 ok") != -1) 56 : 1 : assert_false(headers.indexOf("http/1.") != -1) 57 : 1 : } 58 : 1 : if(client.readyState == 4) 59 : 1 : this.done() 60 : 1 : }) 61 : 1 : client.open("GET", "resources/headers.py") 62 : 1 : client.send(null) 63 : 1 : }) 64 : 1 : </script> 65 : 1 : </body> 66 : 1 : </html> 67 : 1 : 68 : 1 : * 69 : 1 : * getallresponseheaders-status.htm 70 : 1 : */