XMLHttpRequest-response-is-arraybuffer.html 575 B

123456789101112131415161718
  1. <script src="../include.js"></script>
  2. <script>
  3. asyncTest((done) => {
  4. const xhr = new XMLHttpRequest();
  5. xhr.responseType = "arraybuffer";
  6. xhr.onreadystatechange = async function() {
  7. if (xhr.readyState === 4 && xhr.status === 200) {
  8. if (xhr.response instanceof ArrayBuffer)
  9. println("PASS");
  10. else
  11. println("FAIL");
  12. done();
  13. }
  14. };
  15. xhr.open("GET", "data:text/plain,Hello%20World!", true);
  16. xhr.send();
  17. });
  18. </script>