[Chromium] IndexedDB: Assertion failure when storing File objects
authorjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 19:26:00 +0000 (19:26 +0000)
committerjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 19:26:00 +0000 (19:26 +0000)
commitb7b736551d1f76ba5b2baf815d47e268758c2172
tree1fb50e92e1707ded7d25a7096eb4832fd8a126eb
parent7d1fef508ec1c1801b8ce14b1d6ef317894911fc
[Chromium] IndexedDB: Assertion failure when storing File objects
https://bugs.webkit.org/show_bug.cgi?id=76746

Source/WebCore:

The blob data in Blob/File/FileList objects is serialized "by reference" (the
internal URL) rather than "by value" (the actual data); this is sufficient for
postMessage() but not for IndexedDB since the referenced data is not retained
Expose a mechanism to enumerate the URLs so that SSVs can be rejected by IDB
until blob data serialization can is implemented (outside the SSV mechanism, and
potentially asynchronously).

Also, correct issue in V8DOMWrapper::instantiateV8Object where context is assumed
to be a Worker context if it's not a Window, which is incorrect for the
Chromium utility process; this is hit if Blobs are not blocked.

Reviewed by Tony Chang.

Test: storage/indexeddb/noblobs.html

* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::update): Reject SSVs that contain blob references.
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::add): Reject SSVs that contain blob references.
(WebCore::IDBObjectStore::put): Reject SSVs that contain blob references.
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::serialize):
(WebCore::CloneSerializer::CloneSerializer):
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneSerializer::write):
(CloneSerializer):
(WebCore::SerializedScriptValue::SerializedScriptValue):
(WebCore::SerializedScriptValue::create):
(WebCore::SerializedScriptValue::undefinedValue):
(WebCore::SerializedScriptValue::booleanValue):
* bindings/js/SerializedScriptValue.h: New API to enable the clients to be picky.
* bindings/v8/SerializedScriptValue.cpp:
(WebCore::SerializedScriptValue::SerializedScriptValue):
* bindings/v8/SerializedScriptValue.h: New API to enable the clients to be picky.
(WebCore::SerializedScriptValue::blobURLs):
(SerializedScriptValue):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::instantiateV8Object):  Ensure context is a worker context before treating it as such.

LayoutTests:

Ensure that Blob/File/FileList types are rejected in IDB values, to detect regressions.

Reviewed by Tony Chang.

* storage/indexeddb/noblobs-expected.txt: Added.
* storage/indexeddb/noblobs.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/noblobs-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/noblobs.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/bindings/js/SerializedScriptValue.h
Source/WebCore/bindings/v8/SerializedScriptValue.cpp
Source/WebCore/bindings/v8/SerializedScriptValue.h
Source/WebCore/bindings/v8/V8DOMWrapper.cpp