| 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.
|
| + 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");
|
| + runNextTest();
|
| +}
|
| +
|
| +var tests = [
|
| + testRevokeAfterClose,
|
| + testRegisterAfterClose ];
|
| +
|
| +function runNextTest()
|
| +{
|
| + if (!tests.length) {
|
| + finishJSTest();
|
| + return;
|
| + }
|
| + tests.shift()();
|
| +}
|
| +</script>
|
| +<body onload="runNextTest()">
|
| +</body>
|
|
|