1 <html> 2 <head> 3 <script> 4 var xhr = new XMLHttpRequest(); 5 xhr.open("HEAD", "nothing.txt", true); 6 xhr.onreadystatechange = function() { 7 if (xhr.readyState != 4) { 8 return; 9 } 10 if (xhr.status == 404) { 11 alert("PASSED: onreadystatechange fired with status 404"); 12 } else { 13 alert("FAILED: onreadystatechange fired with status " + xhr.status); 14 } 15 16 } 17 xhr.onerror = function() { 18 alert("FAILED: onerror fired"); 19 } 20 xhr.send(); 21 </script> 22 </head> 23 <body> 24 <p>This test must be hosted on a web server, not run from a file url, because XMLHttpRequest from file url causes a security error.</p> 25 <p>You should see an alert box saying whether the test was passed or failed. If there is no alert box, the test was FAILED.</p> 26 </body> 27 </html> 28