Changeset 199970 in webkit


Ignore:
Timestamp:
Apr 24, 2016 5:27:30 PM (8 years ago)
Author:
Chris Dumez
Message:

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

Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r199969 r199970  
     12016-04-24  Chris Dumez  <cdumez@apple.com>
     2
     3        Autogenerated IDBFactory.open() does the wrong thing if you pass an explicit 'undefined' as the second argument
     4        https://bugs.webkit.org/show_bug.cgi?id=156939
     5
     6        Reviewed by Darin Adler.
     7
     8        Update / rebaseline existing test now that passing undefined as second parameter to
     9        IDBFactory.open() no longer throws.
     10
     11        * storage/indexeddb/intversion-bad-parameters-expected.txt:
     12        * storage/indexeddb/intversion-bad-parameters-private-expected.txt:
     13        * storage/indexeddb/resources/intversion-bad-parameters.js:
     14        (deleteSuccess):
     15
    1162016-04-23  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r199969 r199970  
     12016-04-24  Chris Dumez  <cdumez@apple.com>
     2
     3        Autogenerated IDBFactory.open() does the wrong thing if you pass an explicit 'undefined' as the second argument
     4        https://bugs.webkit.org/show_bug.cgi?id=156939
     5
     6        Reviewed by Darin Adler.
     7
     8        Re-sync tests from upstream b1818929.
     9
     10        * IndexedDB-private-browsing/idbfactory_open9-expected.txt:
     11        * IndexedDB-private-browsing/idbfactory_open9.html:
     12        * web-platform-tests/IndexedDB/idbfactory_open9-expected.txt:
     13        * web-platform-tests/IndexedDB/idbfactory_open9.htm:
     14
    1152016-04-23  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/LayoutTests/imported/w3c/IndexedDB-private-browsing/idbfactory_open9-expected.txt

    r198394 r199970  
    1010PASS Calling open() with version argument -Infinity should throw TypeError.
    1111PASS Calling open() with version argument "foo" should throw TypeError.
    12 PASS Calling open() with version argument undefined should throw TypeError.
    1312PASS Calling open() with version argument null should throw TypeError.
    1413PASS Calling open() with version argument false should throw TypeError.
     
    1817PASS Calling open() with version argument 1.5 should not throw.
    1918PASS Calling open() with version argument 9007199254740991 should not throw.
     19PASS Calling open() with version argument undefined should not throw.
    2020
  • trunk/LayoutTests/imported/w3c/IndexedDB-private-browsing/idbfactory_open9.html

    r198394 r199970  
    33<script src="../../../resources/testharness.js"></script>
    44<script src="../../../resources/testharnessreport.js"></script>
    5 <script src=support.js></script>
    65
    76<script>
     
    2726should_throw(-Infinity)
    2827should_throw("foo")
    29 should_throw(undefined)
    3028should_throw(null)
    3129should_throw(false)
     
    4745/* Valid */
    4846
    49 function should_work(val) {
     47function should_work(val, expected_version) {
    5048    var name = format_value(val);
    51     var t = async_test("Calling open() with version argument " + name + " should not throw.")
    52     var rq = createdb(t, val)
    53     rq.onupgradeneeded = function() {
    54         t.done()
    55     }
     49    var dbname = 'test-db-does-not-exist';
     50    async_test(function(t) {
     51        window.indexedDB.deleteDatabase(dbname);
     52        var rq = window.indexedDB.open(dbname, val);
     53        rq.onupgradeneeded = t.step_func(function() {
     54            var db = rq.result;
     55            assert_equals(db.version, expected_version, 'version');
     56            rq.transaction.abort();
     57        });
     58        rq.onsuccess = t.unreached_func("open should fail");
     59        rq.onerror = t.step_func(function() {
     60            t.done()
     61        });
     62    }, "Calling open() with version argument " + name + " should not throw.")
    5663}
    5764
    58 should_work(1.5)
    59 should_work(Number.MAX_SAFE_INTEGER)  // 0x20000000000000 - 1
     65should_work(1.5, 1)
     66should_work(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)  // 0x20000000000000 - 1
     67should_work(undefined, 1)
    6068
    6169</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbfactory_open9-expected.txt

    r198394 r199970  
    1010PASS Calling open() with version argument -Infinity should throw TypeError.
    1111PASS Calling open() with version argument "foo" should throw TypeError.
    12 PASS Calling open() with version argument undefined should throw TypeError.
    1312PASS Calling open() with version argument null should throw TypeError.
    1413PASS Calling open() with version argument false should throw TypeError.
     
    1817PASS Calling open() with version argument 1.5 should not throw.
    1918PASS Calling open() with version argument 9007199254740991 should not throw.
     19PASS Calling open() with version argument undefined should not throw.
    2020
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbfactory_open9.htm

    r198394 r199970  
    11<!DOCTYPE html>
    22<title>IDBFactory.open() - errors in version argument</title>
    3 <script src="../../../resources/testharness.js"></script>
    4 <script src="../../../resources/testharnessreport.js"></script>
    5 <script src=support.js></script>
     3<script src=/resources/testharness.js></script>
     4<script src=/resources/testharnessreport.js></script>
    65
    76<script>
    8 var date = Date();
    97function should_throw(val, name) {
    108    if (!name) {
     
    1311    test(function() {
    1412      assert_throws(new TypeError(), function() {
    15         window.indexedDB.open('test' + date, val);
     13        window.indexedDB.open('test', val);
    1614      });
    1715    }, "Calling open() with version argument " + name + " should throw TypeError.")
     
    2826should_throw(-Infinity)
    2927should_throw("foo")
    30 should_throw(undefined)
    3128should_throw(null)
    3229should_throw(false)
     
    4845/* Valid */
    4946
    50 function should_work(val) {
    51    
     47function should_work(val, expected_version) {
    5248    var name = format_value(val);
    53     var t = async_test("Calling open() with version argument " + name + " should not throw.")
    54     var rq = createdb(t, val + date)
    55     rq.onupgradeneeded = function() {
    56         t.done()
    57     }
     49    var dbname = 'test-db-does-not-exist';
     50    async_test(function(t) {
     51        window.indexedDB.deleteDatabase(dbname);
     52        var rq = window.indexedDB.open(dbname, val);
     53        rq.onupgradeneeded = t.step_func(function() {
     54            var db = rq.result;
     55            assert_equals(db.version, expected_version, 'version');
     56            rq.transaction.abort();
     57        });
     58        rq.onsuccess = t.unreached_func("open should fail");
     59        rq.onerror = t.step_func(function() {
     60            t.done()
     61        });
     62    }, "Calling open() with version argument " + name + " should not throw.")
    5863}
    5964
    60 should_work(1.5)
    61 should_work(Number.MAX_SAFE_INTEGER)  // 0x20000000000000 - 1
     65should_work(1.5, 1)
     66should_work(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)  // 0x20000000000000 - 1
     67should_work(undefined, 1)
    6268
    6369</script>
  • trunk/LayoutTests/storage/indexeddb/intversion-bad-parameters-expected.txt

    r199797 r199970  
    3636PASS Exception was thrown.
    3737PASS indexedDB.open(dbname, null) threw TypeError: IDBFactory.open() called with a version of 0
    38 Expecting TypeError exception from indexedDB.open(dbname, undefined)
    39 PASS Exception was thrown.
    40 PASS indexedDB.open(dbname, undefined) threw TypeError: Value NaN is outside the range [0, 9007199254740991]
     38PASS indexedDB.open(dbname, undefined) did not throw exception.
    4139PASS successfullyParsed is true
    4240
  • trunk/LayoutTests/storage/indexeddb/intversion-bad-parameters-private-expected.txt

    r199797 r199970  
    3636PASS Exception was thrown.
    3737PASS indexedDB.open(dbname, null) threw TypeError: IDBFactory.open() called with a version of 0
    38 Expecting TypeError exception from indexedDB.open(dbname, undefined)
    39 PASS Exception was thrown.
    40 PASS indexedDB.open(dbname, undefined) threw TypeError: Value NaN is outside the range [0, 9007199254740991]
     38PASS indexedDB.open(dbname, undefined) did not throw exception.
    4139PASS successfullyParsed is true
    4240
  • trunk/LayoutTests/storage/indexeddb/resources/intversion-bad-parameters.js

    r163963 r199970  
    2727    evalAndExpectExceptionClass("indexedDB.open(dbname, 0x20000000000000)", "TypeError");
    2828    evalAndExpectExceptionClass("indexedDB.open(dbname, null)", "TypeError");
    29     evalAndExpectExceptionClass("indexedDB.open(dbname, undefined)", "TypeError");
     29    shouldNotThrow("indexedDB.open(dbname, undefined)");
    3030    finishJSTest();
    3131}
  • trunk/Source/WebCore/ChangeLog

    r199969 r199970  
     12016-04-24  Chris Dumez  <cdumez@apple.com>
     2
     3        Autogenerated IDBFactory.open() does the wrong thing if you pass an explicit 'undefined' as the second argument
     4        https://bugs.webkit.org/show_bug.cgi?id=156939
     5
     6        Reviewed by Darin Adler.
     7
     8        As per WebIDL, if undefined is passed by JS for an optional parameter then
     9        we should use its default value if it has one, or use the special value
     10        "missing":
     11        http://heycam.github.io/webidl/#es-overloads (step 10.4)
     12
     13        Our bindings generator was already mapping undefined to the parameter's
     14        default value when present. However, it was missing the notion of
     15        "missing" value when there no default value. This patch adds supports
     16        for its by passing Optional<>(Nullopt) to the implementation in such
     17        case. This means that the implementation will need to use WTF::Optional<>
     18        type for parameters that do not have a default value. Thankfully though,
     19        in most cases, we will be able to specify a default value in the IDL
     20        so cases where we will need to use WTF::Optional<> will actually be
     21        rare.
     22
     23        To avoid having to do too much refactoring in this patch, the support
     24        for WTF::Optional is currently blacklisted for most IDL types. I will
     25        gradually stop blacklisting each type in follow-up patches, as I either:
     26        - Add default parameter values in our IDL (preferred)
     27        - Use WTF::Optional<> in our implementation (when we cannot specify a
     28          default value).
     29
     30        This patch fixes a bug with IDBFactory.open()'s second parameter (version)
     31        for which undefined should not throw and indicate that the version
     32        should not be changed. We now use WTF::Optional in the implementation to
     33        distinguish this case and not throw.
     34
     35        No new tests, existing tests were updated / rebaselined.
     36
     37        * Modules/indexeddb/IDBFactory.cpp:
     38        (WebCore::IDBFactory::open):
     39        (WebCore::IDBFactory::openInternal): Deleted.
     40        * Modules/indexeddb/IDBFactory.h:
     41        * bindings/scripts/CodeGeneratorJS.pm:
     42        (ShouldUseWTFOptionalForParameterType):
     43        (GenerateParametersCheck):
     44        * fileapi/Blob.idl:
     45        * inspector/InspectorIndexedDBAgent.cpp:
     46
    1472016-04-23  Chris Dumez  <cdumez@apple.com>
    248
  • trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp

    r199882 r199970  
    7777}
    7878
    79 RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, ExceptionCodeWithMessage& ec)
     79RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, Optional<unsigned long long> version, ExceptionCodeWithMessage& ec)
    8080{
    8181    LOG(IndexedDB, "IDBFactory::open");
    8282   
    83     return openInternal(context, name, 0, ec);
    84 }
    85 
    86 RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCodeWithMessage& ec)
    87 {
    88     LOG(IndexedDB, "IDBFactory::open");
    89    
    90     if (!version) {
     83    if (version && !version.value()) {
    9184        ec.code = TypeError;
    9285        ec.message = ASCIILiteral("IDBFactory.open() called with a version of 0");
     
    9487    }
    9588
    96     return openInternal(context, name, version, ec);
     89    return openInternal(context, name, version.valueOr(0), ec);
    9790}
    9891
  • trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h

    r199835 r199970  
    5454    ~IDBFactory();
    5555
    56     RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, ExceptionCodeWithMessage&);
    57     RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCodeWithMessage&);
     56    RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, Optional<unsigned long long> version, ExceptionCodeWithMessage&);
    5857    RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const String& name, ExceptionCodeWithMessage&);
    5958
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r199969 r199970  
    33713371}
    33723372
     3373sub CanUseWTFOptionalForParameterType
     3374{
     3375    my $type  = shift;
     3376
     3377    # FIXME: We should progressively stop blacklisting each type below
     3378    # and eventually get rid of this function entirely.
     3379    return 0 if $codeGenerator->IsEnumType($type);
     3380    return 0 if $codeGenerator->IsTypedArrayType($type);
     3381    return 0 if $codeGenerator->IsWrapperType($type);
     3382    return 0 if $type eq "DOMString";
     3383    return 0 if $type eq "Dictionary";
     3384    return 0 if $type eq "any";
     3385    return 0 if $type eq "boolean";
     3386    return 0 if $type eq "float";
     3387    return 0 if $type eq "long";
     3388    return 0 if $type eq "unrestricted float";
     3389    return 0 if $type eq "unrestricted double";
     3390    return 0 if $type eq "unsigned long";
     3391    return 0 if $type eq "unsigned short";
     3392
     3393    return 1;
     3394}
     3395
    33733396sub GenerateParametersCheck
    33743397{
     
    34203443        # Optional Dictionary arguments always considered to have default of empty dictionary.
    34213444        my $optional = $parameter->isOptional;
    3422         if ($optional && !defined($parameter->default) && $argType ne "Dictionary" && !$codeGenerator->IsCallbackInterface($argType)) {
     3445        if ($optional && !defined($parameter->default) && !CanUseWTFOptionalForParameterType($parameter->type) && $argType ne "Dictionary" && !$codeGenerator->IsCallbackInterface($argType)) {
    34233446            # Generate early call if there are enough parameters.
    34243447            if (!$hasOptionalArguments) {
     
    35773600                my $outer;
    35783601                my $inner;
     3602                my $nativeType = GetNativeTypeFromSignature($parameter);
     3603
    35793604                if ($optional && defined($parameter->default)) {
    35803605                    my $defaultValue = $parameter->default;
     
    35933618                        $defaultValue = "nullptr" if $defaultValue eq "null";
    35943619                        $defaultValue = "PNaN" if $defaultValue eq "NaN";
    3595                         $defaultValue = GetNativeTypeFromSignature($parameter) . "()" if $defaultValue eq "[]";
     3620                        $defaultValue = "$nativeType()" if $defaultValue eq "[]";
    35963621                    }
    35973622
     3623                    $outer = "state->argument($argsIndex).isUndefined() ? $defaultValue : ";
     3624                    $inner = "state->uncheckedArgument($argsIndex)";
     3625                } elsif ($optional && !defined($parameter->default) && CanUseWTFOptionalForParameterType($parameter->type)) {
     3626                    # Use WTF::Optional<>() for optional parameters that are missing or undefined and that do not have
     3627                    # a default value in the IDL.
     3628                    my $defaultValue = "Optional<$nativeType>()";
     3629                    $nativeType = "Optional<$nativeType>";
    35983630                    $outer = "state->argument($argsIndex).isUndefined() ? $defaultValue : ";
    35993631                    $inner = "state->uncheckedArgument($argsIndex)";
     
    36023634                    $inner = "state->argument($argsIndex)";
    36033635                }
    3604                 push(@$outputArray, "    " . GetNativeTypeFromSignature($parameter) . " $name = $outer" . JSValueToNative($parameter, $inner, $function->signature->extendedAttributes->{"Conditional"}) . ";\n");
     3636                push(@$outputArray, "    $nativeType $name = $outer" . JSValueToNative($parameter, $inner, $function->signature->extendedAttributes->{"Conditional"}) . ";\n");
    36053637            }
    36063638
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp

    r199969 r199970  
    16491649}
    16501650
     1651void webkit_dom_test_obj_method_with_optional_long_long(WebKitDOMTestObj* self, gint64 number)
     1652{
     1653    WebCore::JSMainThreadNullState state;
     1654    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
     1655    WebCore::TestObj* item = WebKit::core(self);
     1656    item->methodWithOptionalLongLong(number);
     1657}
     1658
     1659void webkit_dom_test_obj_method_with_optional_long_long_is_zero(WebKitDOMTestObj* self, gint64 number)
     1660{
     1661    WebCore::JSMainThreadNullState state;
     1662    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
     1663    WebCore::TestObj* item = WebKit::core(self);
     1664    item->methodWithOptionalLongLongIsZero(number);
     1665}
     1666
     1667void webkit_dom_test_obj_method_with_optional_unsigned_long_long(WebKitDOMTestObj* self, guint64 number)
     1668{
     1669    WebCore::JSMainThreadNullState state;
     1670    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
     1671    WebCore::TestObj* item = WebKit::core(self);
     1672    item->methodWithOptionalUnsignedLongLong(number);
     1673}
     1674
     1675void webkit_dom_test_obj_method_with_optional_unsigned_long_long_is_zero(WebKitDOMTestObj* self, guint64 number)
     1676{
     1677    WebCore::JSMainThreadNullState state;
     1678    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
     1679    WebCore::TestObj* item = WebKit::core(self);
     1680    item->methodWithOptionalUnsignedLongLongIsZero(number);
     1681}
     1682
     1683void webkit_dom_test_obj_method_with_optional_array(WebKitDOMTestObj* self, const gchar* array)
     1684{
     1685    WebCore::JSMainThreadNullState state;
     1686    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
     1687    g_return_if_fail(WEBKIT_DOM_IS_DOM_STRING[](array));
     1688    WebCore::TestObj* item = WebKit::core(self);
     1689    WebCore::DOMString[]* convertedArray = WebKit::core(array);
     1690    item->methodWithOptionalArray(convertedArray);
     1691}
     1692
     1693void webkit_dom_test_obj_method_with_optional_array_is_empty(WebKitDOMTestObj* self, const gchar* array)
     1694{
     1695    WebCore::JSMainThreadNullState state;
     1696    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
     1697    g_return_if_fail(WEBKIT_DOM_IS_DOM_STRING[](array));
     1698    WebCore::TestObj* item = WebKit::core(self);
     1699    WebCore::DOMString[]* convertedArray = WebKit::core(array);
     1700    item->methodWithOptionalArrayIsEmpty(convertedArray);
     1701}
     1702
    16511703gchar* webkit_dom_test_obj_conditional_method1(WebKitDOMTestObj* self)
    16521704{
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h

    r199969 r199970  
    610610
    611611/**
     612 * webkit_dom_test_obj_method_with_optional_long_long:
     613 * @self: A #WebKitDOMTestObj
     614 * @number: A #gint64
     615 *
     616 * Stability: Unstable
     617**/
     618WEBKIT_API void
     619webkit_dom_test_obj_method_with_optional_long_long(WebKitDOMTestObj* self, gint64 number);
     620
     621/**
     622 * webkit_dom_test_obj_method_with_optional_long_long_is_zero:
     623 * @self: A #WebKitDOMTestObj
     624 * @number: A #gint64
     625 *
     626 * Stability: Unstable
     627**/
     628WEBKIT_API void
     629webkit_dom_test_obj_method_with_optional_long_long_is_zero(WebKitDOMTestObj* self, gint64 number);
     630
     631/**
     632 * webkit_dom_test_obj_method_with_optional_unsigned_long_long:
     633 * @self: A #WebKitDOMTestObj
     634 * @number: A #guint64
     635 *
     636 * Stability: Unstable
     637**/
     638WEBKIT_API void
     639webkit_dom_test_obj_method_with_optional_unsigned_long_long(WebKitDOMTestObj* self, guint64 number);
     640
     641/**
     642 * webkit_dom_test_obj_method_with_optional_unsigned_long_long_is_zero:
     643 * @self: A #WebKitDOMTestObj
     644 * @number: A #guint64
     645 *
     646 * Stability: Unstable
     647**/
     648WEBKIT_API void
     649webkit_dom_test_obj_method_with_optional_unsigned_long_long_is_zero(WebKitDOMTestObj* self, guint64 number);
     650
     651/**
     652 * webkit_dom_test_obj_method_with_optional_array:
     653 * @self: A #WebKitDOMTestObj
     654 * @array: A #gchar
     655 *
     656 * Stability: Unstable
     657**/
     658WEBKIT_API void
     659webkit_dom_test_obj_method_with_optional_array(WebKitDOMTestObj* self, const gchar* array);
     660
     661/**
     662 * webkit_dom_test_obj_method_with_optional_array_is_empty:
     663 * @self: A #WebKitDOMTestObj
     664 * @array: A #gchar
     665 *
     666 * Stability: Unstable
     667**/
     668WEBKIT_API void
     669webkit_dom_test_obj_method_with_optional_array_is_empty(WebKitDOMTestObj* self, const gchar* array);
     670
     671/**
    612672 * webkit_dom_test_obj_conditional_method1:
    613673 * @self: A #WebKitDOMTestObj
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r199969 r199970  
    149149JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalFloatIsNaN(JSC::ExecState*);
    150150JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalSequence(JSC::ExecState*);
     151JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalLongLong(JSC::ExecState*);
     152JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalLongLongIsZero(JSC::ExecState*);
     153JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLong(JSC::ExecState*);
     154JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLongIsZero(JSC::ExecState*);
     155JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArray(JSC::ExecState*);
     156JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArrayIsEmpty(JSC::ExecState*);
    151157JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*);
    152158JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg(JSC::ExecState*);
     
    708714    { "methodWithOptionalFloatIsNaN", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalFloatIsNaN), (intptr_t) (0) } },
    709715    { "methodWithOptionalSequence", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalSequence), (intptr_t) (0) } },
     716    { "methodWithOptionalLongLong", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalLongLong), (intptr_t) (0) } },
     717    { "methodWithOptionalLongLongIsZero", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalLongLongIsZero), (intptr_t) (0) } },
     718    { "methodWithOptionalUnsignedLongLong", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLong), (intptr_t) (0) } },
     719    { "methodWithOptionalUnsignedLongLongIsZero", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLongIsZero), (intptr_t) (0) } },
     720    { "methodWithOptionalArray", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArray), (intptr_t) (0) } },
     721    { "methodWithOptionalArrayIsEmpty", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArrayIsEmpty), (intptr_t) (0) } },
    710722    { "methodWithCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t) (1) } },
    711723    { "methodWithNonCallbackArgAndCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg), (intptr_t) (2) } },
     
    42424254}
    42434255
     4256EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalLongLong(ExecState* state)
     4257{
     4258    JSValue thisValue = state->thisValue();
     4259    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     4260    if (UNLIKELY(!castedThis))
     4261        return throwThisTypeError(*state, "TestObj", "methodWithOptionalLongLong");
     4262    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     4263    auto& impl = castedThis->wrapped();
     4264    Optional<long long> number = state->argument(0).isUndefined() ? Optional<long long>() : toInt64(state, state->uncheckedArgument(0), NormalConversion);
     4265    if (UNLIKELY(state->hadException()))
     4266        return JSValue::encode(jsUndefined());
     4267    impl.methodWithOptionalLongLong(number);
     4268    return JSValue::encode(jsUndefined());
     4269}
     4270
     4271EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalLongLongIsZero(ExecState* state)
     4272{
     4273    JSValue thisValue = state->thisValue();
     4274    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     4275    if (UNLIKELY(!castedThis))
     4276        return throwThisTypeError(*state, "TestObj", "methodWithOptionalLongLongIsZero");
     4277    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     4278    auto& impl = castedThis->wrapped();
     4279    long long number = state->argument(0).isUndefined() ? 0 : toInt64(state, state->uncheckedArgument(0), NormalConversion);
     4280    if (UNLIKELY(state->hadException()))
     4281        return JSValue::encode(jsUndefined());
     4282    impl.methodWithOptionalLongLongIsZero(number);
     4283    return JSValue::encode(jsUndefined());
     4284}
     4285
     4286EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLong(ExecState* state)
     4287{
     4288    JSValue thisValue = state->thisValue();
     4289    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     4290    if (UNLIKELY(!castedThis))
     4291        return throwThisTypeError(*state, "TestObj", "methodWithOptionalUnsignedLongLong");
     4292    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     4293    auto& impl = castedThis->wrapped();
     4294    Optional<unsigned long long> number = state->argument(0).isUndefined() ? Optional<unsigned long long>() : toUInt64(state, state->uncheckedArgument(0), NormalConversion);
     4295    if (UNLIKELY(state->hadException()))
     4296        return JSValue::encode(jsUndefined());
     4297    impl.methodWithOptionalUnsignedLongLong(number);
     4298    return JSValue::encode(jsUndefined());
     4299}
     4300
     4301EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLongIsZero(ExecState* state)
     4302{
     4303    JSValue thisValue = state->thisValue();
     4304    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     4305    if (UNLIKELY(!castedThis))
     4306        return throwThisTypeError(*state, "TestObj", "methodWithOptionalUnsignedLongLongIsZero");
     4307    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     4308    auto& impl = castedThis->wrapped();
     4309    unsigned long long number = state->argument(0).isUndefined() ? 0 : toUInt64(state, state->uncheckedArgument(0), NormalConversion);
     4310    if (UNLIKELY(state->hadException()))
     4311        return JSValue::encode(jsUndefined());
     4312    impl.methodWithOptionalUnsignedLongLongIsZero(number);
     4313    return JSValue::encode(jsUndefined());
     4314}
     4315
     4316EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArray(ExecState* state)
     4317{
     4318    JSValue thisValue = state->thisValue();
     4319    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     4320    if (UNLIKELY(!castedThis))
     4321        return throwThisTypeError(*state, "TestObj", "methodWithOptionalArray");
     4322    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     4323    auto& impl = castedThis->wrapped();
     4324    Optional<Vector<String>> array = state->argument(0).isUndefined() ? Optional<Vector<String>>() : toNativeArray<String>(state, state->uncheckedArgument(0));
     4325    if (UNLIKELY(state->hadException()))
     4326        return JSValue::encode(jsUndefined());
     4327    impl.methodWithOptionalArray(array);
     4328    return JSValue::encode(jsUndefined());
     4329}
     4330
     4331EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArrayIsEmpty(ExecState* state)
     4332{
     4333    JSValue thisValue = state->thisValue();
     4334    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     4335    if (UNLIKELY(!castedThis))
     4336        return throwThisTypeError(*state, "TestObj", "methodWithOptionalArrayIsEmpty");
     4337    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     4338    auto& impl = castedThis->wrapped();
     4339    Vector<String> array = state->argument(0).isUndefined() ? Vector<String>() : toNativeArray<String>(state, state->uncheckedArgument(0));
     4340    if (UNLIKELY(state->hadException()))
     4341        return JSValue::encode(jsUndefined());
     4342    impl.methodWithOptionalArrayIsEmpty(array);
     4343    return JSValue::encode(jsUndefined());
     4344}
     4345
    42444346EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(ExecState* state)
    42454347{
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp

    r199265 r199970  
    464464    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
    465465    auto& impl = castedThis->wrapped();
    466 
    467     size_t argsCount = state->argumentCount();
    468     if (argsCount <= 0) {
    469         impl.func();
    470         return JSValue::encode(jsUndefined());
    471     }
    472 
    473     Vector<int> x = toNativeArray<int>(state, state->argument(0));
     466    Vector<int> x = state->argument(0).isUndefined() ? Vector<int>() : toNativeArray<int>(state, state->uncheckedArgument(0));
    474467    if (UNLIKELY(state->hadException()))
    475468        return JSValue::encode(jsUndefined());
     
    570563    if (!std::isnan(arg1NativeValue))
    571564        arg1 = clampTo<unsigned long long>(arg1NativeValue);
    572 
    573 
    574     size_t argsCount = state->argumentCount();
    575     if (argsCount <= 1) {
    576         impl.funcWithClamp(arg1);
    577         return JSValue::encode(jsUndefined());
    578     }
    579565
    580566    unsigned long long arg2 = 0;
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h

    r199969 r199970  
    185185- (void)methodWithOptionalDoubleIsNaN:(double)number;
    186186- (void)methodWithOptionalFloatIsNaN:(float)number;
     187- (void)methodWithOptionalLongLong:(long long)number;
     188- (void)methodWithOptionalLongLongIsZero:(long long)number;
     189- (void)methodWithOptionalUnsignedLongLong:(unsigned long long)number;
     190- (void)methodWithOptionalUnsignedLongLongIsZero:(unsigned long long)number;
    187191- (void)classMethod;
    188192- (int)classMethodWithOptional:(int)arg;
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm

    r199969 r199970  
    13171317}
    13181318
     1319- (void)methodWithOptionalLongLong:(long long)number
     1320{
     1321    WebCore::JSMainThreadNullState state;
     1322    IMPL->methodWithOptionalLongLong(number);
     1323}
     1324
     1325- (void)methodWithOptionalLongLongIsZero:(long long)number
     1326{
     1327    WebCore::JSMainThreadNullState state;
     1328    IMPL->methodWithOptionalLongLongIsZero(number);
     1329}
     1330
     1331- (void)methodWithOptionalUnsignedLongLong:(unsigned long long)number
     1332{
     1333    WebCore::JSMainThreadNullState state;
     1334    IMPL->methodWithOptionalUnsignedLongLong(number);
     1335}
     1336
     1337- (void)methodWithOptionalUnsignedLongLongIsZero:(unsigned long long)number
     1338{
     1339    WebCore::JSMainThreadNullState state;
     1340    IMPL->methodWithOptionalUnsignedLongLongIsZero(number);
     1341}
     1342
    13191343
    13201344#if ENABLE(Condition1)
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r199969 r199970  
    190190    void    methodWithOptionalFloatIsNaN(optional unrestricted float number = NaN);
    191191    void    methodWithOptionalSequence(optional sequence<DOMString> sequence = []);
     192    void    methodWithOptionalLongLong(optional long long number);
     193    void    methodWithOptionalLongLongIsZero(optional long long number = 0);
     194    void    methodWithOptionalUnsignedLongLong(optional unsigned long long number);
     195    void    methodWithOptionalUnsignedLongLongIsZero(optional unsigned long long number = 0);
     196    void    methodWithOptionalArray(optional DOMString[] array);
     197    void    methodWithOptionalArrayIsEmpty(optional DOMString[] array = []);
    192198
    193199#if defined(TESTING_JS)
  • trunk/Source/WebCore/bindings/scripts/test/TestTypedefs.idl

    r168302 r199970  
    4141    static readonly attribute T TestSubObj;
    4242
    43     [StrictTypeChecking] void func(optional ARRAY_OF_LONGS x);
     43    [StrictTypeChecking] void func(optional ARRAY_OF_LONGS x = []);
    4444
    4545    void setShadow(DOUBLE width, DOUBLE height, unrestricted float blur, [StrictTypeChecking] optional STRING color, optional DOUBLE alpha);
  • trunk/Source/WebCore/fileapi/Blob.idl

    r199587 r199970  
    4040
    4141#if !defined(LANGUAGE_OBJECTIVE_C)
    42     Blob slice(optional long long start, optional long long end, optional DOMString? contentType);
     42    Blob slice(optional long long start = 0, optional long long end = 0x7FFFFFFFFFFFFFFF, optional DOMString? contentType = null);
    4343#endif
    4444};
  • trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp

    r199797 r199970  
    214214    }
    215215
    216     RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(*context(), databaseName, ec);
     216    RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(*context(), databaseName, Nullopt, ec);
    217217    if (ec.code) {
    218218        requestCallback().sendFailure("Could not open database.");
Note: See TracChangeset for help on using the changeset viewer.