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.
1 // Array.of calls a "length" setter if one is present.
3 var hits = 0;
4 var lastObj = null, lastVal = undefined;
5 function setter(v) {
6 hits++;
7 lastObj = this;
8 lastVal = v;
9 }
11 // when the setter is on the new object
12 function Pack() {
13 Object.defineProperty(this, "length", {set: setter});
14 }
15 Pack.of = Array.of;
16 var pack = Pack.of("wolves", "cards", "cigarettes", "lies");
17 assertEq(lastObj, pack);
18 assertEq(lastVal, 4);
20 // when the setter is on the new object's prototype
21 function Bevy() {}
22 Object.defineProperty(Bevy.prototype, "length", {set: setter});
23 Bevy.of = Array.of;
24 var bevy = Bevy.of("quail");
25 assertEq(lastObj, bevy);
26 assertEq(lastVal, 1);