Autogenerated IDBFactory.open() does the wrong thing if you pass an explicit 'undefin...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Apr 2016 00:27:30 +0000 (00:27 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Apr 2016 00:27:30 +0000 (00:27 +0000)
commit1a7ecbe733367e42404d6d5eeb41524157119711
treec164863e8540dac43fc64fb55ebcb7ed7f3c8258
parent0db2b28692b6291d8ee66fdbd5a0b09e99d43a44
Autogenerated IDBFactory.open() does the wrong thing if you pass an explicit 'undefined' as the second argument
https://bugs.webkit.org/show_bug.cgi?id=156939

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Re-sync tests from upstream b1818929.

* IndexedDB-private-browsing/idbfactory_open9-expected.txt:
* IndexedDB-private-browsing/idbfactory_open9.html:
* web-platform-tests/IndexedDB/idbfactory_open9-expected.txt:
* web-platform-tests/IndexedDB/idbfactory_open9.htm:

Source/WebCore:

As per WebIDL, if undefined is passed by JS for an optional parameter then
we should use its default value if it has one, or use the special value
"missing":
http://heycam.github.io/webidl/#es-overloads (step 10.4)

Our bindings generator was already mapping undefined to the parameter's
default value when present. However, it was missing the notion of
"missing" value when there no default value. This patch adds supports
for its by passing Optional<>(Nullopt) to the implementation in such
case. This means that the implementation will need to use WTF::Optional<>
type for parameters that do not have a default value. Thankfully though,
in most cases, we will be able to specify a default value in the IDL
so cases where we will need to use WTF::Optional<> will actually be
rare.

To avoid having to do too much refactoring in this patch, the support
for WTF::Optional is currently blacklisted for most IDL types. I will
gradually stop blacklisting each type in follow-up patches, as I either:
- Add default parameter values in our IDL (preferred)
- Use WTF::Optional<> in our implementation (when we cannot specify a
  default value).

This patch fixes a bug with IDBFactory.open()'s second parameter (version)
for which undefined should not throw and indicate that the version
should not be changed. We now use WTF::Optional in the implementation to
distinguish this case and not throw.

No new tests, existing tests were updated / rebaselined.

* Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::open):
(WebCore::IDBFactory::openInternal): Deleted.
* Modules/indexeddb/IDBFactory.h:
* bindings/scripts/CodeGeneratorJS.pm:
(ShouldUseWTFOptionalForParameterType):
(GenerateParametersCheck):
* fileapi/Blob.idl:
* inspector/InspectorIndexedDBAgent.cpp:

LayoutTests:

Update / rebaseline existing test now that passing undefined as second parameter to
IDBFactory.open() no longer throws.

* storage/indexeddb/intversion-bad-parameters-expected.txt:
* storage/indexeddb/intversion-bad-parameters-private-expected.txt:
* storage/indexeddb/resources/intversion-bad-parameters.js:
(deleteSuccess):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@199970 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/IndexedDB-private-browsing/idbfactory_open9-expected.txt
LayoutTests/imported/w3c/IndexedDB-private-browsing/idbfactory_open9.html
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbfactory_open9-expected.txt
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbfactory_open9.htm
LayoutTests/storage/indexeddb/intversion-bad-parameters-expected.txt
LayoutTests/storage/indexeddb/intversion-bad-parameters-private-expected.txt
LayoutTests/storage/indexeddb/resources/intversion-bad-parameters.js
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBFactory.cpp
Source/WebCore/Modules/indexeddb/IDBFactory.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/bindings/scripts/test/TestTypedefs.idl
Source/WebCore/fileapi/Blob.idl
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp