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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:4af210fec865
1 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
4 */
5
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";
11
12 print(BUGNUMBER + ": " + summary);
13
14 /**************
15 * BEGIN TEST *
16 **************/
17
18 var arr = [];
19 var p = new Proxy(arr, {});
20
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 });
24
25 // Same here.
26 Object.defineProperty(p, "length", { value: 42, enumerable: true });
27
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);
34
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);
40
41 /******************************************************************************/
42
43 if (typeof reportCompare === "function")
44 reportCompare(true, true);
45
46 print("Tests complete");

mercurial