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 g1(x) { |
michael@0 | 2 | return x + 1; |
michael@0 | 3 | } |
michael@0 | 4 | function f1() { |
michael@0 | 5 | var y = 0; |
michael@0 | 6 | for (var i=0; i<100; i++) { |
michael@0 | 7 | y += g1(g1(i)); |
michael@0 | 8 | } |
michael@0 | 9 | return y; |
michael@0 | 10 | } |
michael@0 | 11 | g1(10); |
michael@0 | 12 | assertEq(f1(), 5150); |
michael@0 | 13 | |
michael@0 | 14 | x = 1; |
michael@0 | 15 | other = newGlobal("same-compartment"); |
michael@0 | 16 | other.eval("f = function() { return x; }; x = 2;"); |
michael@0 | 17 | |
michael@0 | 18 | h = other.f; |
michael@0 | 19 | |
michael@0 | 20 | function testOtherGlobal() { |
michael@0 | 21 | var y = 0; |
michael@0 | 22 | for (var i=0; i<100; i++) { |
michael@0 | 23 | y += h(); |
michael@0 | 24 | } |
michael@0 | 25 | return y; |
michael@0 | 26 | } |
michael@0 | 27 | h(); |
michael@0 | 28 | assertEq(testOtherGlobal(), 200); |
michael@0 | 29 | |
michael@0 | 30 | // Note: this test requires on On-Stack Invalidation. |
michael@0 | 31 | f2 = function() { |
michael@0 | 32 | return x; |
michael@0 | 33 | } |
michael@0 | 34 | function test2() { |
michael@0 | 35 | var y = 0; |
michael@0 | 36 | for (var i=0; i<50; i++) { |
michael@0 | 37 | y += f2(); |
michael@0 | 38 | } |
michael@0 | 39 | return y; |
michael@0 | 40 | } |
michael@0 | 41 | assertEq(test2(), 50); |
michael@0 | 42 | f2 = h; |
michael@0 | 43 | assertEq(test2(), 100); |