Change IDBObjectStore.createIndex to take an IDL dictionary
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2016 20:04:58 +0000 (20:04 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2016 20:04:58 +0000 (20:04 +0000)
commit09ca504abb63ee27a9bd280c914db493af728ccf
treee8698e2e3f670b966aa3c35badcdaf3fb4f39532
parenta86f2f8cff55adb4150b85d0307d9bd7514e474b
Change IDBObjectStore.createIndex to take an IDL dictionary
https://bugs.webkit.org/show_bug.cgi?id=157520

Reviewed by Chris Dumez.

Source/WebCore:

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::createObjectStore): Use IDBKeyPath::Type instead of
IndexedDB::KeyPathType.
* Modules/indexeddb/IDBKeyPath.cpp:
(WebCore::IDBKeyPath::IDBKeyPath): Ditto.
(WebCore::IDBKeyPath::isValid): Ditto.
(WebCore::IDBKeyPath::operator==): Ditto.
(WebCore::IDBKeyPath::encode): Ditto.
(WebCore::IDBKeyPath::decode): Ditto.

* Modules/indexeddb/IDBKeyPath.h: Use pragma once. Make constructors non-explicit so
we can just pass a string or vector and have it turn into an IDBKeyPath. Added an enum
class named Type here and use it instead of IndexedDB::KeyPathType.

* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::openCursor): Remove unneeded local variable.
(WebCore::IDBObjectStore::get): Ditto.
(WebCore::IDBObjectStore::doDelete): Ditto.
(WebCore::IDBObjectStore::createIndex): Changed argument type to take IndexParameters
instead of two seaparate booleans. Also updated to use IDBKeyPath::Type.

* Modules/indexeddb/IDBObjectStore.h: Removed include of IndexedDB, using a forward
decalration instead. Marked the class final. Added an IndexParameters struct and used
it for the argument to createIndex.

* Modules/indexeddb/IDBObjectStore.idl: Stopped using Custom for put, add, and
createIndex functions. Stopped using Dictionary for createIndex, using IDBIndexParameters
instead as in the specification. Added IDBIndexParameters dictionary definition.

* Modules/indexeddb/IndexedDB.h: Use pragma once. Removed KeyPathType.

* bindings/js/IDBBindingUtilities.cpp:
(WebCore::injectIDBKeyIntoScriptValue): Use IDBKeyPath::Type instead of
IndexedDB::KeyPathType.
(WebCore::maybeCreateIDBKeyFromScriptValueAndKeyPath): Ditto.
(WebCore::canInjectIDBKeyIntoScriptValue): Ditto.
(WebCore::createKeyPathArray): Ditto.
(WebCore::toJS): Ditto.
* bindings/js/JSIDBObjectStoreCustom.cpp:
(WebCore::putOrAdd): Deleted.
(WebCore::JSIDBObjectStore::putFunction): Deleted.
(WebCore::JSIDBObjectStore::add): Deleted.
(WebCore::JSIDBObjectStore::createIndex): Deleted.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheckExpression): Fixed code that generates a type check for
wrappers to only check types is knows how to check: wrappers and arrays, including
typed arrays. This prevents it from trying to check dictionaries.

* inspector/InspectorIndexedDBAgent.cpp: Use IDBKeyPath::Type instead of
IndexedDB::KeyPathType.

LayoutTests:

* storage/indexeddb/deleteIndex-bug110792-expected.txt: Updated result.
Test is still marked as flaky, but this is the proper expectation now.
Discovered this when I accidentally reset results for the whole directory.
* storage/indexeddb/deleteIndex-bug110792-private-expected.txt: Ditto.

* storage/indexeddb/index-basics-expected.txt: Updated to expect the simpler
type error that is generated by the bindings code as opposed to the hand written
binding. If we want to make this fancier like this for all bindings we can do
that the future in the bindings script.
* storage/indexeddb/index-basics-private-expected.txt: Ditto.
* storage/indexeddb/index-basics-workers-expected.txt: Ditto.

* storage/indexeddb/keypath-basics-expected.txt: Updated for the change that
expects null and undefined the be legal key paths. See below.
* storage/indexeddb/keypath-basics-private-expected.txt: Ditto.

* storage/indexeddb/modern/create-index-failures-expected.txt: Removed
expected results that require that we forbid null for the name and key path.
See below.
* storage/indexeddb/modern/create-index-failures-private-expected.txt: Ditto.

* storage/indexeddb/modern/resources/create-index-failures.js: Removed the test
that expects failure when null is passed for the name and key path. In both
cases, the Web IDL and IDB specifications call for the null value to be converted
to the string "null", not an exception.

* storage/indexeddb/resources/keypath-basics.js:
(prepareDatabase): Added tests for both undefined and null. Both are legal values for
the key path argument to createIndex. The Web IDL and IDB specifications call for
them to be converted to the strings "undefined" and "null", not to trigger exceptions.
(testInvalidKeyPaths): Removed tests that expect exceptions when calling createIndex
with undefined and null.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200699 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/deleteIndex-bug110792-expected.txt
LayoutTests/storage/indexeddb/deleteIndex-bug110792-private-expected.txt
LayoutTests/storage/indexeddb/index-basics-expected.txt
LayoutTests/storage/indexeddb/index-basics-private-expected.txt
LayoutTests/storage/indexeddb/index-basics-workers-expected.txt
LayoutTests/storage/indexeddb/keypath-basics-expected.txt
LayoutTests/storage/indexeddb/keypath-basics-private-expected.txt
LayoutTests/storage/indexeddb/modern/create-index-failures-expected.txt
LayoutTests/storage/indexeddb/modern/create-index-failures-private-expected.txt
LayoutTests/storage/indexeddb/modern/resources/create-index-failures.js
LayoutTests/storage/indexeddb/resources/keypath-basics.js
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp
Source/WebCore/Modules/indexeddb/IDBKeyPath.h
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.h
Source/WebCore/Modules/indexeddb/IDBObjectStore.idl
Source/WebCore/Modules/indexeddb/IndexedDB.h
Source/WebCore/bindings/js/IDBBindingUtilities.cpp
Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp