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 : import { ProgressEvent } from '../../../lib/whatwg-xhr.js'; 4 : 1 : 5 [ + ]: 1 : export default (activeURL) => { 6 : 1 : 7 : 1 : let xhr = new XMLHttpRequest(); 8 : 1 : 9 [ + ]: 1 : xhr.upload.onloadend = (e) => { 10 : 1 : 11 : 1 : assert(e instanceof ProgressEvent); 12 : 1 : assert(e.type === 'loadend'); 13 : 1 : assert(e.target === xhr.upload); 14 : 1 : }; 15 : 1 : 16 : 1 : xhr.open('POST', `${activeURL}/content.py`); 17 : 1 : xhr.send('Test Message'); 18 : 1 : } 19 : 1 : 20 : 1 : /* 21 : 1 : * send-response-upload-event-loadend.mjs 22 : 1 : * 23 : 1 : 24 : 1 : <!DOCTYPE html> 25 : 1 : <html> 26 : 1 : <head> 27 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-onloadend" data-tested-assertations="../.." /> 28 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#event-xhr-loadend" data-tested-assertations="../.." /> 29 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::a[contains(@href,'#make-upload-progress-notifications')]/.. following::ol[1]/li[8]" /> 30 : 1 : <link rel="help" href="https://xhr.spec.whatwg.org/#make-upload-progress-notifications" data-tested-assertations="following::ul[1]/li[2]/ol[1]/li[4]" /> 31 : 1 : 32 : 1 : <script src="/resources/testharness.js"></script> 33 : 1 : <script src="/resources/testharnessreport.js"></script> 34 : 1 : <title>XMLHttpRequest: The send() method: Fire a progress event named loadend on the XMLHttpRequestUpload (synchronous flag is unset)</title> 35 : 1 : </head> 36 : 1 : 37 : 1 : <body> 38 : 1 : <div id="log"></div> 39 : 1 : 40 : 1 : <script type="text/javascript"> 41 : 1 : var test = async_test(); 42 : 1 : 43 : 1 : test.step(function() 44 : 1 : { 45 : 1 : var xhr = new XMLHttpRequest(); 46 : 1 : 47 : 1 : xhr.upload.onloadend = function(e) 48 : 1 : { 49 : 1 : test.step(function() 50 : 1 : { 51 : 1 : assert_true(e instanceof ProgressEvent); 52 : 1 : assert_equals(e.type, "loadend"); 53 : 1 : assert_equals(e.target, xhr.upload); 54 : 1 : test.done(); 55 : 1 : }); 56 : 1 : }; 57 : 1 : 58 : 1 : xhr.open("POST", "./resources/content.py", true); 59 : 1 : xhr.send("Test Message"); 60 : 1 : }); 61 : 1 : </script> 62 : 1 : </body> 63 : 1 : </html> 64 : 1 : 65 : 1 : * 66 : 1 : * send-response-upload-event-loadend.mjs 67 : 1 : */