Changeset 203941 in webkit


Ignore:
Timestamp:
Jul 30, 2016 1:35:06 AM (8 years ago)
Author:
Chris Dumez
Message:

[WebIDL] Enable strict type checking for operations' nullable parameters of wrapper types
https://bugs.webkit.org/show_bug.cgi?id=160374

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline W3C test now that one more check is passing.

  • web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt:

Source/WebCore:

Enable strict type checking for operations' nullable parameters of
wrapper types to comply with the Web IDL specification:

For such parameters, if the JS passes a value that is not null /
undefined and does not have the expected wrapper type, then we now
throw a TypeError instead of silently converting the value to null.

This behavior is consistent with Chrome and Firefox. It also helps
identify bugs in JavaScript code.

No new tests, rebaselined existing tests.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateParametersCheck):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod1):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod2):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod6):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2):
(WebCore::jsTestObjPrototypeFunctionConvert2):
(WebCore::jsTestObjPrototypeFunctionStrictFunctionWithSequence):
(WebCore::jsTestObjPrototypeFunctionConditionalMethod3): Deleted.
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod5): Deleted.
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod): Deleted.
(WebCore::jsTestObjPrototypeFunctionOrange): Deleted.

LayoutTests:

Update / rebaseline existing tests to reflect behavior change. Also fix
several bugs in tests that became obvious now that we throw.

  • editing/execCommand/indent-pre-expected.txt:
  • editing/execCommand/indent-pre.html:
  • editing/selection/4895428-2.html:
  • editing/selection/move-by-word-visually-null-box.html:
  • fast/dom/DOMImplementation/detached-doctype.html:
  • fast/dom/MutationObserver/observe-attributes.html:
  • fast/dom/Node/contains-method-expected.txt:
  • fast/dom/Node/script-tests/contains-method.js:
  • fast/dom/Window/webkitConvertPoint.html:
  • fast/dom/adopt-node-crash-2.html:
  • fast/dom/incompatible-operations-expected.txt:
  • fast/dom/incompatible-operations.html:
  • fast/events/selectstart-by-arrow-keys.html:
  • fast/images/image-copy-memory-usage.html:
  • fast/xsl/xslt-processor-expected.txt:
  • http/tests/misc/webtiming-cross-origin-and-back1.html:
  • platform/mac/fast/dom/Window/webkitConvertPoint-expected.txt:
  • svg/custom/unicode-in-tspan-multi-svg-crash.html:
Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203935 r203941  
     12016-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        [WebIDL] Enable strict type checking for operations' nullable parameters of wrapper types
     4        https://bugs.webkit.org/show_bug.cgi?id=160374
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Update / rebaseline existing tests to reflect behavior change. Also fix
     9        several bugs in tests that became obvious now that we throw.
     10
     11        * editing/execCommand/indent-pre-expected.txt:
     12        * editing/execCommand/indent-pre.html:
     13        * editing/selection/4895428-2.html:
     14        * editing/selection/move-by-word-visually-null-box.html:
     15        * fast/dom/DOMImplementation/detached-doctype.html:
     16        * fast/dom/MutationObserver/observe-attributes.html:
     17        * fast/dom/Node/contains-method-expected.txt:
     18        * fast/dom/Node/script-tests/contains-method.js:
     19        * fast/dom/Window/webkitConvertPoint.html:
     20        * fast/dom/adopt-node-crash-2.html:
     21        * fast/dom/incompatible-operations-expected.txt:
     22        * fast/dom/incompatible-operations.html:
     23        * fast/events/selectstart-by-arrow-keys.html:
     24        * fast/images/image-copy-memory-usage.html:
     25        * fast/xsl/xslt-processor-expected.txt:
     26        * http/tests/misc/webtiming-cross-origin-and-back1.html:
     27        * platform/mac/fast/dom/Window/webkitConvertPoint-expected.txt:
     28        * svg/custom/unicode-in-tspan-multi-svg-crash.html:
     29
    1302016-07-29  Chris Dumez  <cdumez@apple.com>
    231
  • trunk/LayoutTests/editing/execCommand/indent-pre-expected.txt

    r93051 r203941  
    103103    if (textNode.nodeType != Node.TEXT_NODE)
    104104        throw "Wrong node type: " + textNode;
    105     execSetSelectionCommand(textNode, 0, 0);
     105    execSetSelectionCommand(textNode, 0, null);
    106106}
    107107
  • trunk/LayoutTests/editing/execCommand/indent-pre.html

    r63039 r203941  
    3131    if (textNode.nodeType != Node.TEXT_NODE)
    3232        throw "Wrong node type: " + textNode;
    33     execSetSelectionCommand(textNode, 0, 0);
     33    execSetSelectionCommand(textNode, 0, null);
    3434}
    3535
  • trunk/LayoutTests/editing/selection/4895428-2.html

    r120173 r203941  
    1919        return;
    2020    var cell = document.getElementById("cell");
    21     cell.addEventListener(handleBlur, "DOMBlurEvent");
     21    cell.addEventListener("DOMBlurEvent", handleBlur);
    2222    var div = document.getElementById("div");
    2323    div.focus();
  • trunk/LayoutTests/editing/selection/move-by-word-visually-null-box.html

    r155276 r203941  
    1010        // Test NULL VisiblePosition.
    1111        var selection = getSelection();
    12         selection.setPosition(0, 0);
     12        selection.setPosition(null, 0);
    1313        selection.modify("move", "right", "-webkit-visual-word");
    1414        document.body.innerHTML = "Crash test passed";
  • trunk/LayoutTests/fast/dom/DOMImplementation/detached-doctype.html

    r120792 r203941  
    1515
    1616var o = document.implementation.createDocumentType('x', null, null);
    17 var doc = document.implementation.createDocument("doc", null, 0);
     17var doc = document.implementation.createDocument("doc", null, null);
    1818for (i in o) {
    1919    try { o[i]; } catch (e) {}
  • trunk/LayoutTests/fast/dom/MutationObserver/observe-attributes.html

    r155265 r203941  
    596596        debug('Testing that attributeFilter respects case with non-HTML elements.');
    597597
    598         svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', 'svg');
     598        svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', null);
    599599        mutations = null;
    600600        observer = new MutationObserver(function(m) {
  • trunk/LayoutTests/fast/dom/Node/contains-method-expected.txt

    r94898 r203941  
    1313PASS test1.contains(test1) is true
    1414PASS test1TextChild.contains(test1TextChild) is true
    15 PASS test1.contains(123) is false
     15PASS test1.contains(123) threw exception TypeError: Argument 1 ('other') to Node.contains must be an instance of Node.
    1616PASS test1.contains(null) is false
    1717PASS document.contains(iframe) is false
  • trunk/LayoutTests/fast/dom/Node/script-tests/contains-method.js

    r98407 r203941  
    1515shouldBeTrue("test1.contains(test1)");
    1616shouldBeTrue("test1TextChild.contains(test1TextChild)");
    17 shouldBeFalse("test1.contains(123)");
     17shouldThrow("test1.contains(123)");
    1818shouldBeFalse("test1.contains(null)");
    1919
  • trunk/LayoutTests/fast/dom/Window/webkitConvertPoint.html

    r155265 r203941  
    114114           
    115115            debug("Test parameter passing - should not crash");
    116             var point = webkitConvertPointFromNodeToPage(new WebKitPoint(0, 0));
    117             if (point == null)
    118                 testPassed("Missing parameter test");
    119             else
    120                 testFailed("Missing parameter test");
    121             debug("Test did not crash and therefore was successful");
     116            shouldThrow("webkitConvertPointFromNodeToPage(new WebKitPoint(0, 0))");
    122117            debug("");
    123118            point = webkitConvertPointFromNodeToPage(null, new WebKitPoint(0, 0));
  • trunk/LayoutTests/fast/dom/adopt-node-crash-2.html

    r135914 r203941  
    2626        testRunner.notifyDone();
    2727}
    28 document.addEventListener("DOMContentLoaded", setTimeout("doit()", 1), false);
     28document.addEventListener("DOMContentLoaded", function() {
     29    setTimeout("doit()", 1);
     30}, false);
    2931</script>
    3032</html>
  • trunk/LayoutTests/fast/dom/incompatible-operations-expected.txt

    r200696 r203941  
    77PASS aNode.appendChild('knort') threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node.
    88PASS aNode.appendChild(void 0) threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node.
    9 PASS aNode.isSameNode(aDOMImplementation) is false
    10 PASS aNode.isSameNode('foo') is false
     9PASS aNode.isSameNode(aDOMImplementation) threw exception TypeError: Argument 1 ('other') to Node.isSameNode must be an instance of Node.
     10PASS aNode.isSameNode('foo') threw exception TypeError: Argument 1 ('other') to Node.isSameNode must be an instance of Node.
    1111PASS aNode.isSameNode(void 0) is false
    1212PASS aNode.lookupPrefix(aDOMImplementation) is null
  • trunk/LayoutTests/fast/dom/incompatible-operations.html

    r200696 r203941  
    3535shouldThrow("aNode.appendChild(void 0)");
    3636
    37 shouldBeFalse("aNode.isSameNode(aDOMImplementation)");
    38 shouldBeFalse("aNode.isSameNode('foo')");
     37shouldThrow("aNode.isSameNode(aDOMImplementation)");
     38shouldThrow("aNode.isSameNode('foo')");
    3939shouldBeFalse("aNode.isSameNode(void 0)");
    4040shouldBe("aNode.lookupPrefix(aDOMImplementation)", "null");
  • trunk/LayoutTests/fast/events/selectstart-by-arrow-keys.html

    r120792 r203941  
    4040    // On Mac, home/end doesn't move caret so manually select " World".
    4141    if (navigator.platform.indexOf('Mac') == 0)
    42         window.getSelection().setBaseAndExtent(div.firstChild, div.textContent.indexOf('World'), div.textContent.length);
     42        window.getSelection().setBaseAndExtent(div.firstChild, div.textContent.indexOf('World'));
    4343
    4444    eventSender.keyDown("leftArrow");
  • trunk/LayoutTests/fast/images/image-copy-memory-usage.html

    r194326 r203941  
    4242                            // the copy and also finish the test. setTimeout() is used with a zero delay in order to cause this to
    4343                            // run after the copy is finished.
    44                             document.getElementById("animationFrame").contentWindow.document.addEventListener("copy",
     44                            document.getElementById("animationFrame").contentWindow.document.addEventListener("copy", function() {
    4545                                setTimeout(
    4646                                        function()
     
    5151                                        window.finishJSTest();
    5252                                    },
    53                                     0),
     53                                    0) },
    5454                                false);
    5555
  • trunk/LayoutTests/fast/xsl/xslt-processor-expected.txt

    r152685 r203941  
    6161Success
    62622.3 use non-DOMDocument output parameter:
    63 ****Failure**** (expected exception, instead got result: "null")
     63Success
    64642.4 transform to same fragment twice:
    6565Success
  • trunk/LayoutTests/http/tests/misc/webtiming-cross-origin-and-back1.html

    r177283 r203941  
    88    window.location = "http://127.0.0.1:8000/misc/resources/webtiming-cross-origin-and-back-redirect1.php";
    99}
    10 addEventListener("load", setTimeout(doRedirect, 0));
     10addEventListener("load", function() {
     11    setTimeout(doRedirect, 0);
     12});
    1113</script>
    1214</head>
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r203935 r203941  
     12016-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        [WebIDL] Enable strict type checking for operations' nullable parameters of wrapper types
     4        https://bugs.webkit.org/show_bug.cgi?id=160374
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Rebaseline W3C test now that one more check is passing.
     9
     10        * web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt:
     11
    1122016-07-29  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt

    r203517 r203941  
    268268PASS createDocument test 154: metadata for "foo:","xmlfoo:bar",null
    269269PASS createDocument test 154: characterSet aliases for "foo:","xmlfoo:bar",null
    270 FAIL createDocument test 155: null,null,false,object "TypeError" assert_throws: function "function () { document.implementation.createDocument(name..." did not throw
     270PASS createDocument test 155: null,null,false,object "TypeError"
    271271PASS createDocument test 156: null,null,null,null
    272272PASS createDocument test 156: metadata for null,null,null
  • trunk/LayoutTests/platform/mac/fast/dom/Window/webkitConvertPoint-expected.txt

    r161884 r203941  
    2828
    2929Test parameter passing - should not crash
    30 PASS Missing parameter test
    31 Test did not crash and therefore was successful
     30PASS webkitConvertPointFromNodeToPage(new WebKitPoint(0, 0)) threw exception TypeError: Argument 1 ('node') to Window.webkitConvertPointFromNodeToPage must be an instance of Node.
    3231
    3332PASS null parameter test a
  • trunk/LayoutTests/svg/custom/unicode-in-tspan-multi-svg-crash.html

    r195411 r203941  
    1515      filterInFirstRoot = document.getElementById('filterInFirstRoot');
    1616      useElement = document.getElementById('useElement');
    17       window.getSelection().setBaseAndExtent(filterInFirstRoot, useElement, 5);
     17      window.getSelection().setBaseAndExtent(filterInFirstRoot, 0);
    1818      document.execCommand('ForwardDelete');
    1919      document.designMode='off';
  • trunk/Source/WebCore/ChangeLog

    r203935 r203941  
     12016-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        [WebIDL] Enable strict type checking for operations' nullable parameters of wrapper types
     4        https://bugs.webkit.org/show_bug.cgi?id=160374
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Enable strict type checking for operations' nullable parameters of
     9        wrapper types to comply with the Web IDL specification:
     10        - http://heycam.github.io/webidl/#es-nullable-type
     11        - http://heycam.github.io/webidl/#es-interface
     12
     13        For such parameters, if the JS passes a value that is not null /
     14        undefined and does not have the expected wrapper type, then we now
     15        throw a TypeError instead of silently converting the value to null.
     16
     17        This behavior is consistent with Chrome and Firefox. It also helps
     18        identify bugs in JavaScript code.
     19
     20        No new tests, rebaselined existing tests.
     21
     22        * bindings/scripts/CodeGeneratorJS.pm:
     23        (GenerateParametersCheck):
     24        * bindings/scripts/test/JS/JSTestObj.cpp:
     25        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper):
     26        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull):
     27        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver):
     28        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod1):
     29        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod2):
     30        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod6):
     31        (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1):
     32        (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2):
     33        (WebCore::jsTestObjPrototypeFunctionConvert2):
     34        (WebCore::jsTestObjPrototypeFunctionStrictFunctionWithSequence):
     35        (WebCore::jsTestObjPrototypeFunctionConditionalMethod3): Deleted.
     36        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod5): Deleted.
     37        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod): Deleted.
     38        (WebCore::jsTestObjPrototypeFunctionOrange): Deleted.
     39
    1402016-07-29  Chris Dumez  <cdumez@apple.com>
    241
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r203858 r203941  
    37513751            my $shouldPassByReference = $isTearOff || ShouldPassWrapperByReference($parameter, $interface);
    37523752
    3753             if ($function->signature->extendedAttributes->{"StrictTypeChecking"} && !$shouldPassByReference && $codeGenerator->IsWrapperType($type)) {
     3753            if (!$shouldPassByReference && $codeGenerator->IsWrapperType($type)) {
    37543754                $implIncludes{"<runtime/Error.h>"} = 1;
    37553755                my $checkedArgument = "state->argument($argumentIndex)";
     
    37603760                push(@$outputArray, "        $name = $nativeValue;\n");
    37613761                if ($mayThrowException) {
    3762                     push(@$outputArray, "    if (UNLIKELY(state->hadException()))\n");
    3763                     push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
     3762                    push(@$outputArray, "        if (UNLIKELY(state->hadException()))\n");
     3763                    push(@$outputArray, "            return JSValue::encode(jsUndefined());\n");
    37643764                }
    37653765                push(@$outputArray, "        if (UNLIKELY(!$name))\n");
    37663766                push(@$outputArray, "            return throwArgumentTypeError(*state, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n");
    37673767                push(@$outputArray, "    }\n");
     3768                $value = "WTFMove($name)";
    37683769            } else {
    37693770                if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($type, $parameter->default)) {
     
    42964297    "Date" => "double",
    42974298    "Dictionary" => "Dictionary",
     4299    "EventListener" => "RefPtr<EventListener>",
    42984300    "SerializedScriptValue" => "RefPtr<SerializedScriptValue>",
    42994301    "XPathNSResolver" => "RefPtr<XPathNSResolver>",
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r203858 r203941  
    50295029    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
    50305030    auto& impl = castedThis->wrapped();
    5031     auto obj = JSTestObj::toWrapped(state->argument(0));
     5031    TestObj* obj = nullptr;
     5032    if (!state->argument(0).isUndefinedOrNull()) {
     5033        obj = JSTestObj::toWrapped(state->uncheckedArgument(0));
     5034        if (UNLIKELY(!obj))
     5035            return throwArgumentTypeError(*state, 0, "obj", "TestObject", "methodWithOptionalNullableWrapper", "TestObj");
     5036    }
    50325037    impl.methodWithOptionalNullableWrapper(WTFMove(obj));
    50335038    return JSValue::encode(jsUndefined());
     
    50425047    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
    50435048    auto& impl = castedThis->wrapped();
    5044     auto obj = JSTestObj::toWrapped(state->argument(0));
     5049    TestObj* obj = nullptr;
     5050    if (!state->argument(0).isUndefinedOrNull()) {
     5051        obj = JSTestObj::toWrapped(state->uncheckedArgument(0));
     5052        if (UNLIKELY(!obj))
     5053            return throwArgumentTypeError(*state, 0, "obj", "TestObject", "methodWithOptionalNullableWrapperIsNull", "TestObj");
     5054    }
    50455055    impl.methodWithOptionalNullableWrapperIsNull(WTFMove(obj));
    50465056    return JSValue::encode(jsUndefined());
     
    50555065    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
    50565066    auto& impl = castedThis->wrapped();
    5057     auto resolver = JSXPathNSResolver::toWrapped(*state, state->argument(0));
    5058     if (UNLIKELY(state->hadException()))
    5059         return JSValue::encode(jsUndefined());
     5067    RefPtr<XPathNSResolver> resolver = nullptr;
     5068    if (!state->argument(0).isUndefinedOrNull()) {
     5069        resolver = JSXPathNSResolver::toWrapped(*state, state->uncheckedArgument(0));
     5070        if (UNLIKELY(state->hadException()))
     5071            return JSValue::encode(jsUndefined());
     5072        if (UNLIKELY(!resolver))
     5073            return throwArgumentTypeError(*state, 0, "resolver", "TestObject", "methodWithOptionalXPathNSResolver", "XPathNSResolver");
     5074    }
    50605075    impl.methodWithOptionalXPathNSResolver(WTFMove(resolver));
    50615076    return JSValue::encode(jsUndefined());
     
    52505265    if (UNLIKELY(state->argumentCount() < 2))
    52515266        return throwVMError(state, createNotEnoughArgumentsError(state));
    5252     auto objArg = JSTestObj::toWrapped(state->argument(0));
     5267    TestObj* objArg = nullptr;
     5268    if (!state->argument(0).isUndefinedOrNull()) {
     5269        objArg = JSTestObj::toWrapped(state->uncheckedArgument(0));
     5270        if (UNLIKELY(!objArg))
     5271            return throwArgumentTypeError(*state, 0, "objArg", "TestObject", "overloadedMethod", "TestObj");
     5272    }
    52535273    auto strArg = state->argument(1).toWTFString(state);
    52545274    if (UNLIKELY(state->hadException()))
     
    52685288    if (UNLIKELY(state->argumentCount() < 1))
    52695289        return throwVMError(state, createNotEnoughArgumentsError(state));
    5270     auto objArg = JSTestObj::toWrapped(state->argument(0));
     5290    TestObj* objArg = nullptr;
     5291    if (!state->argument(0).isUndefinedOrNull()) {
     5292        objArg = JSTestObj::toWrapped(state->uncheckedArgument(0));
     5293        if (UNLIKELY(!objArg))
     5294            return throwArgumentTypeError(*state, 0, "objArg", "TestObject", "overloadedMethod", "TestObj");
     5295    }
    52715296    auto longArg = state->argument(1).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion);
    52725297    if (UNLIKELY(state->hadException()))
     
    53375362    if (UNLIKELY(state->argumentCount() < 1))
    53385363        return throwVMError(state, createNotEnoughArgumentsError(state));
    5339     auto listArg = JSDOMStringList::toWrapped(*state, state->argument(0));
    5340     if (UNLIKELY(state->hadException()))
    5341         return JSValue::encode(jsUndefined());
     5364    RefPtr<DOMStringList> listArg = nullptr;
     5365    if (!state->argument(0).isUndefinedOrNull()) {
     5366        listArg = JSDOMStringList::toWrapped(*state, state->uncheckedArgument(0));
     5367        if (UNLIKELY(state->hadException()))
     5368            return JSValue::encode(jsUndefined());
     5369        if (UNLIKELY(!listArg))
     5370            return throwArgumentTypeError(*state, 0, "listArg", "TestObject", "overloadedMethod", "DOMStringList");
     5371    }
    53425372    impl.overloadedMethod(WTFMove(listArg));
    53435373    return JSValue::encode(jsUndefined());
     
    54945524    if (UNLIKELY(state->argumentCount() < 1))
    54955525        return throwVMError(state, createNotEnoughArgumentsError(state));
    5496     auto objArg1 = JSTestObj::toWrapped(state->argument(0));
    5497     auto objArg2 = JSTestObj::toWrapped(state->argument(1));
     5526    TestObj* objArg1 = nullptr;
     5527    if (!state->argument(0).isUndefinedOrNull()) {
     5528        objArg1 = JSTestObj::toWrapped(state->uncheckedArgument(0));
     5529        if (UNLIKELY(!objArg1))
     5530            return throwArgumentTypeError(*state, 0, "objArg1", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj");
     5531    }
     5532    TestObj* objArg2 = nullptr;
     5533    if (!state->argument(1).isUndefinedOrNull()) {
     5534        objArg2 = JSTestObj::toWrapped(state->uncheckedArgument(1));
     5535        if (UNLIKELY(!objArg2))
     5536            return throwArgumentTypeError(*state, 1, "objArg2", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj");
     5537    }
    54985538    impl.overloadedMethodWithOptionalParameter(WTFMove(objArg1), WTFMove(objArg2));
    54995539    return JSValue::encode(jsUndefined());
     
    55105550    if (UNLIKELY(state->argumentCount() < 1))
    55115551        return throwVMError(state, createNotEnoughArgumentsError(state));
    5512     auto objArg = JSTestObj::toWrapped(state->argument(0));
     5552    TestObj* objArg = nullptr;
     5553    if (!state->argument(0).isUndefinedOrNull()) {
     5554        objArg = JSTestObj::toWrapped(state->uncheckedArgument(0));
     5555        if (UNLIKELY(!objArg))
     5556            return throwArgumentTypeError(*state, 0, "objArg", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj");
     5557    }
    55135558    auto longArg = state->argument(1).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion);
    55145559    if (UNLIKELY(state->hadException()))
     
    58015846    if (UNLIKELY(state->argumentCount() < 1))
    58025847        return throwVMError(state, createNotEnoughArgumentsError(state));
    5803     auto value = JSTestNode::toWrapped(state->argument(0));
     5848    TestNode* value = nullptr;
     5849    if (!state->argument(0).isUndefinedOrNull()) {
     5850        value = JSTestNode::toWrapped(state->uncheckedArgument(0));
     5851        if (UNLIKELY(!value))
     5852            return throwArgumentTypeError(*state, 0, "value", "TestObject", "convert2", "TestNode");
     5853    }
    58045854    impl.convert2(WTFMove(value));
    58055855    return JSValue::encode(jsUndefined());
     
    59225972    if (UNLIKELY(state->hadException()))
    59235973        return JSValue::encode(jsUndefined());
    5924     JSValue result = jsBoolean(impl.strictFunctionWithSequence(objArg, WTFMove(a), ec));
     5974    JSValue result = jsBoolean(impl.strictFunctionWithSequence(WTFMove(objArg), WTFMove(a), ec));
    59255975
    59265976    setDOMException(state, ec);
Note: See TracChangeset for help on using the changeset viewer.