Chromium Code Reviews| Index: LayoutTests/fast/files/blob-close-revoke.html |
| diff --git a/LayoutTests/fast/files/blob-close-revoke.html b/LayoutTests/fast/files/blob-close-revoke.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aaab5ca00eb98ca1c7e7d08648c6463c34650770 |
| --- /dev/null |
| +++ b/LayoutTests/fast/files/blob-close-revoke.html |
| @@ -0,0 +1,76 @@ |
| +<!doctype html> |
| +<script src="../../resources/js-test.js"></script> |
| +<script src="resources/read-common.js"></script> |
| +<script> |
| +description("Test the Blob.close() method, revoking."); |
| + |
| +window.jsTestIsAsync = true; |
| + |
| +function base64ToUint8Array(a) |
| +{ |
| + var binary = window.atob(a); |
| + var buffer = new Uint8Array(binary.length); |
| + for (var i = 0; i < binary.length; i++) |
| + buffer[i] = binary.charCodeAt(i); |
| + |
| + return buffer; |
| +} |
| + |
| +var pngBase64 = "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAnklEQVR42u3QMQEAAAgDoGlyo1vBzwciUJlw1ApkyZIlS5YsBbJkyZIlS5YCWbJkyZIlS4EsWbJkyZKlQJYsWbJkyVIgS5YsWbJkKZAlS5YsWbIUyJIlS5YsWQpkyZIlS5YsBbJkyZIlS5YCWbJkyZIlS4EsWbJkyZKlQJYsWbJkyVIgS5YsWbJkKZAlS5YsWbIUyJIlS5YsWQpkyfq2MosBSIeKONMAAAAASUVORK5CYII="; |
| + |
| +var blobContents = [base64ToUint8Array(pngBase64)]; |
| + |
| +var blob; |
| +var blobURL1; |
| +var blobURL2; |
| +var img; |
| + |
| +function testRevokeAfterClose() |
| +{ |
| + debug("Test that dereferencing URLs referring to closed Blobs fail."); |
| + blob = buildBlob(blobContents, "image/png"); |
| + img = document.createElement("img"); |
| + img.onerror = function (e) { |
| + testPassed("Error triggered on loading image from closed Blob."); |
| + runNextTest(); |
| + }; |
| + img.onload = function () { |
| + testFailed("Image loaded"); |
| + runNextTest(); |
| + }; |
| + blobURL1 = window.URL.createObjectURL(blob); |
| + // create some more Blob URLs. |
| + for (var i = 0; i < 10; i++) |
| + window.URL.createObjectURL(blob); |
| + // 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
|
| + blob.close(); |
| + img.src = blobURL1; |
| +} |
| + |
| +function testRegisterAfterClose() |
| +{ |
| + debug("Test creating object URLs on closed Blobs"); |
| + blob = buildBlob(["body{background: green}"], "text/css"); |
| + blobURL1 = window.URL.createObjectURL(blob); |
| + blob.close(); |
| + blobURL2 = window.URL.createObjectURL(blob); |
| + shouldBeTrue("blobURL1 !== blobURL2"); |
| + 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.
|
| + runNextTest(); |
| +} |
| + |
| +var tests = [ |
| + testRevokeAfterClose, |
| + testRegisterAfterClose ]; |
| + |
| +function runNextTest() |
| +{ |
| + if (!tests.length) { |
| + finishJSTest(); |
| + return; |
| + } |
| + tests.shift()(); |
| +} |
| +</script> |
| +<body onload="runNextTest()"> |
| +</body> |