Changeset 119791 in webkit
- Timestamp:
- Jun 7, 2012 8:15:27 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r119790 r119791 1 2012-06-07 Li Yin <li.yin@intel.com> 2 3 FileAPI: Blob should support ArrayBufferView instead of ArrayBuffer for Constructor Parameters 4 https://bugs.webkit.org/show_bug.cgi?id=88294 5 6 Reviewed by Jian Li. 7 8 Support ArrayBufferView in Blob constructing function. 9 10 * fast/files/blob-constructor-expected.txt: 11 * fast/files/file-reader-fffd-expected.txt: 12 * fast/files/file-reader-fffd.html: 13 * fast/files/script-tests/blob-constructor.js: 14 * http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html: 15 * http/tests/websocket/tests/hybi/bufferedAmount-after-close.html: 16 * http/tests/websocket/tests/hybi/send-blob.html: 17 * http/tests/websocket/tests/hybi/workers/resources/send-blob.js: 18 (createBlobContainingAllDistinctBytes): 19 1 20 2012-06-07 MORITA Hajime <morrita@google.com> 2 21 -
trunk/LayoutTests/fast/files/blob-constructor-expected.txt
r119702 r119791 14 14 PASS new Blob(0) threw exception TypeError: First argument of the constructor is not of type Array. 15 15 PASS (new Blob([])) instanceof window.Blob is true 16 PASS (new Blob([new ArrayBuffer(8)])) instanceof window.Blob is true17 16 PASS (new Blob(['stringPrimitive'])) instanceof window.Blob is true 18 17 PASS (new Blob([String('stringObject')])) instanceof window.Blob is true … … 45 44 PASS (new Blob([], {type:'text/html'})).size is 0 46 45 PASS window.Blob.length is 2 46 PASS new Blob([new DataView(new ArrayBuffer(100))]).size is 100 47 PASS new Blob([new Uint8Array(100)]).size is 100 48 PASS new Blob([new Uint8ClampedArray(100)]).size is 100 49 PASS new Blob([new Uint16Array(100)]).size is 200 50 PASS new Blob([new Uint32Array(100)]).size is 400 51 PASS new Blob([new Int8Array(100)]).size is 100 52 PASS new Blob([new Int16Array(100)]).size is 200 53 PASS new Blob([new Int32Array(100)]).size is 400 54 PASS new Blob([new Float32Array(100)]).size is 400 55 PASS new Blob([new Float64Array(100)]).size is 800 56 PASS new Blob([new Float64Array(100), new Int32Array(100), new Uint8Array(100), new DataView(new ArrayBuffer(100))]).size is 1400 57 PASS new Blob([new Blob([new Int32Array(100)]), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size is 1000 47 58 PASS successfullyParsed is true 48 59 -
trunk/LayoutTests/fast/files/file-reader-fffd-expected.txt
r115582 r119791 4 4 5 5 array = new Uint8Array([65, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 66]); 6 blob = new Blob([array .buffer]);6 blob = new Blob([array]); 7 7 reader = new FileReader(); 8 8 reader.readAsText(blob); -
trunk/LayoutTests/fast/files/file-reader-fffd.html
r115582 r119791 12 12 13 13 array = evalAndLog("array = new Uint8Array([65, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 66]);"); 14 blob = evalAndLog("blob = new Blob([array .buffer]);");14 blob = evalAndLog("blob = new Blob([array]);"); 15 15 reader = evalAndLog("reader = new FileReader();"); 16 16 reader.onload = function(event) { -
trunk/LayoutTests/fast/files/script-tests/blob-constructor.js
r119702 r119791 16 16 // Test valid blob parts. 17 17 shouldBeTrue("(new Blob([])) instanceof window.Blob"); 18 shouldBeTrue("(new Blob([new ArrayBuffer(8)])) instanceof window.Blob");19 18 shouldBeTrue("(new Blob(['stringPrimitive'])) instanceof window.Blob"); 20 19 shouldBeTrue("(new Blob([String('stringObject')])) instanceof window.Blob"); … … 65 64 // Odds and ends 66 65 shouldBe("window.Blob.length", "2"); 66 67 // Test ArrayBufferView Parameters 68 shouldBe("new Blob([new DataView(new ArrayBuffer(100))]).size", "100"); 69 shouldBe("new Blob([new Uint8Array(100)]).size", "100"); 70 shouldBe("new Blob([new Uint8ClampedArray(100)]).size", "100"); 71 shouldBe("new Blob([new Uint16Array(100)]).size", "200"); 72 shouldBe("new Blob([new Uint32Array(100)]).size", "400"); 73 shouldBe("new Blob([new Int8Array(100)]).size", "100"); 74 shouldBe("new Blob([new Int16Array(100)]).size", "200"); 75 shouldBe("new Blob([new Int32Array(100)]).size", "400"); 76 shouldBe("new Blob([new Float32Array(100)]).size", "400"); 77 shouldBe("new Blob([new Float64Array(100)]).size", "800"); 78 shouldBe("new Blob([new Float64Array(100), new Int32Array(100), new Uint8Array(100), new DataView(new ArrayBuffer(100))]).size", "1400"); 79 shouldBe("new Blob([new Blob([new Int32Array(100)]), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size", "1000"); -
trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html
r115582 r119791 24 24 function createBlobWithLength(length) 25 25 { 26 return new Blob([new ArrayBuffer(length)]);26 return new Blob([new Uint8Array(length)]); 27 27 } 28 28 -
trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html
r115582 r119791 24 24 function createBlobWithLength(length) 25 25 { 26 return new Blob([new ArrayBuffer(length)]);26 return new Blob([new Uint8Array(length)]); 27 27 } 28 28 -
trunk/LayoutTests/http/tests/websocket/tests/hybi/send-blob.html
r115582 r119791 34 34 for (var i = 0; i < 256; ++i) 35 35 array[i] = i; 36 return new Blob([array .buffer]);36 return new Blob([array]); 37 37 } 38 38 -
trunk/LayoutTests/http/tests/websocket/tests/hybi/workers/resources/send-blob.js
r115582 r119791 14 14 for (var i = 0; i < 256; ++i) 15 15 array[i] = i; 16 return new Blob([array .buffer]);16 return new Blob([array]); 17 17 } 18 18 -
trunk/Source/WebCore/ChangeLog
r119790 r119791 1 2012-06-07 Li Yin <li.yin@intel.com> 2 3 FileAPI: Blob should support ArrayBufferView instead of ArrayBuffer for Constructor Parameters 4 https://bugs.webkit.org/show_bug.cgi?id=88294 5 6 Reviewed by Jian Li. 7 8 From Spec: http://dev.w3.org/2006/webapi/FileAPI/#dfn-Blob 9 Currently we add the support for ArrayBufferView, while still keeping ArrayBuffer for 10 backward compatibility. We will remove it in the near future. 11 12 Test: fast/files/blob-constructor.html 13 14 * bindings/js/JSBlobCustom.cpp: 15 (WebCore::JSBlobConstructor::constructJSBlob): 16 * bindings/v8/custom/V8BlobCustom.cpp: 17 (WebCore::V8Blob::constructorCallback): 18 * fileapi/WebKitBlobBuilder.cpp: 19 (WebCore::WebKitBlobBuilder::append): 20 (WebCore): 21 * fileapi/WebKitBlobBuilder.h: 22 (WebCore): 23 (WebKitBlobBuilder): 24 * fileapi/WebKitBlobBuilder.idl: Add support for ArrayBufferView in append method 25 1 26 2012-06-07 MORITA Hajime <morrita@google.com> 2 27 -
trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp
r119702 r119791 36 36 #include "ExceptionCodePlaceholder.h" 37 37 #include "JSArrayBuffer.h" 38 #include "JSArrayBufferView.h" 38 39 #include "JSDOMBinding.h" 39 40 #include "JSDictionary.h" … … 120 121 #if ENABLE(BLOB) 121 122 if (item.inherits(&JSArrayBuffer::s_info)) 122 blobBuilder->append(toArrayBuffer(item)); 123 blobBuilder->append(context, toArrayBuffer(item)); 124 else if (item.inherits(&JSArrayBufferView::s_info)) 125 blobBuilder->append(toArrayBufferView(item)); 123 126 else 124 127 #endif -
trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp
r119702 r119791 34 34 #include "Dictionary.h" 35 35 #include "V8ArrayBuffer.h" 36 #include "V8ArrayBufferView.h" 36 37 #include "V8Binding.h" 37 38 #include "V8BindingMacros.h" … … 121 122 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item)); 122 123 ASSERT(arrayBuffer); 123 blobBuilder->append(arrayBuffer); 124 blobBuilder->append(context, arrayBuffer); 125 } else if (V8ArrayBufferView::HasInstance(item)) { 126 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(item)); 127 ASSERT(arrayBufferView); 128 blobBuilder->append(arrayBufferView); 124 129 } else 125 130 #endif -
trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp
r118394 r119791 37 37 #include "File.h" 38 38 #include "LineEnding.h" 39 #include "ScriptExecutionContext.h" 39 40 #include "TextEncoding.h" 40 41 #include <wtf/ArrayBuffer.h> 42 #include <wtf/ArrayBufferView.h> 41 43 #include <wtf/PassRefPtr.h> 42 44 #include <wtf/Vector.h> … … 87 89 88 90 #if ENABLE(BLOB) 89 void WebKitBlobBuilder::append( ArrayBuffer* arrayBuffer)91 void WebKitBlobBuilder::append(ScriptExecutionContext* context, ArrayBuffer* arrayBuffer) 90 92 { 93 String consoleMessage("ArrayBuffer values are deprecated in Blob Constructor. Use ArrayBufferView instead."); 94 context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, consoleMessage); 91 95 if (!arrayBuffer) 92 96 return; … … 94 98 size_t oldSize = buffer.size(); 95 99 buffer.append(static_cast<const char*>(arrayBuffer->data()), arrayBuffer->byteLength()); 100 m_size += buffer.size() - oldSize; 101 } 102 103 void WebKitBlobBuilder::append(ArrayBufferView* arrayBufferView) 104 { 105 if (!arrayBufferView) 106 return; 107 Vector<char>& buffer = getBuffer(); 108 size_t oldSize = buffer.size(); 109 buffer.append(static_cast<const char*>(arrayBufferView->baseAddress()), arrayBufferView->byteLength()); 96 110 m_size += buffer.size() - oldSize; 97 111 } -
trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h
r100227 r119791 39 39 40 40 class Blob; 41 class ScriptExecutionContext; 41 42 class TextEncoding; 42 43 … … 51 52 void append(const String& text, const String& ending, ExceptionCode&); 52 53 #if ENABLE(BLOB) 53 void append(ArrayBuffer*); 54 void append(ScriptExecutionContext*, ArrayBuffer*); 55 void append(ArrayBufferView*); 54 56 #endif 55 57 -
trunk/Source/WebCore/fileapi/WebKitBlobBuilder.idl
r115666 r119791 41 41 void append(in Blob blob); 42 42 #if defined(ENABLE_BLOB) && ENABLE_BLOB 43 void append(in ArrayBuffer arrayBuffer); 43 [CallWith=ScriptExecutionContext] void append(in ArrayBuffer arrayBuffer); 44 void append(in ArrayBufferView arrayBufferView); 44 45 #endif 45 46 void append(in DOMString value, in [Optional, TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString endings) raises (DOMException);
Note: See TracChangeset
for help on using the changeset viewer.