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)
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: https://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

index c0772d1..c5556e7 100644 (file)
@@ -1,3 +1,18 @@
+2016-04-24  Chris Dumez  <cdumez@apple.com>
+
+        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.
+
+        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):
+
 2016-04-23  Chris Dumez  <cdumez@apple.com>
 
         [WebIDL] Drop [Default] WebKit-IDL extended attribute
index b514c34..2224095 100644 (file)
@@ -1,3 +1,17 @@
+2016-04-24  Chris Dumez  <cdumez@apple.com>
+
+        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.
+
+        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:
+
 2016-04-23  Chris Dumez  <cdumez@apple.com>
 
         [WebIDL] Drop [Default] WebKit-IDL extended attribute
index 4ffc883..124f5d1 100644 (file)
@@ -9,7 +9,6 @@ PASS Calling open() with version argument NaN should throw TypeError.
 PASS Calling open() with version argument Infinity should throw TypeError. 
 PASS Calling open() with version argument -Infinity should throw TypeError. 
 PASS Calling open() with version argument "foo" should throw TypeError. 
-PASS Calling open() with version argument undefined should throw TypeError. 
 PASS Calling open() with version argument null should throw TypeError. 
 PASS Calling open() with version argument false should throw TypeError. 
 PASS Calling open() with version argument object should throw TypeError. 
@@ -17,4 +16,5 @@ PASS Calling open() with version argument object (second) should throw TypeError
 PASS Calling open() with version argument object (third) should throw TypeError. 
 PASS Calling open() with version argument 1.5 should not throw. 
 PASS Calling open() with version argument 9007199254740991 should not throw. 
+PASS Calling open() with version argument undefined should not throw. 
 
index 4b961b1..bd447e2 100644 (file)
@@ -2,7 +2,6 @@
 <title>IDBFactory.open() - errors in version argument</title>
 <script src="../../../resources/testharness.js"></script>
 <script src="../../../resources/testharnessreport.js"></script>
