Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / files / blob-close-revoke.html
blob5a1f5626dc28f7379963c0ac3f9a0d7a567af994
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.");
7 window.jsTestIsAsync = true;
9 function base64ToUint8Array(a)
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);
16 return buffer;
19 var pngBase64 = "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAnklEQVR42u3QMQEAAAgDoGlyo1vBzwciUJlw1ApkyZIlS5YsBbJkyZIlS5YCWbJkyZIlS4EsWbJkyZKlQJYsWbJkyVIgS5YsWbJkKZAlS5YsWbIUyJIlS5YsWQpkyZIlS5YsBbJkyZIlS5YCWbJkyZIlS4EsWbJkyZKlQJYsWbJkyVIgS5YsWbJkKZAlS5YsWbIUyJIlS5YsWQpkyfq2MosBSIeKONMAAAAASUVORK5CYII=";
21 var blobContents = [base64ToUint8Array(pngBase64)];
23 var blob;
24 var blobURL1;
25 var blobURL2;
26 var img;
27 var worker;
28 var blobURLs = [];
30 function testRevokeAfterCloseWorkers()
32 debug("Test that dereferencing URLs referring to closed Blobs fail, workers.");
33 blob = new Blob(["postMessage('FAIL');"], {type: "application/javascript"});
34 for (var i = 0; i < 10; i++)
35 blobURLs.push(window.URL.createObjectURL(blob));
37 // First check that the Blob URL can be used by a Worker,
38 // then close it and verify that the rest cannot.
40 function onNonClosedError() {
41 testFailed("Worker failed to load from Blob.");
42 blob.close();
43 testNextWorker();
45 function onNonClosedMessage() {
46 testPassed("Worker loaded.");
47 blob.close();
48 testNextWorker();
50 function onClosedError() {
51 testPassed("Error triggered on starting Worker from a closed Blob.");
52 testNextWorker();
54 function onClosedMessage() {
55 testFailed("Worker loaded.");
56 testNextWorker();
59 function testNextWorker(onerror, onmessage) {
60 var u = blobURLs.shift();
61 if (u) {
62 worker = new Worker(u);
63 worker.onerror = onerror ? onerror : onClosedError;
64 worker.onmessage = onmessage ? onmessage : onClosedMessage;
65 } else {
66 runNextTest();
69 testNextWorker(onNonClosedError, onNonClosedMessage);
72 function testRevokeAfterClose()
74 debug("Test that dereferencing URLs referring to closed Blobs fail.");
75 blob = new Blob(blobContents, {type: "image/png"});
76 img = document.createElement("img");
77 img.onerror = function (e) {
78 testPassed("Error triggered on loading image from closed Blob.");
79 runNextTest();
81 img.onload = function () {
82 testFailed("Image loaded");
83 runNextTest();
85 blobURL1 = window.URL.createObjectURL(blob);
86 // create some more Blob URLs.
87 for (var i = 0; i < 10; i++)
88 window.URL.createObjectURL(blob);
89 // Make them all inaccessible.
90 blob.close();
91 img.src = blobURL1;
94 function testCreateAfterClose()
96 debug("Test creating object URLs on closed Blobs");
97 blob = new Blob(["body{background: green}"], {type: "text/css"});
98 blob.close();
99 shouldThrow("window.URL.createObjectURL(blob);");
100 runNextTest();
103 var tests = [
104 testRevokeAfterClose,
105 testRevokeAfterCloseWorkers,
106 testCreateAfterClose ];
108 function runNextTest()
110 if (!tests.length) {
111 finishJSTest();
112 return;
114 tests.shift()();
116 </script>
117 <body onload="runNextTest()">
118 </body>