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 : xhr.onreadystatechange = () => { 9 : 1 : 10 [ - ]: 1 : if(xhr.readyState === 3){ 11 : 0 : assert.strictEqual(xhr.response, ''); 12 : 0 : } 13 : 1 : else 14 [ - ]: 1 : if(xhr.readyState === 4){ 15 : 0 : assert(false, 'loadstart event did not fire in LOADING state!'); 16 : 0 : } 17 : 1 : 18 : 1 : }; 19 : 1 : 20 [ + ]: 1 : xhr.onloadstart = () => { 21 : 1 : xhr.onreadystatechange = null; 22 : 1 : }; 23 : 1 : 24 : 1 : xhr.open('POST', `${activeURL}/content.py`, true); 25 : 1 : xhr.send(); 26 : 1 : } 27 : 1 : 28 : 1 : /* 29 : 1 : * send-no-response-event-loadstart.htm 30 : 1 : * 31 : 1 : 32 : 1 : <!DOCTYPE html> 33 : 1 : <html> 34 : 1 : <head> 35 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-onloadstart" data-tested-assertations="/../.." /> 36 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#event-xhr-loadstart" data-tested-assertations="/../.." /> 37 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="/following-sibling::ol/li[9]/ol/li[2]" /> 38 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#the-response-attribute" data-tested-assertations="/following-sibling::ol/li[1]" /> 39 : 1 : <script src="/resources/testharness.js"></script> 40 : 1 : <script src="/resources/testharnessreport.js"></script> 41 : 1 : <title>XMLHttpRequest: The send() method: Fire a progress event named loadstart (no response entity body and the state is LOADING)</title> 42 : 1 : </head> 43 : 1 : 44 : 1 : <body> 45 : 1 : <div id="log"></div> 46 : 1 : 47 : 1 : <script type="text/javascript"> 48 : 1 : var test = async_test(); 49 : 1 : 50 : 1 : test.step(function() 51 : 1 : { 52 : 1 : var xhr = new XMLHttpRequest(); 53 : 1 : 54 : 1 : xhr.onreadystatechange = function() 55 : 1 : { 56 : 1 : test.step(function() 57 : 1 : { 58 : 1 : if (xhr.readyState == 3) 59 : 1 : { 60 : 1 : assert_equals(xhr.response, ""); 61 : 1 : } 62 : 1 : else if (xhr.readyState == 4) 63 : 1 : { 64 : 1 : assert_unreached("loadstart event did not fire in LOADING state!"); 65 : 1 : } 66 : 1 : }); 67 : 1 : }; 68 : 1 : 69 : 1 : xhr.onloadstart = function() 70 : 1 : { 71 : 1 : test.step(function() { test.done("Test done!"); }); 72 : 1 : }; 73 : 1 : 74 : 1 : xhr.open("POST", "./resources/content.py", true); 75 : 1 : xhr.send(); 76 : 1 : }); 77 : 1 : </script> 78 : 1 : </body> 79 : 1 : </html> 80 : 1 : 81 : 1 : * 82 : 1 : * send-no-response-event-loadstart.htm 83 : 1 : */