-<script src=support.js></script>
 
 <script>
 function should_throw(val, name) {
@@ -26,7 +25,6 @@ should_throw(NaN)
 should_throw(Infinity)
 should_throw(-Infinity)
 should_throw("foo")
-should_throw(undefined)
 should_throw(null)
 should_throw(false)
 
@@ -46,17 +44,27 @@ should_throw({
 
 /* Valid */
 
-function should_work(val) {
+function should_work(val, expected_version) {
     var name = format_value(val);
-    var t = async_test("Calling open() with version argument " + name + " should not throw.")
-    var rq = createdb(t, val)
-    rq.onupgradeneeded = function() {
-        t.done()
-    }
+    var dbname = 'test-db-does-not-exist';
+    async_test(function(t) {
+        window.indexedDB.deleteDatabase(dbname);
+        var rq = window.indexedDB.open(dbname, val);
+        rq.onupgradeneeded = t.step_func(function() {
+            var db = rq.result;
+            assert_equals(db.version, expected_version, 'version');
+            rq.transaction.abort();
+        });
+        rq.onsuccess = t.unreached_func("open should fail");
+        rq.onerror = t.step_func(function() {
+            t.done()
+        });
+    }, "Calling open() with version argument " + name + " should not throw.")
 }
 
-should_work(1.5)
-should_work(Number.MAX_SAFE_INTEGER)  // 0x20000000000000 - 1
+should_work(1.5, 1)
+should_work(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)  // 0x20000000000000 - 1
+should_work(undefined, 1)
 
 </script>
 
index 4ffc883..124f5d1 100644 (file)
@@ -9,7 +9,6 @@ PASS Calling open() with version argument NaN should throw TypeError.
 PASS Calling open() with version argument Infinity should throw TypeError. 
 PASS Calling open() with version argument -Infinity should throw TypeError. 
 PASS Calling open() with version argument "foo" should throw TypeError. 
-PASS Calling open() with version argument undefined should throw TypeError. 
 PASS Calling open() with version argument null should throw TypeError. 
 PASS Calling open() with version argument false should throw TypeError. 
 PASS Calling open() with version argument object should throw TypeError. 
@@ -17,4 +16,5 @@ PASS Calling open() with version argument object (second) should throw TypeError
 PASS Calling open() with version argument object (third) should throw TypeError. 
 PASS Calling open() with version argument 1.5 should not throw. 
 PASS Calling open() with version argument 9007199254740991 should not throw. 
+PASS Calling open() with version argument undefined should not throw. 
 
index 5512715..98b1dde 100644 (file)
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <title>IDBFactory.open() - errors in version argument</title>
-<script src="../../../resources/testharness.js"></script>
-<script src="../../../resources/testharnessreport.js"></script>
-<script src=support.js></script>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
 
 <script>
-var date = Date();
 function should_throw(val, name) {
     if (!name) {
         name = ((typeof val == "object" && val) ? "object" : format_value(val))
     }
     test(function() {
       assert_throws(new TypeError(), function() {
-        window.indexedDB.open('test' + date, val);
+        window.indexedDB.open('test', val);
       });
     }, "Calling open() with version argument " + name + " should throw TypeError.")
 }
@@ -27,7 +25,6 @@ should_throw(NaN)
 should_throw(Infinity)
 should_throw(-Infinity)
 should_throw("foo")
-should_throw(undefined)
 should_throw(null)
 should_throw(false)
 
@@ -47,18 +44,27 @@ should_throw({
 
 /* Valid */
 
-function should_work(val) {
-    
+function should_work(val, expected_version) {
     var name = format_value(val);
-    var t = async_test("Calling open() with version argument " + name + " should not throw.")
-    var rq = createdb(t, val + date)
-    rq.onupgradeneeded = function() {
-        t.done()
-    }
+    var dbname = 'test-db-does-not-exist';
+    async_test(function(t) {
+        window.indexedDB.deleteDatabase(dbname);
+        var rq = window.indexedDB.open(dbname, val);
+        rq.onupgradeneeded = t.step_func(function() {
+            var db = rq.result;
+            assert_equals(db.version, expected_version, 'version');
+            rq.transaction.abort();
+        });
+        rq.onsuccess = t.unreached_func("open should fail");
+        rq.onerror = t.step_func(function() {
+            t.done()
+        });
+    }, "Calling open() with version argument " + name + " should not throw.")
 }
 
-should_work(1.5)
-should_work(Number.MAX_SAFE_INTEGER)  // 0x20000000000000 - 1
+should_work(1.5, 1)
+should_work(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)  // 0x20000000000000 - 1
+should_work(undefined, 1)
 
 </script>
 
index 16b58de..2a08f32 100644 (file)
@@ -35,9 +35,7 @@ PASS indexedDB.open(dbname, 0x20000000000000) threw TypeError: Value 90071992547
 Expecting TypeError exception from indexedDB.open(dbname, null)
 PASS Exception was thrown.
 PASS indexedDB.open(dbname, null) threw TypeError: IDBFactory.open() called with a version of 0
-Expecting TypeError exception from indexedDB.open(dbname, undefined)
-PASS Exception was thrown.
-PASS indexedDB.open(dbname, undefined) threw TypeError: Value NaN is outside the range [0, 9007199254740991]
+PASS indexedDB.open(dbname, undefined) did not throw exception.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 16b58de..2a08f32 100644 (file)
@@ -35,9 +35,7 @@ PASS indexedDB.open(dbname, 0x20000000000000) threw TypeError: Value 90071992547
 Expecting TypeError exception from indexedDB.open(dbname, null)
 PASS Exception was thrown.
 PASS indexedDB.open(dbname, null) threw TypeError: IDBFactory.open() called with a version of 0
-Expecting TypeError exception from indexedDB.open(dbname, undefined)
-PASS Exception was thrown.
-PASS indexedDB.open(dbname, undefined) threw TypeError: Value NaN is outside the range [0, 9007199254740991]
+PASS indexedDB.open(dbname, undefined) did not throw exception.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index cd3a762..9d61944 100644 (file)
@@ -26,7 +26,7 @@ function deleteSuccess(evt) {
     evalAndExpectExceptionClass("indexedDB.open(dbname, -1)", "TypeError");
     evalAndExpectExceptionClass("indexedDB.open(dbname, 0x20000000000000)", "TypeError");
     evalAndExpectExceptionClass("indexedDB.open(dbname, null)", "TypeError");
-    evalAndExpectExceptionClass("indexedDB.open(dbname, undefined)", "TypeError");
+    shouldNotThrow("indexedDB.open(dbname, undefined)");
     finishJSTest();
 }
 
index 374ed14..bc62c75 100644 (file)
@@ -1,3 +1,49 @@
+2016-04-24  Chris Dumez  <cdumez@apple.com>
+
+        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.
+
+        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:
+
 2016-04-23  Chris Dumez  <cdumez@apple.com>
 
         [WebIDL] Drop [Default] WebKit-IDL extended attribute
index 01fb420..9d0a77a 100644 (file)
@@ -76,24 +76,17 @@ IDBFactory::~IDBFactory()
 {
 }
 
-RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, ExceptionCodeWithMessage& ec)
+RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, Optional<unsigned long long> version, ExceptionCodeWithMessage& ec)
 {
     LOG(IndexedDB, "IDBFactory::open");
     
-    return openInternal(context, name, 0, ec);
-}
-
-RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBFactory::open");
-    
-    if (!version) {
+    if (version && !version.value()) {
         ec.code = TypeError;
         ec.message = ASCIILiteral("IDBFactory.open() called with a version of 0");
         return nullptr;
     }
 
-    return openInternal(context, name, version, ec);
+    return openInternal(context, name, version.valueOr(0), ec);
 }
 
 RefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCodeWithMessage& ec)
index 137e073..1fdf713 100644 (file)
@@ -53,8 +53,7 @@ public:
     static Ref<IDBFactory> create(IDBClient::IDBConnectionProxy&);
     ~IDBFactory();
 
-    RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, ExceptionCodeWithMessage&);
-    RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCodeWithMessage&);
+    RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, Optional<unsigned long long> version, ExceptionCodeWithMessage&);
     RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const String& name, ExceptionCodeWithMessage&);
 
     short cmp(ScriptExecutionContext&, JSC::JSValue first, JSC::JSValue second, ExceptionCodeWithMessage&);
