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 : let result = []; 9 : 1 : let expected = [1, 2, 3, 4]; 10 : 1 : 11 [ + ]: 1 : xhr.onreadystatechange = () => { 12 : 4 : result.push(xhr.readyState); 13 : 4 : 14 [ + ]: 4 : if(4 === xhr.readyState){ 15 : 1 : assert.deepStrictEqual(result, expected); 16 : 1 : assert(xhr.responseText === 'top\n'); 17 : 1 : 18 : 1 : xhr.onreadystatechange = null; 19 : 1 : } 20 : 1 : }; 21 : 1 : 22 : 1 : xhr.open('GET', `${activeURL}/folder.txt`); 23 : 1 : xhr.open('GET', `${activeURL.replace('/resources', '') + '/folder.txt'}`); 24 : 1 : 25 : 1 : xhr.send(); 26 : 1 : } 27 : 1 : 28 : 1 : /* 29 : 1 : * open-open-send.htm 30 : 1 : * 31 : 1 : 32 : 1 : <!DOCTYPE html> 33 : 1 : <html> 34 : 1 : <head> 35 : 1 : <title>XMLHttpRequest: open() - open() - send()</title> 36 : 1 : <script src="/resources/testharness.js"></script> 37 : 1 : <script src="/resources/testharnessreport.js"></script> 38 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol/li[14]/ul/li[1] following::ol/li[14]/ul/li[2] following::ol/li[15]/ol/li[1] following::ol/li[15]/ol/li[2]" /> 39 : 1 : </head> 40 : 1 : <body> 41 : 1 : <div id="log"></div> 42 : 1 : <script> 43 : 1 : var test = async_test() 44 : 1 : test.step(function() { 45 : 1 : var client = new XMLHttpRequest(), 46 : 1 : result = [], 47 : 1 : expected = [1,2,3,4] 48 : 1 : client.onreadystatechange = function() { 49 : 1 : test.step(function() { 50 : 1 : result.push(client.readyState) 51 : 1 : if(4 == client.readyState) { 52 : 1 : assert_array_equals(result, expected) 53 : 1 : assert_equals(client.responseText, 'top\n') 54 : 1 : test.done() 55 : 1 : } 56 : 1 : }) 57 : 1 : } 58 : 1 : client.open("GET", "resources/folder.txt") 59 : 1 : client.open("GET", "folder.txt") 60 : 1 : client.send(null) 61 : 1 : }) 62 : 1 : </script> 63 : 1 : </body> 64 : 1 : </html> 65 : 1 : 66 : 1 : * 67 : 1 : * open-open-send.htm 68 : 1 : */