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