<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>189030</bug_id>
          
          <creation_ts>2018-08-27 16:25:35 -0700</creation_ts>
          <short_desc>For-in over a proxy with ownKeys handler hits non-enumerable keys</short_desc>
          <delta_ts>2019-04-18 11:01:45 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kevin Gibbons">bakkot</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>caitp</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>gskachkov</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>rmorisset</cc>
    
    <cc>saam</cc>
    
    <cc>ticaiolima</cc>
    
    <cc>tzagallo</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1454190</commentid>
    <comment_count>0</comment_count>
    <who name="Kevin Gibbons">bakkot</who>
    <bug_when>2018-08-27 16:25:35 -0700</bug_when>
    <thetext>Consider the following program:

```
if (typeof console === &apos;undefined&apos;) console = { log: print };

let a = Object.create(null, {
  x: { enumerable: false, configurable: true, value: 0 },
});

let handler = {
  ownKeys(target) {
    return Reflect.ownKeys(target);
  },
};

let pa = new Proxy(a, handler);

for (let key in pa) {
  console.log(&apos;reached&apos;);
}
```

This prints &apos;reached&apos;. It should not; `pa` reports no enumerable keys. (And no other engine has this behavior.)

This only happens if the `ownKeys` handler is present, even though the one I&apos;ve specified does the same thing as the default handler.


See also (and please comment on) this open spec bug about more precisely specifying the behavior of for-in, which prompted the investigation which lead me to discovering this issue: https://github.com/tc39/ecma262/issues/1281</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1458321</commentid>
    <comment_count>1</comment_count>
    <who name="Kevin Gibbons">bakkot</who>
    <bug_when>2018-09-10 17:04:06 -0700</bug_when>
    <thetext>This is probably related, so I&apos;m going to add it as a comment here:

JSC can also print the same key twice. According to Allen Wirfs-Brock [1], &quot;no duplicate names&quot; is the most important property required by the spec, so this seems especially bad.

Sample code:

```
let a = {
  x: 0,
};

let b = {
  x: 0,
};


let pb = new Proxy(b, {
  ownKeys(target) {
    return Reflect.ownKeys(target);
  },
});

Object.setPrototypeOf(a, pb);


for (let key in a) {
  console.log(key);
}
```

This prints `x` twice.



[1] https://github.com/tc39/ecma262/issues/1281#issuecomment-411133580</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1496406</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-01-20 14:50:25 -0800</bug_when>
    <thetext>&lt;rdar://problem/47417561&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1509062</commentid>
    <comment_count>3</comment_count>
    <who name="Caitlin Potter (:caitp)">caitp</who>
    <bug_when>2019-02-22 10:52:52 -0800</bug_when>
    <thetext>This is essentially the same bug as your other one, https://bugs.webkit.org/show_bug.cgi?id=189034 --- isn&apos;t it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1509069</commentid>
    <comment_count>4</comment_count>
    <who name="Kevin Gibbons">bakkot</who>
    <bug_when>2019-02-22 11:03:03 -0800</bug_when>
    <thetext>Maybe? This one only occurs if you have an `ownKeys` handler - if you remove it from my examples, the engine does the right thing. So I was assuming it was a distinct issue from failing to invoke `getOwnPropertyDescriptor`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1509075</commentid>
    <comment_count>5</comment_count>
    <who name="Caitlin Potter (:caitp)">caitp</who>
    <bug_when>2019-02-22 11:12:35 -0800</bug_when>
    <thetext>(In reply to bakkot from comment #4)
&gt; Maybe? This one only occurs if you have an `ownKeys` handler - if you remove
&gt; it from my examples, the engine does the right thing. So I was assuming it
&gt; was a distinct issue from failing to invoke `getOwnPropertyDescriptor`.

Ah, I see what you mean. This one is a dupe of https://bugs.webkit.org/show_bug.cgi?id=176810, but the GOPD bug still needs to be fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1528510</commentid>
    <comment_count>6</comment_count>
    <who name="Caitlin Potter (:caitp)">caitp</who>
    <bug_when>2019-04-18 11:01:45 -0700</bug_when>
    <thetext>Neither of these test cases are reproducible for me on master now.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>