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 : import { prepare_xhr_for_event_order_test } from './xmlhttprequest-event-order.js?q3';
5 : 1 : import { assert_xhr_event_order_matches } from './xmlhttprequest-event-order.js?q3';
6 : 1 :
7 [ + ]: 1 : export default (activeURL) => {
8 : 1 :
9 : 1 : let xhr = new XMLHttpRequest();
10 : 1 :
11 : 1 : prepare_xhr_for_event_order_test(xhr);
12 : 1 :
13 [ + ]: 1 : xhr.addEventListener('loadend', () => {
14 : 1 : assert_xhr_event_order_matches([
15 : 1 : 1,
16 : 1 : 'loadstart(0,0,false)',
17 : 1 : 'upload.loadstart(0,12,true)',
18 : 1 : 4,
19 : 1 : 'upload.error(0,0,false)',
20 : 1 : 'upload.loadend(0,0,false)',
21 : 1 : 'error(0,0,false)',
22 : 1 : 'loadend(0,0,false)'
23 : 1 : ]);
24 : 1 :
25 : 1 : xhr.onloadend = null;
26 : 1 : });
27 : 1 :
28 : 1 : xhr.open('POST', `http://nonexistent`);
29 : 1 : xhr.send('Test Message');
30 : 1 : }
31 : 1 :
32 : 1 : /*
33 : 1 : * event-error-order.sub.htm
34 : 1 : *
35 : 1 :
36 : 1 : <!DOCTYPE html>
37 : 1 : <html>
38 : 1 : <head>
39 : 1 : <meta name="assert" content="Check the order of events fired when the request has failed.">
40 : 1 : <script src="/resources/testharness.js"></script>
41 : 1 : <script src="/resources/testharnessreport.js"></script>
42 : 1 : <script src="resources/xmlhttprequest-event-order.js"></script>
43 : 1 : <title>XMLHttpRequest: event - error (order of events)</title>
44 : 1 : </head>
45 : 1 :
46 : 1 : <body>
47 : 1 : <div id="log"></div>
48 : 1 :
49 : 1 : <script type="text/javascript">
50 : 1 : var test = async_test();
51 : 1 :
52 : 1 : test.step(function()
53 : 1 : {
54 : 1 : var xhr = new XMLHttpRequest();
55 : 1 : prepare_xhr_for_event_order_test(xhr);
56 : 1 :
57 : 1 : xhr.addEventListener("loadend", function() {
58 : 1 : test.step(function() {
59 : 1 : // no progress events due to CORS failure
60 : 1 : assert_xhr_event_order_matches([1, "loadstart(0,0,false)", "upload.loadstart(0,12,true)", 4, "upload.error(0,0,false)", "upload.loadend(0,0,false)", "error(0,0,false)", "loadend(0,0,false)"]);
61 : 1 : test.done();
62 : 1 : });
63 : 1 : });
64 : 1 :
65 : 1 : xhr.open("POST", "http://nonexistent.{{host}}:{{ports[http][0]}}", true);
66 : 1 : xhr.send("Test Message");
67 : 1 : });
68 : 1 : </script>
69 : 1 : </body>
70 : 1 : </html>
71 : 1 :
72 : 1 : *
73 : 1 : * event-error-order.sub.htm
74 : 1 : */
|