Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // The property assignments in Array.prototype.sort are strict assignments. |
michael@0 | 2 | |
michael@0 | 3 | load(libdir + "asserts.js"); |
michael@0 | 4 | |
michael@0 | 5 | var a = ["A", , "B", "C", "D"]; |
michael@0 | 6 | var normalArrayElementDesc = Object.getOwnPropertyDescriptor(a, 0); |
michael@0 | 7 | var getterDesc = { |
michael@0 | 8 | configurable: false, |
michael@0 | 9 | enumerable: true, |
michael@0 | 10 | get: function () { return "F"; }, |
michael@0 | 11 | set: undefined |
michael@0 | 12 | }; |
michael@0 | 13 | Object.defineProperty(a, 1, getterDesc); |
michael@0 | 14 | |
michael@0 | 15 | // a.sort is permitted to try to delete a[1] or to try to assign a[1], but it |
michael@0 | 16 | // must try one or the other. Either one will fail, throwing a TypeError. |
michael@0 | 17 | assertThrowsInstanceOf(() => a.sort(), TypeError); |
michael@0 | 18 | |
michael@0 | 19 | // a.sort() is not permitted to delete the nonconfigurable property. |
michael@0 | 20 | assertDeepEq(Object.getOwnPropertyDescriptor(a, 1), getterDesc); |
michael@0 | 21 | |
michael@0 | 22 | // The values left in the other elements of a are unspecified; some or all may |
michael@0 | 23 | // have been deleted. |
michael@0 | 24 | for (var i = 0; i < a.length; i++) { |
michael@0 | 25 | if (i !== 1 && a.hasOwnProperty(i)) { |
michael@0 | 26 | normalArrayElementDesc.value = a[i]; |
michael@0 | 27 | assertDeepEq(Object.getOwnPropertyDescriptor(a, i), normalArrayElementDesc); |
michael@0 | 28 | } |
michael@0 | 29 | } |