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 | function test1() { |
michael@0 | 2 | // splice GetElement calls are observable and should be executed even if |
michael@0 | 3 | // the return value of splice is unused. |
michael@0 | 4 | Object.defineProperty(Object.prototype, "0", {get: function() { |
michael@0 | 5 | c++; |
michael@0 | 6 | }, set: function() {}}); |
michael@0 | 7 | var arr = [,,,]; |
michael@0 | 8 | var c = 0; |
michael@0 | 9 | for (var i=0; i<100; i++) { |
michael@0 | 10 | arr.splice(0, 1); |
michael@0 | 11 | arr.length = 1; |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | assertEq(c, 100); |
michael@0 | 15 | } |
michael@0 | 16 | test1(); |
michael@0 | 17 | |
michael@0 | 18 | function test2() { |
michael@0 | 19 | var arr = []; |
michael@0 | 20 | for (var i=0; i<100; i++) |
michael@0 | 21 | arr.push(i); |
michael@0 | 22 | for (var i=0; i<40; i++) |
michael@0 | 23 | arr.splice(0, 2); |
michael@0 | 24 | assertEq(arr.length, 20); |
michael@0 | 25 | assertEq(arr[0], 80); |
michael@0 | 26 | } |
michael@0 | 27 | test2(); |
michael@0 | 28 | |
michael@0 | 29 | function testNonArray() { |
michael@0 | 30 | for (var i=0; i<10; i++) { |
michael@0 | 31 | var o = {splice:[].splice, 0:"a", 1:"b", 2:"c", length:3}; |
michael@0 | 32 | o.splice(0, 2); |
michael@0 | 33 | assertEq(o.length, 1); |
michael@0 | 34 | assertEq(o[0], "c"); |
michael@0 | 35 | } |
michael@0 | 36 | } |
michael@0 | 37 | testNonArray(); |