[Webkit-unassigned] [Bug 189136] New: Omitting an optional argument when calling a WebIDL operation results in a "required member" TypeError if the argument type is a dictionary with required members

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 29 18:12:09 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=189136

            Bug ID: 189136
           Summary: Omitting an optional argument when calling a WebIDL
                    operation results in a "required member" TypeError if
                    the argument type is a dictionary with required
                    members
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Bindings
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: aestes at apple.com
                CC: cdumez at apple.com, sam at webkit.org

Payment Request defines a dictionary that has a required member:

    dictionary PaymentMethodChangeEventInit : PaymentRequestUpdateEventInit {
        required DOMString methodName;
        object? methodDetails;
    };

It also defines an interface (PaymentMethodChangeEvent) with a constructor that takes an optional PaymentMethodChangeEventInit:

    Constructor(DOMString type, optional PaymentMethodChangeEventInit eventInitDict)

If you call the constructor, omitting the second argument, you get a TypeError about a missing required field (methodName).

Despite eventInitDict being optional, WebKit still generates code that tries to convert undefined to a PaymentMethodChangeEventInit struct:

    auto eventInitDict = convert<IDLDictionary<PaymentMethodChangeEventInit>>(*state, state->argument(1));

And that code throws when converting undefined with a required member:

    JSValue methodNameValue;
    if (isNullOrUndefined)
        methodNameValue = jsUndefined();
    else {
        methodNameValue = object->get(&state, Identifier::fromString(&state, "methodName"));
        RETURN_IF_EXCEPTION(throwScope, { });
    }
    if (!methodNameValue.isUndefined()) {
        result.methodName = convert<IDLDOMString>(state, methodNameValue);
        RETURN_IF_EXCEPTION(throwScope, { });
    } else {
        throwRequiredMemberTypeError(state, throwScope, "methodName", "PaymentMethodChangeEventInit", "DOMString");
        return { };
    }

I don't know if it's legal per WebIDL to have optional arguments to structs with required members, but if it is then this seems like a bug in our bindings generation.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180830/4fbe275c/attachment-0001.html>


More information about the webkit-unassigned mailing list