| <!doctype html> |
| <title>Revoking blob URL used with XMLHttpRequest</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| |
| <script> |
| async_test(function(t) { |
| var blob = new Blob(["test"]); |
| var url = URL.createObjectURL(blob); |
| var xhr = new XMLHttpRequest(); |
| xhr.open("GET", url); |
| |
| // Revoke the object URL. XHR should take a reference to the blob as soon as |
| // it receives it in open(), so the request succeeds even though we revoke the |
| // URL before calling send(). |
| URL.revokeObjectURL(url); |
| |
| xhr.send(); |
| |
| xhr.onload = t.step_func_done(function() { |
| assert_equals(xhr.response, "test"); |
| }) |
| xhr.onerror = t.step_func(function() { |
| assert_unreached("Got unexpected error event"); |
| }) |
| }, "Revoke blob URL after open(), will fetch"); |
| |
| async_test(t => { |
| const blob = new Blob(["test"]), |
| blobURL = URL.createObjectURL(blob), |
| client = new XMLHttpRequest |
| URL.revokeObjectURL(blobURL) |
| client.open("GET", blobURL) |
| client.onload = t.step_func(() => assert_unreached("Got unexpected load event")) |
| client.onerror = t.step_func_done() |
| client.send() |
| }, "Revoke blob URL before open(), network error (after send())") |
| </script> |