OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <title>Revoking blob URL used with XMLHttpRequest</title> | 2 <title>Revoking blob URL used with XMLHttpRequest</title> |
3 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
4 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
5 | 5 |
6 <script> | 6 <script> |
7 async_test(function(t) { | 7 async_test(function(t) { |
8 var blob = new Blob(["test"]); | 8 var blob = new Blob(["test"]); |
9 var url = URL.createObjectURL(blob); | 9 var url = URL.createObjectURL(blob); |
10 var xhr = new XMLHttpRequest(); | 10 var xhr = new XMLHttpRequest(); |
11 xhr.open("GET", url); | 11 xhr.open("GET", url); |
12 | 12 |
13 // Revoke the object URL. XHR should take a reference to the blob as soon a
s | 13 // Revoke the object URL. XHR should take a reference to the blob as soon a
s |
14 // it receives it in open(), so the request succeeds even though we revoke t
he | 14 // it receives it in open(), so the request succeeds even though we revoke t
he |
15 // URL before calling send(). | 15 // URL before calling send(). |
16 URL.revokeObjectURL(url); | 16 URL.revokeObjectURL(url); |
17 | 17 |
18 xhr.send(); | 18 xhr.send(); |
19 | 19 |
20 xhr.onload = t.step_func(function() { | 20 xhr.onload = t.step_func_done(function() { |
21 assert_equals(xhr.response, "test"); | 21 assert_equals(xhr.response, "test"); |
22 t.done(); | |
23 }) | 22 }) |
24 xhr.onerror = t.step_func(function() { | 23 xhr.onerror = t.step_func(function() { |
25 assert_unreached("Got unexpected error event"); | 24 assert_unreached("Got unexpected error event"); |
26 }) | 25 }) |
27 }); | 26 }, "Revoke blob URL after open(), will fetch"); |
28 </script> | 27 |
| 28 async_test(t => { |
| 29 const blob = new Blob(["test"]), |
| 30 blobURL = URL.createObjectURL(blob), |
| 31 client = new XMLHttpRequest |
| 32 URL.revokeObjectURL(blobURL) |
| 33 client.open("GET", blobURL) |
| 34 client.onload = t.step_func(() => assert_unreached("Got unexpected load event"
)) |
| 35 client.onerror = t.step_func_done() |
| 36 client.send() |
| 37 }, "Revoke blob URL before open(), network error (after send())") |
| 38 </script> |
OLD | NEW |