• Raphael Kubo da Costa's avatar
    bindings: Expose an indexed property descriptor handler for named properties. · cf8a4164
    Raphael Kubo da Costa authored
    Follow-up to https://chromium-review.googlesource.com/576183 ("bindings:
    Return the right property descriptors for legacy platform objects"), which
    introduced the indexed descriptor callbacks for bindings.
    
    Even if a given IDL (such as Storage.idl) only supports named properties,
    our bindings layer installs a handler for indexed properties that, in this
    case, mostly just ends up falling back to the named property handlers.
    
    However, we were not defining a descriptor callback for indexed properties
    when the IDL only supports named properties. Consequently, we were not
    setting the right property descriptor values for a given numeric property,
    leading to bizarre cases where, e.g. if Storage only had numeric keys,
    Object.values() and Object.keys() would return arrays of diffferent
    lengths (the latter would be an empty one, actually).
    
    This change is a bit complicated because we install our indexed and named
    property handlers differently: the former is created with descriptor and
    definer callbacks, whereas the latter uses the query callback signature
    instead. This means the indexed property descriptor callback for named
    properties needs to call the query callback and translate its return value
    into a format suitable for descriptor callbacks, which is not very
    efficient. Ideally, both named and indexed properties should converge in
    terms of how their handlers are declared.
    
    Despite the fact that this is a follow-up commit, the original CL did not
    introduce a regression; interfaces that only support named properties were
    just behaving like they did in the past, with an indexed descriptor callback
    not being set.
    
    Bug: 719703, 764633
    Change-Id: I1ebaabe61f5f8b6cadb0cfa8b41664a64e49e51b
    Reviewed-on: https://chromium-review.googlesource.com/660497
    Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
    Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
    Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
    Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
    Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
    Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#501591}
    cf8a4164
interface_base.cpp.tmpl 44.8 KB