<?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>25079</bug_id>
          
          <creation_ts>2009-04-07 10:36:37 -0700</creation_ts>
          <short_desc>(needs test?) JS Arrays et al receive the wrong prototype</short_desc>
          <delta_ts>2011-06-16 20:31:39 -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>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://dl.dropbox.com/u/513327/JavaScript/bugs/sandboxed-natives.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="John-David Dalton">john.david.dalton</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>ap</cc>
    
    <cc>barraclough</cc>
    
    <cc>joe</cc>
    
    <cc>kangax</cc>
    
    <cc>oliver</cc>
    
    <cc>sam</cc>
    
    <cc>thedartt</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>116774</commentid>
    <comment_count>0</comment_count>
    <who name="John-David Dalton">john.david.dalton</who>
    <bug_when>2009-04-07 10:36:37 -0700</bug_when>
    <thetext>First create sandboxed natives by creating an iframe and referencing its Array,
String, Date or other natives. When calling a method on the sandboxed native it
returns a document native instead of a sandboxed one.

Example:

window.Sandbox.Array.prototype.awesome = function() { };
var foo = new window.Sandbox.Array(&apos;a&apos;, &apos;b&apos;, &apos;c&apos;);
alert(typeof foo.awesome); // -&gt; function
alert(typeof Array.prototype.awesome) -&gt; undefined (correctly reports
undefined)
alert(typeof foo.slice(0).awesome) -&gt; undefined (should be `function`)

Tested and fails on Safari 2.0 - 3.4 beta.
Chrome, IE, and Opera work correctly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>204668</commentid>
    <comment_count>1</comment_count>
    <who name="Dan Trott">thedartt</who>
    <bug_when>2010-03-26 10:43:06 -0700</bug_when>
    <thetext>This still appears to be an issue in Safari 4.0.5 (tested on Windows).

This is causing a lot of issues in our app which interacts with a child document which has been extended with the Prototype framework.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>204912</commentid>
    <comment_count>2</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-03-26 19:02:35 -0700</bug_when>
    <thetext>Can you attach a version of your test case in HTML?  I don&apos;t understand what Sandbox is.  Also, have you tried a nightly build from http://nightly.webkit.org/?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>204974</commentid>
    <comment_count>3</comment_count>
    <who name="Dan Trott">thedartt</who>
    <bug_when>2010-03-27 04:12:31 -0700</bug_when>
    <thetext>It seems that the issue I&apos;ve been experiencing is not quite the same as the one reported by John-David.

I made a test that demonstrates my issue and tried it in the latest nightly, it&apos;s fixed.

I ran John-David&apos;s test in the latest nightly and the test still fails.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258182</commentid>
    <comment_count>4</comment_count>
    <who name="John-David Dalton">john.david.dalton</who>
    <bug_when>2010-07-30 06:36:51 -0700</bug_when>
    <thetext>I have updated the test case. This is still an issue in Safari 5. With JavaScript frameworks like FuseJS using this technique it would be beneficial if Safari would fix this bug so it can perform as well as other browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258191</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-07-30 07:32:29 -0700</bug_when>
    <thetext>Ok.  I understand now.  Your test case is about 10x more complex than it needs to be.  The issue is that object created via constructors are getting their prototypes from the current page whereas they should be getting their prototypes from the page that contained the constructors originally.  In the test case, the page that contains the constructors is detached, but it&apos;s unclear whether that&apos;s essentially to the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258192</commentid>
    <comment_count>6</comment_count>
      <attachid>63058</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-07-30 07:35:13 -0700</bug_when>
    <thetext>Created attachment 63058
Reduced test case

Here&apos;s a reduced test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258193</commentid>
    <comment_count>7</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-07-30 07:35:37 -0700</bug_when>
    <thetext>Probably something internal to JSC.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258194</commentid>
    <comment_count>8</comment_count>
    <who name="John-David Dalton">john.david.dalton</who>
    <bug_when>2010-07-30 07:42:08 -0700</bug_when>
    <thetext>I noticed you changed the title to `JS Arrays` receive the wrong prototype. This is for any native object instance. The same thing can be seen for:

