Skip to content

Array proxies as keys? #309

Closed
Closed

Description

@inexorabletash

I noticed that this throws in both Chrome and Firefox:

const k = [1,2,3];
const p = new Proxy(k, {});
indexedDB.cmp(k, p);

In Chrome, at least, the proxy fails an internal "is this an array?" check.

In the spec convert a value to a key calls ECMAScript's IsArray which would seem to return true for array proxies.

At the very least, we don't have tests.

Should we update the spec to exclude proxies, e.g. replacing "if IsArray(input)" with "if input is an Array exotic object"?

Alternately, should array proxies be supported? What are the consequences of allowing these? Would the value→key conversion algorithm potentially blow up in more places?

Activity

  1. added this to the V3 milestone on Nov 20, 2019
  2. asutherland commented on Nov 20, 2019

    @asutherland
    Collaborator

    The algorithms where we clone a value already forbid proxies thanks to step 23 of StructuredSerializeInternal (https://html.spec.whatwg.org/#structuredserializeinternal) which prevents use of proxies.

    It makes sense to me to also forbid proxies where we directly invoke algorithms without first performing the clone step.

    (Also, Firefox/Gecko is a hard no on supporting proxies in IndexedDB were that not already the case!)

  3. inexorabletash commented on Nov 20, 2019

    @inexorabletash
    MemberAuthor

    SGTM. I'll put up a spec PR and wpt PR, time permitting, changing the text to the exotic Array object check.

  4. added a commit that references this issue on Nov 22, 2019
    7d425a9
  5. added a commit that references this issue on Feb 1, 2021
    e71f613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions