IDB: Date objects don't work as keys or values.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Nov 2015 04:34:49 +0000 (04:34 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Nov 2015 04:34:49 +0000 (04:34 +0000)
commit69edbea3c98d72cb8b3b905f5c289e2d72fd6316
treeb909fdc91ee790529168a5b7659b99b5d08cd8e4
parent04acd810b215a6c59511192991ce77200499e5b1
IDB: Date objects don't work as keys or values.
https://bugs.webkit.org/show_bug.cgi?id=150743

Reviewed by Darin Adler.

Source/WebCore:

Test: storage/indexeddb/modern/date-basic.html

The combination of the autogenerated bindings with Deprecated::ScriptValue was
losing the fidelity of "Date" objects being Dates, and not just normal Objects.

This was breaking their usage as IDBKeys.

Custom binding + reworking the IDBObjectStore IDLs to use JSValue instead of ScriptValue
fixes this handily.

* Modules/indexeddb/IDBObjectStore.h:
* Modules/indexeddb/IDBObjectStore.idl:

* Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
(WebCore::IDBClient::IDBObjectStore::add):
(WebCore::IDBClient::IDBObjectStore::put):
(WebCore::IDBClient::IDBObjectStore::putOrAdd):
* Modules/indexeddb/client/IDBObjectStoreImpl.h:

* Modules/indexeddb/legacy/LegacyObjectStore.cpp:
(WebCore::LegacyObjectStore::add):
(WebCore::LegacyObjectStore::put):
* Modules/indexeddb/legacy/LegacyObjectStore.h:

* bindings/js/IDBBindingUtilities.cpp:
(WebCore::internalCreateIDBKeyFromScriptValueAndKeyPath):
(WebCore::maybeCreateIDBKeyFromScriptValueAndKeyPath):
(WebCore::canInjectIDBKeyIntoScriptValue):
(WebCore::scriptValueToIDBKey):
* bindings/js/IDBBindingUtilities.h:

* bindings/js/JSIDBObjectStoreCustom.cpp:
(WebCore::putOrAdd):
(WebCore::JSIDBObjectStore::putRecord):
(WebCore::JSIDBObjectStore::add):

LayoutTests:

* storage/indexeddb/modern/date-basic-expected.txt: Added.
* storage/indexeddb/modern/date-basic.html: Added.
* storage/indexeddb/modern/get-keyrange-expected.txt:
* storage/indexeddb/modern/get-keyrange.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191850 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/modern/date-basic-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/date-basic.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/get-keyrange-expected.txt
LayoutTests/storage/indexeddb/modern/get-keyrange.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBObjectStore.h
Source/WebCore/Modules/indexeddb/IDBObjectStore.idl
Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h
Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.cpp
Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.h
Source/WebCore/bindings/js/IDBBindingUtilities.cpp
Source/WebCore/bindings/js/IDBBindingUtilities.h
Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp