Changeset 115582 in webkit
- Timestamp:
- Apr 28, 2012, 3:24:48 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 45 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-unset.html (modified) (1 diff)
-
LayoutTests/fast/dom/HTMLAnchorElement/anchor-download.html (modified) (1 diff)
-
LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set.html (modified) (1 diff)
-
LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload.html (modified) (1 diff)
-
LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/window-domurl-crash.html (modified) (1 diff)
-
LayoutTests/fast/files/blob-constructor-expected.txt (added)
-
LayoutTests/fast/files/blob-constructor.html (added)
-
LayoutTests/fast/files/blob-slice-overflow.html (modified) (1 diff)
-
LayoutTests/fast/files/blob-slice-test.html (modified) (1 diff)
-
LayoutTests/fast/files/file-reader-fffd-expected.txt (modified) (1 diff)
-
LayoutTests/fast/files/file-reader-fffd.html (modified) (1 diff)
-
LayoutTests/fast/files/not-enough-arguments-expected.txt (modified) (1 diff)
-
LayoutTests/fast/files/not-enough-arguments.html (modified) (1 diff)
-
LayoutTests/fast/files/resources/read-blob-test-cases.js (modified) (1 diff)
-
LayoutTests/fast/files/resources/read-common.js (modified) (1 diff)
-
LayoutTests/fast/files/script-tests/blob-constructor.js (added)
-
LayoutTests/fast/files/workers/inline-worker-via-blob-url.html (modified) (1 diff)
-
LayoutTests/fast/filesystem/resources/file-writer-abort-continue.js (modified) (2 diffs)
-
LayoutTests/fast/filesystem/resources/file-writer-abort-depth.js (modified) (1 diff)
-
LayoutTests/fast/filesystem/resources/file-writer-abort.js (modified) (2 diffs)
-
LayoutTests/fast/filesystem/resources/file-writer-events.js (modified) (2 diffs)
-
LayoutTests/fast/filesystem/resources/file-writer-gc-blob.js (modified) (1 diff)
-
LayoutTests/fast/filesystem/resources/file-writer-sync-truncate-extend.js (modified) (1 diff)
-
LayoutTests/fast/filesystem/resources/file-writer-sync-write-overlapped.js (modified) (1 diff)
-
LayoutTests/fast/filesystem/resources/file-writer-utils.js (modified) (1 diff)
-
LayoutTests/http/tests/fileapi/create-blob-url-from-data-url.html (modified) (1 diff)
-
LayoutTests/http/tests/filesystem/no-cache-filesystem-url.html (modified) (1 diff)
-
LayoutTests/http/tests/local/blob/resources/hybrid-blob-util.js (modified) (1 diff)
-
LayoutTests/http/tests/security/resources/create-filesystem-file.html (modified) (1 diff)
-
LayoutTests/http/tests/websocket/tests/hixie76/send-object.html (modified) (1 diff)
-
LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html (modified) (1 diff)
-
LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html (modified) (1 diff)
-
LayoutTests/http/tests/websocket/tests/hybi/send-blob.html (modified) (2 diffs)
-
LayoutTests/http/tests/websocket/tests/hybi/send-file-blob-fail.html (modified) (1 diff)
-
LayoutTests/http/tests/websocket/tests/hybi/send-file-blob.html (modified) (1 diff)
-
LayoutTests/http/tests/websocket/tests/hybi/workers/resources/send-blob.js (modified) (2 diffs)
-
LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt (modified) (1 diff)
-
LayoutTests/storage/indexeddb/noblobs.html (modified) (1 diff)
-
LayoutTests/storage/indexeddb/structured-clone.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/bindings/js/JSBlobCustom.cpp (modified) (2 diffs)
-
Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp (modified) (2 diffs)
-
Source/WebCore/fileapi/Blob.cpp (modified) (1 diff)
-
Source/WebCore/fileapi/Blob.h (modified) (2 diffs)
-
Source/WebCore/fileapi/Blob.idl (modified) (1 diff)
-
Source/WebCore/workers/WorkerContext.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r115578 r115582 1 2012-04-28 Sam Weinig <sam@webkit.org> 2 3 Add support for the Blob constructor 4 https://bugs.webkit.org/show_bug.cgi?id=84555 5 6 Reviewed by Maciej Stachowiak. 7 8 Switch tests that were not directly testing BlobBuilder over to 9 using the Blob constructor, to get test coverage of standard way 10 constructing blobs. 11 12 * fast/files/blob-constructor.html: Added. 13 * fast/files/blob-constructor-expected.txt: Added. 14 * fast/files/script-tests/blob-constructor.js: Added. 15 New test. 16 17 * fast/dom/HTMLAnchorElement/anchor-download-unset.html: 18 * fast/dom/HTMLAnchorElement/anchor-download.html: 19 * fast/dom/HTMLAnchorElement/anchor-nodownload-set.html: 20 * fast/dom/HTMLAnchorElement/anchor-nodownload.html: 21 * fast/dom/constructed-objects-prototypes-expected.txt: 22 * fast/dom/window-domurl-crash.html: 23 * fast/files/blob-slice-overflow.html: 24 * fast/files/blob-slice-test.html: 25 * fast/files/file-reader-fffd-expected.txt: 26 * fast/files/file-reader-fffd.html: 27 * fast/files/not-enough-arguments-expected.txt: 28 * fast/files/not-enough-arguments.html: 29 * fast/files/resources/read-blob-test-cases.js: 30 * fast/files/resources/read-common.js: 31 * fast/files/workers/inline-worker-via-blob-url.html: 32 * fast/filesystem/resources/file-writer-abort-continue.js: 33 * fast/filesystem/resources/file-writer-abort-depth.js: 34 * fast/filesystem/resources/file-writer-abort.js: 35 * fast/filesystem/resources/file-writer-events.js: 36 * fast/filesystem/resources/file-writer-gc-blob.js: 37 * fast/filesystem/resources/file-writer-sync-truncate-extend.js: 38 * fast/filesystem/resources/file-writer-sync-write-overlapped.js: 39 * fast/filesystem/resources/file-writer-utils.js: 40 * http/tests/fileapi/create-blob-url-from-data-url.html: 41 * http/tests/filesystem/no-cache-filesystem-url.html: 42 * http/tests/local/blob/resources/hybrid-blob-util.js: 43 * http/tests/security/resources/create-filesystem-file.html: 44 * http/tests/websocket/tests/hixie76/send-object.html: 45 * http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html: 46 * http/tests/websocket/tests/hybi/bufferedAmount-after-close.html: 47 * http/tests/websocket/tests/hybi/send-blob.html: 48 * http/tests/websocket/tests/hybi/send-file-blob-fail.html: 49 * http/tests/websocket/tests/hybi/send-file-blob.html: 50 * http/tests/websocket/tests/hybi/workers/resources/send-blob.js: 51 * platform/mac/fast/dom/Window/window-properties-expected.txt: 52 * storage/indexeddb/noblobs.html: 53 * storage/indexeddb/structured-clone.html: 54 1 55 2012-04-28 Zan Dobersek <zandobersek@gmail.com> 2 56 -
trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-unset.html
r115491 r115582 25 25 function runTest() 26 26 { 27 var bb = new WebKitBlobBuilder(); 28 bb.append("<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>"); 29 var blob = bb.getBlob("text/html", "inline"); 27 var string = "<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>"); 28 var blob = new Blob([string], {type: "text/html"}); 30 29 var link = document.getElementById("blob-url"); 31 30 link.href = window.webkitURL.createObjectURL(blob); -
trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download.html
r115491 r115582 25 25 function runTest() 26 26 { 27 var bb = new WebKitBlobBuilder(); 28 bb.append("<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>"); 29 var blob = bb.getBlob("text/html", "inline"); 27 var string = "<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>"; 28 var blob = new Blob([string], {type: "text/html"}); 30 29 var link = document.getElementById("blob-url"); 31 30 link.href = window.webkitURL.createObjectURL(blob); -
trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
r115491 r115582 25 25 function runTest() 26 26 { 27 var bb = new WebKitBlobBuilder(); 28 bb.append("<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>"); 29 var blob = bb.getBlob("text/html", "inline"); 27 var string = "<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>"; 28 var blob = new Blob([string], {type: "text/html"}); 30 29 var link = document.getElementById("blob-url"); 31 30 link.href = window.webkitURL.createObjectURL(blob); -
trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload.html
r115491 r115582 25 25 function runTest() 26 26 { 27 var bb = new WebKitBlobBuilder(); 28 bb.append("<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>"); 29 var blob = bb.getBlob("text/html", "inline"); 27 var string = "<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>"; 28 var blob = new Blob([string], {type: "text/html"}); 30 29 var link = document.getElementById("blob-url"); 31 30 link.href = window.webkitURL.createObjectURL(blob); -
trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt
r105520 r115582 8 8 PASS (new inner.BeforeLoadEvent()).isInner is true 9 9 PASS (new inner.BeforeLoadEvent()).constructor.isInner is true 10 PASS (new inner.Blob()).isInner is true 11 PASS (new inner.Blob()).constructor.isInner is true 10 12 PASS (new inner.CloseEvent()).isInner is true 11 13 PASS (new inner.CloseEvent()).constructor.isInner is true -
trunk/LayoutTests/fast/dom/window-domurl-crash.html
r115491 r115582 2 2 <head> 3 3 <script> 4 var blob = (new WebKitBlobBuilder).getBlob();4 var blob = new Blob([]); 5 5 var url = null; 6 6 var count = 0; -
trunk/LayoutTests/fast/files/blob-slice-overflow.html
r115491 r115582 6 6 <script> 7 7 if (window.layoutTestController) { 8 layoutTestController.dumpAsText();9 layoutTestController.waitUntilDone()8 layoutTestController.dumpAsText(); 9 layoutTestController.waitUntilDone() 10 10 } 11 var builder = new WebKitBlobBuilder(); 11 12 12 var text = ''; 13 for (var i = 0; i < 2000; ++i) text += 'A'; 14 builder.append(text); 15 blob = builder.getBlob(); 13 for (var i = 0; i < 2000; ++i) 14 text += 'A'; 15 16 blob = new Blob([text]); 16 17 slicedBlob = blob.webkitSlice(1999, 9223372036854775000); 18 17 19 document.getElementById('console').appendChild(document.createTextNode('Blob slice length: ' + slicedBlob.size)); 18 20 if (slicedBlob.size != 1) { 19 document.getElementById('console').appendChild(document.createTextNode('FAIL'));21 document.getElementById('console').appendChild(document.createTextNode('FAIL')); 20 22 } 23 21 24 if (window.layoutTestController) { 22 25 layoutTestController.notifyDone(); -
trunk/LayoutTests/fast/files/blob-slice-test.html
r115491 r115582 83 83 function runTests() 84 84 { 85 var builder = new WebKitBlobBuilder(); 86 builder.append("0123456789"); 87 blob = builder.getBlob(); 85 blob = new Blob(["0123456789"]); 88 86 89 87 runNextTest(); -
trunk/LayoutTests/fast/files/file-reader-fffd-expected.txt
r97543 r115582 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 4 5 bb = new WebKitBlobBuilder();6 5 array = new Uint8Array([65, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 66]); 7 blob = buildBlob([array.buffer]);6 blob = new Blob([array.buffer]); 8 7 reader = new FileReader(); 9 8 reader.readAsText(blob); -
trunk/LayoutTests/fast/files/file-reader-fffd.html
r115491 r115582 11 11 description("Throw various bad bytes at file reader."); 12 12 13 bb = evalAndLog("bb = new WebKitBlobBuilder();");14 13 array = evalAndLog("array = new Uint8Array([65, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 66]);"); 15 blob = evalAndLog("blob = buildBlob([array.buffer]);");14 blob = evalAndLog("blob = new Blob([array.buffer]);"); 16 15 reader = evalAndLog("reader = new FileReader();"); 17 16 reader.onload = function(event) { -
trunk/LayoutTests/fast/files/not-enough-arguments-expected.txt
r96956 r115582 8 8 PASS reader.readAsText() threw exception TypeError: Not enough arguments. 9 9 PASS reader.readAsDataURL() threw exception TypeError: Not enough arguments. 10 PASS blobBuilder.append() threw exception TypeError: Type error.11 10 PASS fileInput.files.item() threw exception TypeError: Not enough arguments. 12 11 PASS successfullyParsed is true -
trunk/LayoutTests/fast/files/not-enough-arguments.html
r115491 r115582 16 16 shouldThrow('reader.readAsDataURL()'); 17 17 18 var blobBuilder = new WebKitBlobBuilder();19 20 shouldThrow('blobBuilder.append()');21 22 18 var fileInput = document.getElementsByTagName('input')[0]; 23 19 -
trunk/LayoutTests/fast/files/resources/read-blob-test-cases.js
r115491 r115582 171 171 { 172 172 log("Test reading a triple-sliced hybrid blob"); 173 var builder = new WebKitBlobBuilder();174 173 var array = new Uint8Array([48, 49, 50]); 175 var blob = buildBlob(['First', testFiles['file1'].webkitSlice(1, 11), testFiles['empty-file'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array.buffer], undefined, builder); 174 var items = ['First', testFiles['file1'].webkitSlice(1, 11), testFiles['empty-file'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array.buffer]; 175 var blob = buildBlob(items); 176 176 var blob = blob.webkitSlice(7, 19); 177 var blob2 = buildBlob( ['Foo', blob, 'Bar'], undefined, builder);177 var blob2 = buildBlob(items.concat(['Foo', blob, 'Bar'])); 178 178 var blob2 = blob2.webkitSlice(12, 42); 179 179 readBlobAsBinaryString(testFiles, blob2); -
trunk/LayoutTests/fast/files/resources/read-common.js
r115491 r115582 2 2 // The 'contentType' argument is optional. 3 3 // If the 'builder' argument is not provided, create a new one. 4 function buildBlob(items, contentType, builder) 5 { 6 if (builder === undefined) 7 builder = new WebKitBlobBuilder(); 8 for (var i = 0; i < items.length; i++) 9 builder.append(items[i]); 10 return builder.getBlob(contentType); 4 function buildBlob(items, contentType) 5 { 6 if (contentType === undefined) 7 return new Blob(items); 8 return new Blob(items, {type:contentType}); 11 9 } 12 10 -
trunk/LayoutTests/fast/files/workers/inline-worker-via-blob-url.html
r115491 r115582 11 11 { 12 12 log("Test inline web worker via blob URL."); 13 var blobBuilder = new WebKitBlobBuilder(); 14 blobBuilder.append([ 13 var string = [ 15 14 "onmessage = function(e) {", 16 15 " postMessage('Hello from worker');", 17 16 "};" 18 17 ].join('\n')); 19 var blobURL = webkitURL.createObjectURL( blobBuilder.getBlob());18 var blobURL = webkitURL.createObjectURL(new Blob([string])); 20 19 var worker = new Worker(blobURL); 21 20 worker.onmessage = function(event) { -
trunk/LayoutTests/fast/filesystem/resources/file-writer-abort-continue.js
r115491 r115582 53 53 54 54 function tenXBlob(blob) { 55 var bb = new WebKitBlobBuilder();55 var bb = []; 56 56 for (var i = 0; i < 10; ++i) { 57 bb. append(blob);57 bb.push(blob); 58 58 } 59 return bb.getBlob();59 return new Blob(bb); 60 60 } 61 61 … … 92 92 function startWrite() { 93 93 // Let's make it about a megabyte. 94 var bb = new WebKitBlobBuilder(); 95 bb.append("lorem ipsum"); 96 var blob = tenXBlob(bb.getBlob()); 94 var blob = tenXBlob(new Blob(["lorem ipsum"])); 97 95 blob = tenXBlob(blob); 98 96 blob = tenXBlob(blob); -
trunk/LayoutTests/fast/filesystem/resources/file-writer-abort-depth.js
r115491 r115582 11 11 var sawWriteEnd; 12 12 var writer; 13 var bb = new WebKitBlobBuilder(); 14 bb.append("lorem ipsum"); 15 var blob = bb.getBlob(); 13 var blob = new Blob(["lorem ipsum"]); 16 14 var recursionDepth = 0; 17 15 var method; -
trunk/LayoutTests/fast/filesystem/resources/file-writer-abort.js
r115491 r115582 13 13 14 14 function tenXBlob(blob) { 15 var bb = new WebKitBlobBuilder();15 var bb = []; 16 16 for (var i = 0; i < 10; ++i) { 17 bb. append(blob);17 bb.push(blob); 18 18 } 19 return bb.getBlob();19 return new Blob(bb); 20 20 } 21 21 … … 63 63 function startWrite(fileWriter) { 64 64 // Let's make it about a megabyte. 65 var bb = new WebKitBlobBuilder(); 66 bb.append("lorem ipsum"); 67 var blob = tenXBlob(bb.getBlob()); 65 var blob = tenXBlob(new Blob(["lorem ipsum"])); 68 66 blob = tenXBlob(blob); 69 67 blob = tenXBlob(blob); -
trunk/LayoutTests/fast/filesystem/resources/file-writer-events.js
r115491 r115582 17 17 18 18 function tenXBlob(blob) { 19 var bb = new WebKitBlobBuilder();19 var bb = []; 20 20 for (var i = 0; i < 10; ++i) { 21 bb. append(blob);21 bb.push(blob); 22 22 } 23 return bb.getBlob();23 return new Blob(bb); 24 24 } 25 25 … … 79 79 function startWrite(fileWriter) { 80 80 // Let's make it about a megabyte. 81 var bb = new WebKitBlobBuilder(); 82 bb.append("lorem ipsum"); 83 var blob = tenXBlob(bb.getBlob()); 81 var blob = tenXBlob(new Blob(["lorem ipsum"])); 84 82 blob = tenXBlob(blob); 85 83 blob = tenXBlob(blob); -
trunk/LayoutTests/fast/filesystem/resources/file-writer-gc-blob.js
r115491 r115582 15 15 16 16 function tenXBlob(blob) { 17 var bb = new WebKitBlobBuilder();17 var bb = []; 18 18 for (var i = 0; i < 10; ++i) { 19 bb. append(blob);19 bb.push(blob); 20 20 } 21 return bb.getBlob();21 return new Blob(bb); 22 22 } 23 23 24 24 function startWrite(writer) { 25 25 // Let's make it about a megabyte. 26 var bb = new WebKitBlobBuilder(); 27 bb.append("lorem ipsum"); 28 var blob = tenXBlob(bb.getBlob()); 26 var blob = tenXBlob(new Blob["lorem ipsum"]); 29 27 blob = tenXBlob(blob); 30 28 blob = tenXBlob(blob); -
trunk/LayoutTests/fast/filesystem/resources/file-writer-sync-truncate-extend.js
r115491 r115582 16 16 var writer = entry.createWriter(); 17 17 assert(!writer.position); 18 var builder = new WebKitBlobBuilder();19 18 var testData = "test data"; 20 builder.append(testData); 21 writer.write(builder.getBlob()); 19 writer.write(new Blob([testData])); 22 20 assert(writer.length == testData.length); 23 21 assert(writer.position == writer.length); -
trunk/LayoutTests/fast/filesystem/resources/file-writer-sync-write-overlapped.js
r115491 r115582 16 16 var writer = entry.createWriter(); 17 17 assert(!writer.position); 18 var builder = new WebKitBlobBuilder();19 18 var testData = "test data"; 20 builder.append(testData); 21 var blob = builder.getBlob(); 19 var blob = new Blob([testData]); 22 20 writer.write(blob); 23 21 assert(writer.length == testData.length); -
trunk/LayoutTests/fast/filesystem/resources/file-writer-utils.js
r115491 r115582 135 135 function writeString(fileEntry, fileWriter, offset, data, onSuccess) 136 136 { 137 var bb = new WebKitBlobBuilder(); 138 bb.append(data); 139 var blob = bb.getBlob(); 137 var blob = new Blob([data]); 140 138 fileWriter.seek(offset); 141 139 fileWriter.write(blob); -
trunk/LayoutTests/http/tests/fileapi/create-blob-url-from-data-url.html
r115491 r115582 29 29 <p> Test case for checking blob URL not allowed to be created from the code running from data URI</p> 30 30 <pre id='console'></pre> 31 <iframe src="data:text/html,%3Cscript%3Evar%20b %20%3D%20new%20WebKitBlobBuilder()%3Bb.append(%22Foo%22)%3Bvar%20bb%20%3D%20b.getBlob('text%2Fhtml')%3Btop.location%3D'http%3A%2F%2F127.0.0.1%3A8000%2Ffileapi%2Fcreate-blob-url-from-data-url.html%23'%20%2B%20window.webkitURL.createObjectURL(bb)%3B%3C%2Fscript%3E"></iframe>31 <iframe src="data:text/html,%3Cscript%3Evar%20bb%20%3D%20new%20Blob%28%5B%22Foo%22%5D%2C%20%7Btype%3A%22text%2Fhtml%22%7D%29%3Btop.location%3D%27http%3A%2F%2F127.0.0.1%3A8000%2Ffileapi%2Fcreate-blob-url-from-data-url.html%23%27%20%2B%20window.webkitURL.createObjectURL%28bb%29%3B%3C%2Fscript%3E"></iframe> 32 32 </body> 33 33 </html> -
trunk/LayoutTests/http/tests/filesystem/no-cache-filesystem-url.html
r115491 r115582 25 25 callback(rand); 26 26 }; 27 var bb = new WebKitBlobBuilder(); 28 bb.append('document.getElementById("result").innerHTML = (expected == ' + rand + ') ? "SUCCESS" : "FAILURE";'); 29 writer.write(bb.getBlob('text/plain')); 27 writer.write(new Blob(['document.getElementById("result").innerHTML = (expected == ' + rand + ') ? "SUCCESS" : "FAILURE";'], {type:'text/plain'})); 30 28 } 31 29 -
trunk/LayoutTests/http/tests/local/blob/resources/hybrid-blob-util.js
r115491 r115582 132 132 this.appendAndCreateBlob = function(items, opt_ending, opt_type) 133 133 { 134 var b b = new WebKitBlobBuilder();134 var builder = []; 135 135 for (var i = 0; i < items.length; i++) { 136 136 if (items[i] instanceof Array) { 137 137 // If it's an array, combine its elements and append as a blob. 138 bb.append(this.appendAndCreateBlob(items[i], opt_ending, opt_type)); 139 } else if (items[i].type == "data" && opt_ending) 140 bb.append(items[i].value, opt_ending); 141 else 142 bb.append(items[i].value); 138 builder.push(this.appendAndCreateBlob(items[i], opt_ending, opt_type)); 139 } else 140 builder.push(items[i].value); 143 141 } 144 return bb.getBlob(opt_type); 142 var options = {}; 143 if (opt_ending) 144 options.endings = opt_ending; 145 if (opt_type) 146 options.type = opt_type; 147 return new Blob(builder, options); 145 148 }; 146 149 }; -
trunk/LayoutTests/http/tests/security/resources/create-filesystem-file.html
r115491 r115582 6 6 fs.root.getFile("page.html", {create:true}, function(entry) { 7 7 entry.createWriter(function(writer) { 8 var bb = new WebKitBlobBuilder();9 bb.append('<div id="innerDiv">Visible Contents</div>\n');10 8 writer.onwrite = function() { 11 9 console.log(entry.toURL() + " created."); 12 10 }; 13 writer.write( bb.getBlob());11 writer.write(new Blob(['<div id="innerDiv">Visible Contents</div>\n'])); 14 12 }); 15 13 }); -
trunk/LayoutTests/http/tests/websocket/tests/hixie76/send-object.html
r115491 r115582 16 16 function createEmptyBlob() 17 17 { 18 var builder = new WebKitBlobBuilder(); 19 return builder.getBlob(); 18 return new Blob([]); 20 19 } 21 20 -
trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html
r115491 r115582 24 24 function createBlobWithLength(length) 25 25 { 26 var builder = new WebKitBlobBuilder(); 27 builder.append(new ArrayBuffer(length)); 28 return builder.getBlob(); 26 return new Blob([new ArrayBuffer(length)]); 29 27 } 30 28 -
trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html
r115491 r115582 24 24 function createBlobWithLength(length) 25 25 { 26 var builder = new WebKitBlobBuilder(); 27 builder.append(new ArrayBuffer(length)); 28 return builder.getBlob(); 26 return new Blob([new ArrayBuffer(length)]); 29 27 } 30 28 -
trunk/LayoutTests/http/tests/websocket/tests/hybi/send-blob.html
r115491 r115582 21 21 function createBlobContainingHelloWorld() 22 22 { 23 var builder = new WebKitBlobBuilder(); 24 builder.append("Hello, world!"); 25 return builder.getBlob(); 23 return new Blob(["Hello, world!"]); 26 24 } 27 25 28 26 function createEmptyBlob() 29 27 { 30 var builder = new WebKitBlobBuilder(); 31 return builder.getBlob(); 28 return new Blob([]); 32 29 } 33 30 … … 37 34 for (var i = 0; i < 256; ++i) 38 35 array[i] = i; 39 var builder = new WebKitBlobBuilder(); 40 builder.append(array.buffer); 41 return builder.getBlob(); 36 return new Blob([array.buffer]); 42 37 } 43 38 -
trunk/LayoutTests/http/tests/websocket/tests/hybi/send-file-blob-fail.html
r115491 r115582 60 60 writer.onwrite = function() 61 61 { 62 var builder = new WebKitBlobBuilder(); 63 builder.append(messageToWrite); 64 writer.write(builder.getBlob()); 62 writer.write(new Blob([messageToWrite])); 65 63 writer.onwrite = didWriteFile; 66 64 }; -
trunk/LayoutTests/http/tests/websocket/tests/hybi/send-file-blob.html
r115491 r115582 60 60 writer.onwrite = function() 61 61 { 62 var builder = new WebKitBlobBuilder(); 63 builder.append(messageToWrite); 64 writer.write(builder.getBlob()); 62 writer.write(new Blob([messageToWrite])); 65 63 writer.onwrite = didWriteFile; 66 64 }; -
trunk/LayoutTests/http/tests/websocket/tests/hybi/workers/resources/send-blob.js
r115491 r115582 1 1 function createBlobContainingHelloWorld() 2 2 { 3 var builder = new WebKitBlobBuilder(); 4 builder.append("Hello, world!"); 5 return builder.getBlob(); 3 return new Blob(["Hello, world!"]); 6 4 } 7 5 8 6 function createEmptyBlob() 9 7 { 10 var builder = new WebKitBlobBuilder(); 11 return builder.getBlob(); 8 return new Blob([]); 12 9 } 13 10 … … 17 14 for (var i = 0; i < 256; ++i) 18 15 array[i] = i; 19 var builder = new WebKitBlobBuilder(); 20 builder.append(array.buffer); 21 return builder.getBlob(); 16 return new Blob([array.buffer]); 22 17 } 23 18 -
trunk/LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt
r115491 r115582 181 181 window.BeforeLoadEvent.prototype.stopPropagation [function] 182 182 window.Blob [object BlobConstructor] 183 window.Blob.length [number] 183 184 window.Blob.prototype [object BlobPrototype] 184 185 window.Boolean [function] -
trunk/LayoutTests/storage/indexeddb/noblobs.html
r115491 r115582 59 59 debug("testBlob():"); 60 60 61 evalAndLog("BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder");62 shouldBeTrue("BlobBuilder != null");63 61 shouldBeTrue("FileReader != null"); 64 evalAndLog("builder = new BlobBuilder()");65 62 evalAndLog("test_content = 'This is a test. This is only a test.'"); 66 evalAndLog("builder.append(test_content)"); 67 evalAndLog("blob = builder.getBlob()"); 63 evalAndLog("blob = new Blob([test_content])"); 68 64 validateExceptions("blob", testFile); 69 65 } -
trunk/LayoutTests/storage/indexeddb/structured-clone.html
r115491 r115582 377 377 return; 378 378 379 evalAndLog("BlobBuilder = self.BlobBuilder || self.WebKitBlobBuilder");380 shouldBeTrue("BlobBuilder != null");381 379 shouldBeTrue("FileReader != null"); 382 evalAndLog("builder = new BlobBuilder()");383 380 evalAndLog("test_content = 'This is a test. This is only a test.'"); 384 evalAndLog("builder.append(test_content)"); 385 evalAndLog("test_data = builder.getBlob()"); 381 evalAndLog("test_data = new Blob([test_content])"); 386 382 testValue(test_data, function(result) { 387 383 self.result = result; -
trunk/Source/WebCore/ChangeLog
r115581 r115582 1 2012-04-27 Sam Weinig <sam@webkit.org> 2 3 Add support for the Blob constructor 4 https://bugs.webkit.org/show_bug.cgi?id=84555 5 6 Reviewed by Maciej Stachowiak. 7 8 Test: fast/files/blob-constructor.html 9 10 This adds an implementation of the Blob constructor that willfully 11 violates the W3C Editor’s Draft 29 February 2012 in the following ways: 12 - Elements in the parts array are coerced to DOMStrings https://www.w3.org/Bugs/Public/show_bug.cgi?id=16721 13 - Don't throw for invalid key in the dictionary https://www.w3.org/Bugs/Public/show_bug.cgi?id=16727 14 - Values for the endings property are treated as enums https://www.w3.org/Bugs/Public/show_bug.cgi?id=16729 15 16 * bindings/js/JSBlobCustom.cpp: 17 (WebCore::JSBlobConstructor::constructJSBlob): 18 Implement blob constructor. 19 20 * bindings/v8/custom/V8BlobCustom.cpp: 21 (WebCore::V8Blob::constructorCallback): 22 Implement blob constructor. 23 24 * fileapi/Blob.idl: 25 Add constructor to IDL. 26 27 * workers/WorkerContext.idl: 28 Add Blob constructor to the worker global object. 29 1 30 2012-04-28 Igor Oliveira <igor.o@sisa.samsung.com> 2 31 -
trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp
r115491 r115582 33 33 34 34 #include "Blob.h" 35 #include "ExceptionCode.h" 36 #include "ExceptionCodePlaceholder.h" 37 #include "JSArrayBuffer.h" 35 38 #include "JSDOMBinding.h" 39 #include "JSDictionary.h" 36 40 #include "JSFile.h" 41 #include "WebKitBlobBuilder.h" 42 #include <runtime/Error.h> 43 #include <runtime/JSArray.h> 37 44 #include <wtf/Assertions.h> 38 45 … … 52 59 } 53 60 61 EncodedJSValue JSC_HOST_CALL JSBlobConstructor::constructJSBlob(ExecState* exec) 62 { 63 JSBlobConstructor* jsConstructor = jsCast<JSBlobConstructor*>(exec->callee()); 64 ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); 65 if (!context) 66 return throwVMError(exec, createReferenceError(exec, "Blob constructor associated document is unavailable")); 67 68 if (!exec->argumentCount()) { 69 RefPtr<Blob> blob = Blob::create(); 70 return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), Blob, blob.get())); 71 } 72 73 JSValue firstArg = exec->argument(0); 74 if (!isJSArray(firstArg)) 75 return throwVMError(exec, createTypeError(exec, "First argument of the constructor is not of type Array")); 76 77 String type; 78 String endings = "transparent"; 79 80 if (exec->argumentCount() > 1) { 81 JSValue blobPropertyBagValue = exec->argument(1); 82 83 // FIXME: Should we throw if the blobPropertyBag is not an object? 84 85 if (blobPropertyBagValue.isObject()) { 86 // Given the above test, this will always yield an object. 87 JSObject* blobPropertyBagObject = blobPropertyBagValue.toObject(exec); 88 89 // Create the dictionary wrapper from the initializer object. 90 JSDictionary dictionary(exec, blobPropertyBagObject); 91 92 // Attempt to get the type property. 93 dictionary.get("type", type); 94 if (exec->hadException()) 95 return JSValue::encode(jsUndefined()); 96 97 // Attempt to get the endings property and validate it. 98 bool containsEndings = dictionary.get("endings", endings); 99 if (exec->hadException()) 100 return JSValue::encode(jsUndefined()); 101 102 if (containsEndings) { 103 if (endings != "transparent" && endings != "native") { 104 setDOMException(exec, INVALID_STATE_ERR); 105 return JSValue::encode(jsUndefined()); 106 } 107 } 108 } 109 } 110 111 ASSERT(endings == "transparent" || endings == "native"); 112 113 // FIXME: this would be better if the WebKitBlobBuilder were a stack object to avoid the allocation. 114 RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create(); 115 116 JSArray* array = asArray(firstArg); 117 unsigned length = array->length(); 118 119 for (unsigned i = 0; i < length; ++i) { 120 JSValue item = array->getIndex(i); 121 #if ENABLE(BLOB) 122 if (item.inherits(&JSArrayBuffer::s_info)) 123 blobBuilder->append(toArrayBuffer(item)); 124 else 125 #endif 126 if (item.inherits(&JSBlob::s_info)) 127 blobBuilder->append(toBlob(item)); 128 else { 129 String string = ustringToString(item.toString(exec)->value(exec)); 130 if (exec->hadException()) 131 return JSValue::encode(jsUndefined()); 132 blobBuilder->append(string, endings, ASSERT_NO_EXCEPTION); 133 } 134 } 135 136 RefPtr<Blob> blob = blobBuilder->getBlob(type); 137 return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), Blob, blob.get())); 138 } 139 54 140 } // namespace WebCore -
trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp
r115491 r115582 32 32 #include "Blob.h" 33 33 34 #include "Dictionary.h" 35 #include "V8Binding.h" 34 36 #include "V8Blob.h" 35 37 #include "V8File.h" 36 38 #include "V8Proxy.h" 39 #include "V8Utilities.h" 40 #include "WebKitBlobBuilder.h" 37 41 #include <wtf/RefPtr.h> 38 42 … … 50 54 } 51 55 56 v8::Handle<v8::Value> V8Blob::constructorCallback(const v8::Arguments& args) 57 { 58 INC_STATS("DOM.Blob.Constructor"); 59 60 if (!args.IsConstructCall()) 61 return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError); 62 63 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) 64 return args.Holder(); 65 66 // Get the script execution context. 67 ScriptExecutionContext* context = getScriptExecutionContext(); 68 if (!context) 69 return throwError("Blob constructor associated document is unavailable", V8Proxy::ReferenceError); 70 71 if (!args.Length()) 72 RefPtr<Blob> blob = Blob::create(); 73 return toV8(blob.get(), args.GetIsolate()); 74 } 75 76 v8::Local<v8::Value> firstArg = args[0]; 77 if (!firstArg->IsArray()) 78 return throwError("First argument of the constructor is not of type Array", V8Proxy::TypeError); 79 80 EXCEPTION_BLOCK(v8::Local<v8::Array>, blobParts, v8::Local<v8::Array>::Cast(firstArg)); 81 82 String type; 83 String endings = "transparent"; 84 85 if (args.Length() > 1 && args[1]->IsObject()) { 86 Dictionary dictionary(args[1]); 87 88 v8::TryCatch tryCatchType; 89 dictionary.get("type", type); 90 if (tryCatchType.HasCaught()) 91 return throwError(tryCatchType.Exception()); 92 93 v8::TryCatch tryCatchEndings; 94 bool containsEndings = dictionary.get("endings", endings); 95 if (tryCatchEndings.HasCaught()) 96 return throwError(tryCatchEndings.Exception()); 97 98 if (containsEndings) { 99 if (endings != "transparent" && endings != "native") { 100 V8Proxy::setDOMException(INVALID_STATE_ERR); 101 return v8::Undefined(); 102 } 103 } 104 } 105 106 ASSERT(endings == "transparent" || endings == "native"); 107 108 RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create(); 109 for (uint32_t i = 0; i < blobParts->Length(); ++i) { 110 v8::Local<v8::Value> item = blobParts->Get(v8::Uint32::New(i)); 111 ASSERT(!item.IsEmpty()); 112 #if ENABLE(BLOB) 113 if (V8ArrayBuffer::HasInstance(item)) { 114 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item)); 115 ASSERT(arrayBuffer); 116 blobBuilder->append(arrayBuffer); 117 } else 118 #endif 119 if (V8Blob::HasInstance(item)) { 120 Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item)); 121 ASSERT(blob); 122 blobBuilder->append(blob); 123 } else { 124 EXCEPTION_BLOCK(String, stringValue, toWebCoreString(item->ToString())); 125 blobBuilder->append(stringValue, endings, ASSERT_NO_EXCEPTION); 126 } 127 } 128 129 RefPtr<Blob> blob = blobBuilder->getBlob(type); 130 return toV8(blob.get(), args.GetIsolate()); 131 } 132 52 133 } // namespace WebCore -
trunk/Source/WebCore/fileapi/Blob.cpp
r115491 r115582 37 37 38 38 namespace WebCore { 39 40 Blob::Blob() 41 : m_size(0) 42 { 43 OwnPtr<BlobData> blobData = BlobData::create(); 44 45 // Create a new internal URL and register it with the provided blob data. 46 m_internalURL = BlobURL::createInternalURL(); 47 ThreadableBlobRegistry::registerBlobURL(m_internalURL, blobData.release()); 48 } 39 49 40 50 Blob::Blob(PassOwnPtr<BlobData> blobData, long long size) -
trunk/Source/WebCore/fileapi/Blob.h
r115491 r115582 44 44 class Blob : public RefCounted<Blob> { 45 45 public: 46 static PassRefPtr<Blob> create() 47 { 48 return adoptRef(new Blob); 49 } 50 46 51 static PassRefPtr<Blob> create(PassOwnPtr<BlobData> blobData, long long size) 47 52 { … … 68 73 69 74 protected: 75 Blob(); 70 76 Blob(PassOwnPtr<BlobData>, long long size); 71 77 -
trunk/Source/WebCore/fileapi/Blob.idl
r115491 r115582 34 34 JSGenerateIsReachable=Impl, 35 35 CustomToJSObject, 36 JSNoStaticTables 36 JSNoStaticTables, 37 CustomConstructor, 38 ConstructorParameters=2 37 39 ] Blob { 38 40 readonly attribute unsigned long long size; -
trunk/Source/WebCore/workers/WorkerContext.idl
r115491 r115582 85 85 #if defined(ENABLE_BLOB) && ENABLE_BLOB 86 86 attribute WebKitBlobBuilderConstructor WebKitBlobBuilder; 87 attribute BlobConstructor Blob; 87 88 attribute FileReaderConstructor FileReader; 88 89 attribute FileReaderSyncConstructor FileReaderSync;
Note:
See TracChangeset
for help on using the changeset viewer.