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