test_performance_aborted_status.html (1675B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test for Bug 1916356</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 </head> 8 <body> 9 <script> 10 SimpleTest.waitForExplicitFinish(); 11 12 (async () => { 13 // server.sjs?slow doesn't respond, which results in the 14 // HttpBaseChannel::mResponseHead being nullptr. 15 const slowXHR = new XMLHttpRequest(); 16 slowXHR.open("GET", "server.sjs?slow"); 17 slowXHR.send(); 18 19 // server.sjs?fast quickly responds. 20 // Perform this and wait for the load, in order to ensure the 21 // network requests performed there reaches necko and the 22 // corresponding resource entry is created for server.sjs?slow as well. 23 const fastXHR = new XMLHttpRequest(); 24 fastXHR.open("GET", "server.sjs?fast"); 25 const fastLoadPromise = new Promise(resolve => { 26 fastXHR.addEventListener("load", resolve); 27 }); 28 fastXHR.send(); 29 await fastLoadPromise; 30 31 const slowEntryPromise = new Promise(resolve => { 32 new PerformanceObserver(list => { 33 const entries = list.getEntries(); 34 for (const entry of entries) { 35 if (entry.name.includes("server.sjs?slow")) { 36 resolve(entry); 37 } 38 } 39 }).observe({ entryTypes: [ "resource" ] }); 40 }); 41 42 slowXHR.abort(); 43 44 const slowEntry = await slowEntryPromise; 45 is(slowEntry.responseStatus, 0, 46 "responseStatus for the request with no response should be 0"); 47 48 SimpleTest.finish(); 49 })(); 50 </script> 51 </body> 52 </html>