Sandbox.String.prototype.blah = 3;
var str = new Sandbox.String(&apos;x&apos;);
str.blah; // should be 3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258250</commentid>
    <comment_count>9</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2010-07-30 10:08:32 -0700</bug_when>
    <thetext>What do sandboxes have to do with this?  The testcase is simply using an iframe, i don&apos;t see any sign of the sandbox attribute?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258258</commentid>
    <comment_count>10</comment_count>
    <who name="John-David Dalton">john.david.dalton</who>
    <bug_when>2010-07-30 10:14:23 -0700</bug_when>
    <thetext>@Oliver Hunt: &quot;Sandboxed Natives&quot; is the term I use for natives imported from an iframe, ActiveX object, or modified via the non-standard __proto__ property. The `Sandbox` object in the code snippets refers to the test case I have linked to.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258263</commentid>
    <comment_count>11</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-07-30 10:17:42 -0700</bug_when>
    <thetext>&gt; What do sandboxes have to do with this?

Noting.

&gt; The testcase is simply using an iframe, i don&apos;t see any sign of the sandbox attribute?

That&apos;s correct.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258264</commentid>
    <comment_count>12</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-07-30 10:17:59 -0700</bug_when>
    <thetext>(In reply to comment #11)
&gt; &gt; What do sandboxes have to do with this?
&gt; 
&gt; Noting.

Err.  &quot;Nothing.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258766</commentid>
    <comment_count>13</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-08-02 03:24:00 -0700</bug_when>
    <thetext>How is this related to bug 27088?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258992</commentid>
    <comment_count>14</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-08-02 11:13:15 -0700</bug_when>
    <thetext>&gt; How is this related to bug 27088?

The difference in behavior is similar (prototypes get wired up to the wrong objects), but the fix will be different.  Bug 27088 is about JavaScript objects constructed in WebCore.  This bug is about JavaScript objects constructed in JavaScriptCore (e.g., via the Array and String constructors).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>369715</commentid>
    <comment_count>15</comment_count>
    <who name="John-David Dalton">john.david.dalton</who>
    <bug_when>2011-03-18 10:39:22 -0700</bug_when>
    <thetext>Just a heads up. The discussion of removing __proto__ over on the Mozilla bug tracker is related to this ticket. https://bugzilla.mozilla.org/show_bug.cgi?id=642500

Because of this bug part of the code I maintain will fall to __proto__. If this bug was fixed that would remove the strain and cause me to sleep better at night. This seems to be a Safari only issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>370275</commentid>
    <comment_count>16</comment_count>
    <who name="John-David Dalton">john.david.dalton</who>
    <bug_when>2011-03-20 21:06:51 -0700</bug_when>
    <thetext>Just confirmed via the `Reduced test case` that this bug still exists in WebKit Nightly r80840 built on March 11, 2011. Can the status be changed to `confirmed`?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>390562</commentid>
    <comment_count>17</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2011-04-21 19:58:40 -0700</bug_when>
    <thetext>This is now fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>390577</commentid>
    <comment_count>18</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-04-21 20:28:49 -0700</bug_when>
    <thetext>Should we land Adam&apos;s test case now?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422391</commentid>
    <comment_count>19</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2011-06-16 20:31:39 -0700</bug_when>
    <thetext>Test case landed in r89111.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>63058</attachid>
            <date>2010-07-30 07:35:13 -0700</date>
            <delta_ts>2010-07-30 07:35:13 -0700</delta_ts>
            <desc>Reduced test case</desc>
            <filename>case.html</filename>
            <type>text/html</type>
            <size>172</size>
            <attacher name="Adam Barth">abarth</attacher>
            
              <data encoding="base64">PGlmcmFtZT48L2lmcmFtZT4KPHNjcmlwdD4KdmFyIGFycmF5Q29uc3RydWN0b3IgPSBmcmFtZXNb
MF0uQXJyYXk7CmFycmF5Q29uc3RydWN0b3IucHJvdG90eXBlLmZvbyA9ICJiYXIiOwp2YXIgeCA9
IG5ldyBhcnJheUNvbnN0cnVjdG9yKCk7CmRvY3VtZW50LndyaXRlKHguZm9vKTsKPC9zY3JpcHQ+
Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>