<?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>75788</bug_id>
          
          <creation_ts>2012-01-07 22:51:22 -0800</creation_ts>
          <short_desc>Array.prototype.pop should throw if property is not configurable</short_desc>
          <delta_ts>2012-07-02 12:26:15 -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>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></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="Gavin Barraclough">barraclough</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>metaweta</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>531718</commentid>
    <comment_count>0</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2012-01-07 22:51:22 -0800</bug_when>
    <thetext>See ES5.1 15.4.4.6 step 5c.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>656761</commentid>
    <comment_count>1</comment_count>
    <who name="">metaweta</who>
    <bug_when>2012-06-25 11:47:12 -0700</bug_when>
    <thetext>This is far worse than merely not throwing, which is acceptable outside of strict mode.  The current behavior violates the frozenness invariant:

var a = [1,2,3];
Object.freeze(a);
a.pop(); // returns 3
a; // [1,2]
Object.isFrozen(a); // true

It&apos;s a security bug and should be escalated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>660926</commentid>
    <comment_count>2</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2012-06-29 18:47:20 -0700</bug_when>
    <thetext>I don&apos;t think this bug still exists in ToT:

var a = [1,2,3];
Object.freeze(a);
a.pop(); // Exception: TypeError: Attempted to assign to readonly property.
a; // 1,2,3
Object.isFrozen(a); // true

Technically I think we now implement the spec correctly, though we do give a misleading error message (which is outside of the spec).

We should be throwing a type error at the point pop() tries to delete the old property,
    15.4.4.6 step 5.c. -&gt; 8.12.7 step 4
Instead we&apos;re silently ignoring the failed delete, but we&apos;ll throw a type error when pop tries to change the array&apos;s length.
    15.4.4.6 step 5.d. -&gt; 15.4.5.1 step 3.g.

We will generate the right error message if the last property in the array is not configurable but length is writable:

var a = [1,2,3];
Object.defineProperty(a, 2, {configurable:false})
a.pop() // Exception: TypeError: Unable to delete property.

This works because the first attempted delete will (erroneously) silently fail, but when the length property is changed we&apos;ll attempt to remove all properties beyond the new array bounds, and this will throw as expected with the correct error message.
    15.4.4.6 step 5.d. -&gt; 15.4.5.1 step 3.l.iii.4.

I&apos;ll put up a patch to make the first delete catch the error, as it should, so the TypeError has the right error message.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>661669</commentid>
    <comment_count>3</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2012-07-02 12:26:15 -0700</bug_when>
    <thetext>Fixed in r121700</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>