js/src/tests/ecma_5/extensions/proxy-array-target-length-definition.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 var gTestfile = 'proxy-array-target-length-definition.js';
     7 var BUGNUMBER = 905947;
     8 var summary =
     9   "Redefining an array's |length| property when redefining the |length| " +
    10   "property on a proxy with an array as target";
    12 print(BUGNUMBER + ": " + summary);
    14 /**************
    15  * BEGIN TEST *
    16  **************/
    18 var arr = [];
    19 var p = new Proxy(arr, {});
    21 // This really should throw a TypeError, but we're buggy just yet, and this
    22 // silently does nothing.
    23 Object.defineProperty(p, "length", { value: 17, configurable: true });
    25 // Same here.
    26 Object.defineProperty(p, "length", { value: 42, enumerable: true });
    28 // But at least we can check the property went unchanged.
    29 var pd = Object.getOwnPropertyDescriptor(p, "length");
    30 assertEq(pd.value, 0);
    31 assertEq(pd.writable, true);
    32 assertEq(pd.enumerable, false);
    33 assertEq(pd.configurable, false);
    35 var ad = Object.getOwnPropertyDescriptor(arr, "length");
    36 assertEq(ad.value, 0);
    37 assertEq(ad.writable, true);
    38 assertEq(ad.enumerable, false);
    39 assertEq(ad.configurable, false);
    41 /******************************************************************************/
    43 if (typeof reportCompare === "function")
    44   reportCompare(true, true);
    46 print("Tests complete");

mercurial