OLD | NEW |
---|---|
(Empty) | |
1 <!doctype html> | |
2 <script src="../../resources/js-test.js"></script> | |
3 <script src="resources/read-common.js"></script> | |
4 <script> | |
5 description("Test the Blob.close() method, revoking."); | |
6 | |
7 window.jsTestIsAsync = true; | |
8 | |
9 function base64ToUint8Array(a) | |
10 { | |
11 var binary = window.atob(a); | |
12 var buffer = new Uint8Array(binary.length); | |
13 for (var i = 0; i < binary.length; i++) | |
14 buffer[i] = binary.charCodeAt(i); | |
15 | |
16 return buffer; | |
17 } | |
18 | |
19 var pngBase64 = "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAAsTAAA LEwEAmpwYAAAAnklEQVR42u3QMQEAAAgDoGlyo1vBzwciUJlw1ApkyZIlS5YsBbJkyZIlS5YCWbJkyZI lS4EsWbJkyZKlQJYsWbJkyVIgS5YsWbJkKZAlS5YsWbIUyJIlS5YsWQpkyZIlS5YsBbJkyZIlS5YCWbJ kyZIlS4EsWbJkyZKlQJYsWbJkyVIgS5YsWbJkKZAlS5YsWbIUyJIlS5YsWQpkyfq2MosBSIeKONMAAAA ASUVORK5CYII="; | |
20 | |
21 var blobContents = [base64ToUint8Array(pngBase64)]; | |
22 | |
23 var blob; | |
24 var blobURL1; | |
25 var blobURL2; | |
26 var img; | |
27 | |
28 function testRevokeAfterClose() | |
29 { | |
30 debug("Test that dereferencing URLs referring to closed Blobs fail."); | |
31 blob = buildBlob(blobContents, "image/png"); | |
32 img = document.createElement("img"); | |
33 img.onerror = function (e) { | |
34 testPassed("Error triggered on loading image from closed Blob."); | |
35 runNextTest(); | |
36 }; | |
37 img.onload = function () { | |
38 testFailed("Image loaded"); | |
39 runNextTest(); | |
40 }; | |
41 blobURL1 = window.URL.createObjectURL(blob); | |
42 // create some more Blob URLs. | |
43 for (var i = 0; i < 10; i++) | |
44 window.URL.createObjectURL(blob); | |
45 // Make them all inaccessible. | |
kinuko
2014/02/21 12:26:17
We don't seem checking if all of them become inacc
sof
2014/02/21 14:56:57
Good idea; I've kept this test over 'img', but cre
| |
46 blob.close(); | |
47 img.src = blobURL1; | |
48 } | |
49 | |
50 function testRegisterAfterClose() | |
51 { | |
52 debug("Test creating object URLs on closed Blobs"); | |
53 blob = buildBlob(["body{background: green}"], "text/css"); | |
54 blobURL1 = window.URL.createObjectURL(blob); | |
55 blob.close(); | |
56 blobURL2 = window.URL.createObjectURL(blob); | |
57 shouldBeTrue("blobURL1 !== blobURL2"); | |
58 shouldBeTrue("blobURL2.length > 0"); | |
kinuko
2014/02/21 12:26:17
I've briefly checked the spec but I'm fully not su
sof
2014/02/21 12:36:45
That's correct, not much to go on there yet. The b
kinuko
2014/02/21 14:11:18
I see, thanks for the pointers. So let me make sur
sof
2014/02/21 14:56:57
Correct, this only tests re-registration after clo
kinuko
2014/02/21 15:40:49
Yes thanks. Could we add a brief comment for these
sof
2014/02/21 16:02:43
Done.
| |
59 runNextTest(); | |
60 } | |
61 | |
62 var tests = [ | |
63 testRevokeAfterClose, | |
64 testRegisterAfterClose ]; | |
65 | |
66 function runNextTest() | |
67 { | |
68 if (!tests.length) { | |
69 finishJSTest(); | |
70 return; | |
71 } | |
72 tests.shift()(); | |
73 } | |
74 </script> | |
75 <body onload="runNextTest()"> | |
76 </body> | |
OLD | NEW |