<?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>133532</bug_id>
          
          <creation_ts>2014-06-04 19:24:58 -0700</creation_ts>
          <short_desc>REGRESSION prototype chain ignored iterating properties of global object</short_desc>
          <delta_ts>2014-06-06 00:53:05 -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>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>http://test.saurik.com/apple/protochain.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jay Freeman (saurik)">saurik</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>eoconnor</cc>
    
    <cc>ggaren</cc>
    
    <cc>oliver</cc>
    
    <cc>saurik</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1013445</commentid>
    <comment_count>0</comment_count>
    <who name="Jay Freeman (saurik)">saurik</who>
    <bug_when>2014-06-04 19:24:58 -0700</bug_when>
    <thetext>To put this upfront: this issue affects JavaScriptCore on iOS 8.0 and Mac OS X 10.10. The functionality in question works on iOS 2-7 and OS X 10.5-9. I was told by an Apple engineer at WWDC to file a bug here and start the summary with &quot;REGRESSION&quot;. I attempted to replicate this issue in a browser, and it seems my attempt &quot;fails&quot; on older versions (iOS 6/7, OS X 10.8/9), but I could see many (maybe silly/wrong) reasons why this might be different.

So, here&apos;s an example interaction (using a JavaScript REPL that runs everything through JavaScriptCore). I am going to assign the prototype of the global object and then walk to a variable. My REPL prints objects using JSObjectCopyPropertyNames, but I have also provided code using a for/in loop to get the same data into an array (note the REPL shows the array as an object). Note that I am using the global object: the scenario works for other objects.

I have filed two separate bugs because I was asked to do so by Oliver. This bug is in relation to iterating the properties inherited by prototype (here shown using a for/in loop).

Here is the working behavior from the old version of JavaScriptCore:

cy# a = {}; this.__proto__ = a; a.f = 5; this
{a:{f:5},f:5}
cy# this.f
5
cy# c = []; for (x in this) c.push(x); c
{0:&quot;a&quot;,1:&quot;c&quot;,2:&quot;f&quot;}

Here is the broken behavior from the new version of JavaScriptCore:

cy# a = {}; this.__proto__ = a; a.f = 5; this
{a:{f:5}}
cy# this.f
5
cy# c = []; for (x in this) c.push(x); c
{0:&quot;a&quot;,1:&quot;c&quot;}

FWIW, if there is some different way of doing this, if this was never supposed to have worked, etc. I would be more than happy to be told &quot;do something different&quot;. I don&apos;t see myself why this shouldn&apos;t work, however, and I&apos;ve been doing this without issue now on JavaScriptCore for over five years.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1013762</commentid>
    <comment_count>1</comment_count>
    <who name="Jay Freeman (saurik)">saurik</who>
    <bug_when>2014-06-06 00:53:05 -0700</bug_when>
    <thetext>To make certain this is clear when this bug is evaluated (due to some confusion on #133531), the behavior in my code is to use JSContextGetGlobalObject to get the global object (which I guess is now a JSProxy?), then use JSObjectGetPrototype in a loop to find the top-most prototype, and finally to use JSObjectSetPrototype on the final not-NULL result. I demonstrated the change in behavior using JavaScript in this bug, but I am actually working at the level of JavaScriptCore&apos;s API.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>