index cf7f19a..277efe4 100644 (file)
@@ -3370,6 +3370,29 @@ sub GenerateArgumentsCountCheck
     }
 }
 
+sub CanUseWTFOptionalForParameterType
+{
+    my $type  = shift;
+
+    # FIXME: We should progressively stop blacklisting each type below
+    # and eventually get rid of this function entirely.
+    return 0 if $codeGenerator->IsEnumType($type);
+    return 0 if $codeGenerator->IsTypedArrayType($type);
+    return 0 if $codeGenerator->IsWrapperType($type);
+    return 0 if $type eq "DOMString";
+    return 0 if $type eq "Dictionary";
+    return 0 if $type eq "any";
+    return 0 if $type eq "boolean";
+    return 0 if $type eq "float";
+    return 0 if $type eq "long";
+    return 0 if $type eq "unrestricted float";
+    return 0 if $type eq "unrestricted double";
+    return 0 if $type eq "unsigned long";
+    return 0 if $type eq "unsigned short";
+
+    return 1;
+}
+
 sub GenerateParametersCheck
 {
     my $outputArray = shift;
@@ -3419,7 +3442,7 @@ sub GenerateParametersCheck
         # Optional arguments with [Optional=...] should not generate the early call.
         # Optional Dictionary arguments always considered to have default of empty dictionary.
         my $optional = $parameter->isOptional;
-        if ($optional && !defined($parameter->default) && $argType ne "Dictionary" && !$codeGenerator->IsCallbackInterface($argType)) {
+        if ($optional && !defined($parameter->default) && !CanUseWTFOptionalForParameterType($parameter->type) && $argType ne "Dictionary" && !$codeGenerator->IsCallbackInterface($argType)) {
             # Generate early call if there are enough parameters.
             if (!$hasOptionalArguments) {
                 push(@$outputArray, "\n    size_t argsCount = state->argumentCount();\n");
@@ -3576,6 +3599,8 @@ sub GenerateParametersCheck
             } else {
                 my $outer;
                 my $inner;
+                my $nativeType = GetNativeTypeFromSignature($parameter);
+
                 if ($optional && defined($parameter->default)) {
                     my $defaultValue = $parameter->default;
 
@@ -3592,16 +3617,23 @@ sub GenerateParametersCheck
                     } else {
                         $defaultValue = "nullptr" if $defaultValue eq "null";
                         $defaultValue = "PNaN" if $defaultValue eq "NaN";
-                        $defaultValue = GetNativeTypeFromSignature($parameter) . "()" if $defaultValue eq "[]";
+                        $defaultValue = "$nativeType()" if $defaultValue eq "[]";
                     }
 
                     $outer = "state->argument($argsIndex).isUndefined() ? $defaultValue : ";
                     $inner = "state->uncheckedArgument($argsIndex)";
+                } elsif ($optional && !defined($parameter->default) && CanUseWTFOptionalForParameterType($parameter->type)) {
+                    # Use WTF::Optional<>() for optional parameters that are missing or undefined and that do not have
+                    # a default value in the IDL.
+                    my $defaultValue = "Optional<$nativeType>()";
+                    $nativeType = "Optional<$nativeType>";
+                    $outer = "state->argument($argsIndex).isUndefined() ? $defaultValue : ";
+                    $inner = "state->uncheckedArgument($argsIndex)";
                 } else {
                     $outer = "";
                     $inner = "state->argument($argsIndex)";
                 }
-                push(@$outputArray, "    " . GetNativeTypeFromSignature($parameter) . " $name = $outer" . JSValueToNative($parameter, $inner, $function->signature->extendedAttributes->{"Conditional"}) . ";\n");
+                push(@$outputArray, "    $nativeType $name = $outer" . JSValueToNative($parameter, $inner, $function->signature->extendedAttributes->{"Conditional"}) . ";\n");
             }
 
             # Check if the type conversion succeeded.
index 7119a85..266737c 100644 (file)
@@ -1648,6 +1648,58 @@ void webkit_dom_test_obj_method_with_optional_float_is_na_n(WebKitDOMTestObj* se
     item->methodWithOptionalFloatIsNaN(number);
 }
 
+void webkit_dom_test_obj_method_with_optional_long_long(WebKitDOMTestObj* self, gint64 number)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item->methodWithOptionalLongLong(number);
+}
+
+void webkit_dom_test_obj_method_with_optional_long_long_is_zero(WebKitDOMTestObj* self, gint64 number)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item->methodWithOptionalLongLongIsZero(number);
+}
+
+void webkit_dom_test_obj_method_with_optional_unsigned_long_long(WebKitDOMTestObj* self, guint64 number)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item->methodWithOptionalUnsignedLongLong(number);
+}
+
+void webkit_dom_test_obj_method_with_optional_unsigned_long_long_is_zero(WebKitDOMTestObj* self, guint64 number)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item->methodWithOptionalUnsignedLongLongIsZero(number);
+}
+
+void webkit_dom_test_obj_method_with_optional_array(WebKitDOMTestObj* self, const gchar* array)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    g_return_if_fail(WEBKIT_DOM_IS_DOM_STRING[](array));
+    WebCore::TestObj* item = WebKit::core(self);
+    WebCore::DOMString[]* convertedArray = WebKit::core(array);
+    item->methodWithOptionalArray(convertedArray);
+}
+
+void webkit_dom_test_obj_method_with_optional_array_is_empty(WebKitDOMTestObj* self, const gchar* array)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    g_return_if_fail(WEBKIT_DOM_IS_DOM_STRING[](array));
+    WebCore::TestObj* item = WebKit::core(self);
+    WebCore::DOMString[]* convertedArray = WebKit::core(array);
+    item->methodWithOptionalArrayIsEmpty(convertedArray);
+}
+
 gchar* webkit_dom_test_obj_conditional_method1(WebKitDOMTestObj* self)
 {
 #if ENABLE(Condition1)
index fd407f9..bc8fcf4 100644 (file)
@@ -609,6 +609,66 @@ WEBKIT_API void
 webkit_dom_test_obj_method_with_optional_float_is_na_n(WebKitDOMTestObj* self, gfloat number);
 
 /**
+ * webkit_dom_test_obj_method_with_optional_long_long:
+ * @self: A #WebKitDOMTestObj
+ * @number: A #gint64
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_long_long(WebKitDOMTestObj* self, gint64 number);
+
+/**
+ * webkit_dom_test_obj_method_with_optional_long_long_is_zero:
+ * @self: A #WebKitDOMTestObj
+ * @number: A #gint64
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_long_long_is_zero(WebKitDOMTestObj* self, gint64 number);
+
+/**
+ * webkit_dom_test_obj_method_with_optional_unsigned_long_long:
+ * @self: A #WebKitDOMTestObj
+ * @number: A #guint64
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_unsigned_long_long(WebKitDOMTestObj* self, guint64 number);
+
+/**
+ * webkit_dom_test_obj_method_with_optional_unsigned_long_long_is_zero:
+ * @self: A #WebKitDOMTestObj
+ * @number: A #guint64
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_unsigned_long_long_is_zero(WebKitDOMTestObj* self, guint64 number);
+
+/**
+ * webkit_dom_test_obj_method_with_optional_array:
+ * @self: A #WebKitDOMTestObj
+ * @array: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_array(WebKitDOMTestObj* self, const gchar* array);
+
+/**
+ * webkit_dom_test_obj_method_with_optional_array_is_empty:
+ * @self: A #WebKitDOMTestObj
+ * @array: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_array_is_empty(WebKitDOMTestObj* self, const gchar* array);
+
+/**
  * webkit_dom_test_obj_conditional_method1:
  * @self: A #WebKitDOMTestObj
  *
index 6b454f5..e357101 100644 (file)
@@ -148,6 +148,12 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAt
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalDoubleIsNaN(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalFloatIsNaN(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalSequence(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalLongLong(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalLongLongIsZero(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLong(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLongIsZero(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArray(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArrayIsEmpty(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg(JSC::ExecState*);
@@ -707,6 +713,12 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { "methodWithOptionalDoubleIsNaN", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalDoubleIsNaN), (intptr_t) (0) } },
     { "methodWithOptionalFloatIsNaN", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalFloatIsNaN), (intptr_t) (0) } },
     { "methodWithOptionalSequence", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalSequence), (intptr_t) (0) } },
+    { "methodWithOptionalLongLong", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalLongLong), (intptr_t) (0) } },
+    { "methodWithOptionalLongLongIsZero", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalLongLongIsZero), (intptr_t) (0) } },
+    { "methodWithOptionalUnsignedLongLong", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLong), (intptr_t) (0) } },
+    { "methodWithOptionalUnsignedLongLongIsZero", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLongIsZero), (intptr_t) (0) } },
+    { "methodWithOptionalArray", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArray), (intptr_t) (0) } },
+    { "methodWithOptionalArrayIsEmpty", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArrayIsEmpty), (intptr_t) (0) } },
     { "methodWithCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t) (1) } },
     { "methodWithNonCallbackArgAndCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg), (intptr_t) (2) } },
     { "methodWithCallbackAndOptionalArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg), (intptr_t) (0) } },
@@ -4241,6 +4253,96 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalSequenc
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalLongLong(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObj", "methodWithOptionalLongLong");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    Optional<long long> number = state->argument(0).isUndefined() ? Optional<long long>() : toInt64(state, state->uncheckedArgument(0), NormalConversion);
+    if (UNLIKELY(state->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalLongLong(number);
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalLongLongIsZero(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObj", "methodWithOptionalLongLongIsZero");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    long long number = state->argument(0).isUndefined() ? 0 : toInt64(state, state->uncheckedArgument(0), NormalConversion);
+    if (UNLIKELY(state->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalLongLongIsZero(number);
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLong(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObj", "methodWithOptionalUnsignedLongLong");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    Optional<unsigned long long> number = state->argument(0).isUndefined() ? Optional<unsigned long long>() : toUInt64(state, state->uncheckedArgument(0), NormalConversion);
+    if (UNLIKELY(state->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalUnsignedLongLong(number);
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLongIsZero(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObj", "methodWithOptionalUnsignedLongLongIsZero");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    unsigned long long number = state->argument(0).isUndefined() ? 0 : toUInt64(state, state->uncheckedArgument(0), NormalConversion);
+    if (UNLIKELY(state->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalUnsignedLongLongIsZero(number);
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArray(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObj", "methodWithOptionalArray");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    Optional<Vector<String>> array = state->argument(0).isUndefined() ? Optional<Vector<String>>() : toNativeArray<String>(state, state->uncheckedArgument(0));
+    if (UNLIKELY(state->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalArray(array);
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArrayIsEmpty(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObj", "methodWithOptionalArrayIsEmpty");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    Vector<String> array = state->argument(0).isUndefined() ? Vector<String>() : toNativeArray<String>(state, state->uncheckedArgument(0));
+    if (UNLIKELY(state->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalArrayIsEmpty(array);
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(ExecState* state)
 {
     JSValue thisValue = state->thisValue();
index e7050c8..c35258f 100644 (file)
@@ -463,14 +463,7 @@ EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionFunc(ExecState* stat
         return throwThisTypeError(*state, "TestTypedefs", "func");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
     auto& impl = castedThis->wrapped();
-
-    size_t argsCount = state->argumentCount();
-    if (argsCount <= 0) {
-        impl.func();
-        return JSValue::encode(jsUndefined());
-    }
-
-    Vector<int> x = toNativeArray<int>(state, state->argument(0));
+    Vector<int> x = state->argument(0).isUndefined() ? Vector<int>() : toNativeArray<int>(state, state->uncheckedArgument(0));
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     impl.func(x);
@@ -570,13 +563,6 @@ EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionFuncWithClamp(ExecSt
     if (!std::isnan(arg1NativeValue))
         arg1 = clampTo<unsigned long long>(arg1NativeValue);
 
-
-    size_t argsCount = state->argumentCount();
-    if (argsCount <= 1) {
-        impl.funcWithClamp(arg1);
-        return JSValue::encode(jsUndefined());
-    }
-
     unsigned long long arg2 = 0;
     double arg2NativeValue = state->argument(1).toNumber(state);
     if (UNLIKELY(state->hadException()))
index df93719..be2bdc5 100644 (file)
@@ -184,6 +184,10 @@ WEBCORE_EXPORT @interface DOMTestObj : DOMObject
 - (void)methodWithOptionalAtomicStringIsEmptyString:(NSString *)str;
 - (void)methodWithOptionalDoubleIsNaN:(double)number;
 - (void)methodWithOptionalFloatIsNaN:(float)number;
+- (void)methodWithOptionalLongLong:(long long)number;
+- (void)methodWithOptionalLongLongIsZero:(long long)number;
+- (void)methodWithOptionalUnsignedLongLong:(unsigned long long)number;
+- (void)methodWithOptionalUnsignedLongLongIsZero:(unsigned long long)number;
 - (void)classMethod;
 - (int)classMethodWithOptional:(int)arg;
 - (void)classMethod2:(int)arg;
index 67bf45d..113ff65 100644 (file)
     IMPL->methodWithOptionalFloatIsNaN(number);
 }
 
+- (void)methodWithOptionalLongLong:(long long)number
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->methodWithOptionalLongLong(number);
+}
+
+- (void)methodWithOptionalLongLongIsZero:(long long)number
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->methodWithOptionalLongLongIsZero(number);
+}
+
+- (void)methodWithOptionalUnsignedLongLong:(unsigned long long)number
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->methodWithOptionalUnsignedLongLong(number);
+}
+
+- (void)methodWithOptionalUnsignedLongLongIsZero:(unsigned long long)number
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->methodWithOptionalUnsignedLongLongIsZero(number);
+}
+
 
 #if ENABLE(Condition1)
 - (NSString *)conditionalMethod1
index cadf952..8e1e791 100644 (file)
@@ -189,6 +189,12 @@ enum _optional { "", "OptionalValue1", "OptionalValue2", "OptionalValue3" };
     void    methodWithOptionalDoubleIsNaN(optional unrestricted double number = NaN);
     void    methodWithOptionalFloatIsNaN(optional unrestricted float number = NaN);
     void    methodWithOptionalSequence(optional sequence<DOMString> sequence = []);
+    void    methodWithOptionalLongLong(optional long long number);
+    void    methodWithOptionalLongLongIsZero(optional long long number = 0);
+    void    methodWithOptionalUnsignedLongLong(optional unsigned long long number);
+    void    methodWithOptionalUnsignedLongLongIsZero(optional unsigned long long number = 0);
+    void    methodWithOptionalArray(optional DOMString[] array);
+    void    methodWithOptionalArrayIsEmpty(optional DOMString[] array = []);
 
 #if defined(TESTING_JS)
     // Callback interface parameters.
index a3c7202..444f1bb 100644 (file)
@@ -40,7 +40,7 @@
     
     static readonly attribute T TestSubObj;
 
-    [StrictTypeChecking] void func(optional ARRAY_OF_LONGS x);
+    [StrictTypeChecking] void func(optional ARRAY_OF_LONGS x = []);
 
     void setShadow(DOUBLE width, DOUBLE height, unrestricted float blur, [StrictTypeChecking] optional STRING color, optional DOUBLE alpha);
 
index e0c6d26..2f832c7 100644 (file)
@@ -39,7 +39,7 @@
     readonly attribute DOMString type;
 
 #if !defined(LANGUAGE_OBJECTIVE_C)
-    Blob slice(optional long long start, optional long long end, optional DOMString? contentType);
+    Blob slice(optional long long start = 0, optional long long end = 0x7FFFFFFFFFFFFFFF, optional DOMString? contentType = null);
 #endif
 };
 
index 845e0da..70601fd 100644 (file)
@@ -213,7 +213,7 @@ void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin*, cons
         return;
     }
 
-    RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(*context(), databaseName, ec);
+    RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(*context(), databaseName, Nullopt, ec);
     if (ec.code) {
         requestCallback().sendFailure("Could not open database.");
         return;