Diff
Modified: trunk/LayoutTests/ChangeLog (119790 => 119791)
--- trunk/LayoutTests/ChangeLog 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/ChangeLog 2012-06-08 03:15:27 UTC (rev 119791)
@@ -1,3 +1,22 @@
+2012-06-07 Li Yin <[email protected]>
+
+ FileAPI: Blob should support ArrayBufferView instead of ArrayBuffer for Constructor Parameters
+ https://bugs.webkit.org/show_bug.cgi?id=88294
+
+ Reviewed by Jian Li.
+
+ Support ArrayBufferView in Blob constructing function.
+
+ * fast/files/blob-constructor-expected.txt:
+ * fast/files/file-reader-fffd-expected.txt:
+ * fast/files/file-reader-fffd.html:
+ * fast/files/script-tests/blob-constructor.js:
+ * http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html:
+ * http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:
+ * http/tests/websocket/tests/hybi/send-blob.html:
+ * http/tests/websocket/tests/hybi/workers/resources/send-blob.js:
+ (createBlobContainingAllDistinctBytes):
+
2012-06-07 MORITA Hajime <[email protected]>
A style in an older shadow subtree causes assert when composing with <shadow>
Modified: trunk/LayoutTests/fast/files/blob-constructor-expected.txt (119790 => 119791)
--- trunk/LayoutTests/fast/files/blob-constructor-expected.txt 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/fast/files/blob-constructor-expected.txt 2012-06-08 03:15:27 UTC (rev 119791)
@@ -13,7 +13,6 @@
PASS new Blob('hello') threw exception TypeError: First argument of the constructor is not of type Array.
PASS new Blob(0) threw exception TypeError: First argument of the constructor is not of type Array.
PASS (new Blob([])) instanceof window.Blob is true
-PASS (new Blob([new ArrayBuffer(8)])) instanceof window.Blob is true
PASS (new Blob(['stringPrimitive'])) instanceof window.Blob is true
PASS (new Blob([String('stringObject')])) instanceof window.Blob is true
PASS (new Blob([new Blob])) instanceof window.Blob is true
@@ -44,6 +43,18 @@
PASS (new Blob([], {type:'text/html'})).type is 'text/html'
PASS (new Blob([], {type:'text/html'})).size is 0
PASS window.Blob.length is 2
+PASS new Blob([new DataView(new ArrayBuffer(100))]).size is 100
+PASS new Blob([new Uint8Array(100)]).size is 100
+PASS new Blob([new Uint8ClampedArray(100)]).size is 100
+PASS new Blob([new Uint16Array(100)]).size is 200
+PASS new Blob([new Uint32Array(100)]).size is 400
+PASS new Blob([new Int8Array(100)]).size is 100
+PASS new Blob([new Int16Array(100)]).size is 200
+PASS new Blob([new Int32Array(100)]).size is 400
+PASS new Blob([new Float32Array(100)]).size is 400
+PASS new Blob([new Float64Array(100)]).size is 800
+PASS new Blob([new Float64Array(100), new Int32Array(100), new Uint8Array(100), new DataView(new ArrayBuffer(100))]).size is 1400
+PASS new Blob([new Blob([new Int32Array(100)]), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size is 1000
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/files/file-reader-fffd-expected.txt (119790 => 119791)
--- trunk/LayoutTests/fast/files/file-reader-fffd-expected.txt 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/fast/files/file-reader-fffd-expected.txt 2012-06-08 03:15:27 UTC (rev 119791)
@@ -3,7 +3,7 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
array = new Uint8Array([65, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 66]);
-blob = new Blob([array.buffer]);
+blob = new Blob([array]);
reader = new FileReader();
reader.readAsText(blob);
PASS fileString is 'A�����������B'
Modified: trunk/LayoutTests/fast/files/file-reader-fffd.html (119790 => 119791)
--- trunk/LayoutTests/fast/files/file-reader-fffd.html 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/fast/files/file-reader-fffd.html 2012-06-08 03:15:27 UTC (rev 119791)
@@ -11,7 +11,7 @@
description("Throw various bad bytes at file reader.");
array = evalAndLog("array = new Uint8Array([65, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 66]);");
-blob = evalAndLog("blob = new Blob([array.buffer]);");
+blob = evalAndLog("blob = new Blob([array]);");
reader = evalAndLog("reader = new FileReader();");
reader._onload_ = function(event) {
fileString = event.target.result;
Modified: trunk/LayoutTests/fast/files/script-tests/blob-constructor.js (119790 => 119791)
--- trunk/LayoutTests/fast/files/script-tests/blob-constructor.js 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/fast/files/script-tests/blob-constructor.js 2012-06-08 03:15:27 UTC (rev 119791)
@@ -15,7 +15,6 @@
// Test valid blob parts.
shouldBeTrue("(new Blob([])) instanceof window.Blob");
-shouldBeTrue("(new Blob([new ArrayBuffer(8)])) instanceof window.Blob");
shouldBeTrue("(new Blob(['stringPrimitive'])) instanceof window.Blob");
shouldBeTrue("(new Blob([String('stringObject')])) instanceof window.Blob");
shouldBeTrue("(new Blob([new Blob])) instanceof window.Blob");
@@ -64,3 +63,17 @@
// Odds and ends
shouldBe("window.Blob.length", "2");
+
+// Test ArrayBufferView Parameters
+shouldBe("new Blob([new DataView(new ArrayBuffer(100))]).size", "100");
+shouldBe("new Blob([new Uint8Array(100)]).size", "100");
+shouldBe("new Blob([new Uint8ClampedArray(100)]).size", "100");
+shouldBe("new Blob([new Uint16Array(100)]).size", "200");
+shouldBe("new Blob([new Uint32Array(100)]).size", "400");
+shouldBe("new Blob([new Int8Array(100)]).size", "100");
+shouldBe("new Blob([new Int16Array(100)]).size", "200");
+shouldBe("new Blob([new Int32Array(100)]).size", "400");
+shouldBe("new Blob([new Float32Array(100)]).size", "400");
+shouldBe("new Blob([new Float64Array(100)]).size", "800");
+shouldBe("new Blob([new Float64Array(100), new Int32Array(100), new Uint8Array(100), new DataView(new ArrayBuffer(100))]).size", "1400");
+shouldBe("new Blob([new Blob([new Int32Array(100)]), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size", "1000");
Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html (119790 => 119791)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html 2012-06-08 03:15:27 UTC (rev 119791)
@@ -23,7 +23,7 @@
function createBlobWithLength(length)
{
- return new Blob([new ArrayBuffer(length)]);
+ return new Blob([new Uint8Array(length)]);
}
var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/echo");
Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html (119790 => 119791)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html 2012-06-08 03:15:27 UTC (rev 119791)
@@ -23,7 +23,7 @@
function createBlobWithLength(length)
{
- return new Blob([new ArrayBuffer(length)]);
+ return new Blob([new Uint8Array(length)]);
}
var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/simple");
Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/send-blob.html (119790 => 119791)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/send-blob.html 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/send-blob.html 2012-06-08 03:15:27 UTC (rev 119791)
@@ -33,7 +33,7 @@
var array = new Uint8Array(256);
for (var i = 0; i < 256; ++i)
array[i] = i;
- return new Blob([array.buffer]);
+ return new Blob([array]);
}
var url = ""
Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/workers/resources/send-blob.js (119790 => 119791)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/workers/resources/send-blob.js 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/workers/resources/send-blob.js 2012-06-08 03:15:27 UTC (rev 119791)
@@ -13,7 +13,7 @@
var array = new Uint8Array(256);
for (var i = 0; i < 256; ++i)
array[i] = i;
- return new Blob([array.buffer]);
+ return new Blob([array]);
}
var url = ""
Modified: trunk/Source/WebCore/ChangeLog (119790 => 119791)
--- trunk/Source/WebCore/ChangeLog 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/Source/WebCore/ChangeLog 2012-06-08 03:15:27 UTC (rev 119791)
@@ -1,3 +1,28 @@
+2012-06-07 Li Yin <[email protected]>
+
+ FileAPI: Blob should support ArrayBufferView instead of ArrayBuffer for Constructor Parameters
+ https://bugs.webkit.org/show_bug.cgi?id=88294
+
+ Reviewed by Jian Li.
+
+ From Spec: http://dev.w3.org/2006/webapi/FileAPI/#dfn-Blob
+ Currently we add the support for ArrayBufferView, while still keeping ArrayBuffer for
+ backward compatibility. We will remove it in the near future.
+
+ Test: fast/files/blob-constructor.html
+
+ * bindings/js/JSBlobCustom.cpp:
+ (WebCore::JSBlobConstructor::constructJSBlob):
+ * bindings/v8/custom/V8BlobCustom.cpp:
+ (WebCore::V8Blob::constructorCallback):
+ * fileapi/WebKitBlobBuilder.cpp:
+ (WebCore::WebKitBlobBuilder::append):
+ (WebCore):
+ * fileapi/WebKitBlobBuilder.h:
+ (WebCore):
+ (WebKitBlobBuilder):
+ * fileapi/WebKitBlobBuilder.idl: Add support for ArrayBufferView in append method
+
2012-06-07 MORITA Hajime <[email protected]>
A style in an older shadow subtree causes assert when composing with <shadow>
Modified: trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp (119790 => 119791)
--- trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp 2012-06-08 03:15:27 UTC (rev 119791)
@@ -35,6 +35,7 @@
#include "ExceptionCode.h"
#include "ExceptionCodePlaceholder.h"
#include "JSArrayBuffer.h"
+#include "JSArrayBufferView.h"
#include "JSDOMBinding.h"
#include "JSDictionary.h"
#include "JSFile.h"
@@ -119,7 +120,9 @@
JSValue item = array->getIndex(i);
#if ENABLE(BLOB)
if (item.inherits(&JSArrayBuffer::s_info))
- blobBuilder->append(toArrayBuffer(item));
+ blobBuilder->append(context, toArrayBuffer(item));
+ else if (item.inherits(&JSArrayBufferView::s_info))
+ blobBuilder->append(toArrayBufferView(item));
else
#endif
if (item.inherits(&JSBlob::s_info))
Modified: trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp (119790 => 119791)
--- trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-06-08 03:15:27 UTC (rev 119791)
@@ -33,6 +33,7 @@
#include "Dictionary.h"
#include "V8ArrayBuffer.h"
+#include "V8ArrayBufferView.h"
#include "V8Binding.h"
#include "V8BindingMacros.h"
#include "V8Blob.h"
@@ -120,7 +121,11 @@
if (V8ArrayBuffer::HasInstance(item)) {
ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item));
ASSERT(arrayBuffer);
- blobBuilder->append(arrayBuffer);
+ blobBuilder->append(context, arrayBuffer);
+ } else if (V8ArrayBufferView::HasInstance(item)) {
+ ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(item));
+ ASSERT(arrayBufferView);
+ blobBuilder->append(arrayBufferView);
} else
#endif
if (V8Blob::HasInstance(item)) {
Modified: trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp (119790 => 119791)
--- trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/Source/WebCore/fileapi/WebKitBlobBuilder.cpp 2012-06-08 03:15:27 UTC (rev 119791)
@@ -36,8 +36,10 @@
#include "ExceptionCode.h"
#include "File.h"
#include "LineEnding.h"
+#include "ScriptExecutionContext.h"
#include "TextEncoding.h"
#include <wtf/ArrayBuffer.h>
+#include <wtf/ArrayBufferView.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/AtomicString.h>
@@ -86,8 +88,10 @@
}
#if ENABLE(BLOB)
-void WebKitBlobBuilder::append(ArrayBuffer* arrayBuffer)
+void WebKitBlobBuilder::append(ScriptExecutionContext* context, ArrayBuffer* arrayBuffer)
{
+ String consoleMessage("ArrayBuffer values are deprecated in Blob Constructor. Use ArrayBufferView instead.");
+ context->addConsoleMessage(JSMessageSource, LogMessageType, WarningMessageLevel, consoleMessage);
if (!arrayBuffer)
return;
Vector<char>& buffer = getBuffer();
@@ -95,6 +99,16 @@
buffer.append(static_cast<const char*>(arrayBuffer->data()), arrayBuffer->byteLength());
m_size += buffer.size() - oldSize;
}
+
+void WebKitBlobBuilder::append(ArrayBufferView* arrayBufferView)
+{
+ if (!arrayBufferView)
+ return;
+ Vector<char>& buffer = getBuffer();
+ size_t oldSize = buffer.size();
+ buffer.append(static_cast<const char*>(arrayBufferView->baseAddress()), arrayBufferView->byteLength());
+ m_size += buffer.size() - oldSize;
+}
#endif
void WebKitBlobBuilder::append(Blob* blob)
Modified: trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h (119790 => 119791)
--- trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/Source/WebCore/fileapi/WebKitBlobBuilder.h 2012-06-08 03:15:27 UTC (rev 119791)
@@ -38,6 +38,7 @@
namespace WebCore {
class Blob;
+class ScriptExecutionContext;
class TextEncoding;
typedef int ExceptionCode;
@@ -50,7 +51,8 @@
void append(const String& text, ExceptionCode&);
void append(const String& text, const String& ending, ExceptionCode&);
#if ENABLE(BLOB)
- void append(ArrayBuffer*);
+ void append(ScriptExecutionContext*, ArrayBuffer*);
+ void append(ArrayBufferView*);
#endif
PassRefPtr<Blob> getBlob(const String& contentType = String());
Modified: trunk/Source/WebCore/fileapi/WebKitBlobBuilder.idl (119790 => 119791)
--- trunk/Source/WebCore/fileapi/WebKitBlobBuilder.idl 2012-06-08 03:13:24 UTC (rev 119790)
+++ trunk/Source/WebCore/fileapi/WebKitBlobBuilder.idl 2012-06-08 03:15:27 UTC (rev 119791)
@@ -40,7 +40,8 @@
#endif
void append(in Blob blob);
#if defined(ENABLE_BLOB) && ENABLE_BLOB
- void append(in ArrayBuffer arrayBuffer);
+ [CallWith=ScriptExecutionContext] void append(in ArrayBuffer arrayBuffer);
+ void append(in ArrayBufferView arrayBufferView);
#endif
void append(in DOMString value, in [Optional, TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString endings) raises (DOMException);
};