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 | // Check that the implicit-this logic needed for CALLNAME global stubs |
michael@0 | 2 | // handles non-function values correctly. |
michael@0 | 3 | var self = this; |
michael@0 | 4 | var count = 0; |
michael@0 | 5 | function g1() { |
michael@0 | 6 | assertEq(this, self); |
michael@0 | 7 | this.count++; |
michael@0 | 8 | } |
michael@0 | 9 | function g2() { |
michael@0 | 10 | this.count += 10; |
michael@0 | 11 | } |
michael@0 | 12 | function f() { |
michael@0 | 13 | function f1(other) { |
michael@0 | 14 | eval("gc(); h = g1"); |
michael@0 | 15 | try { |
michael@0 | 16 | for(var i=0; i<20; i++) { |
michael@0 | 17 | h(); |
michael@0 | 18 | if (i === 9) { |
michael@0 | 19 | h = other; |
michael@0 | 20 | } |
michael@0 | 21 | } |
michael@0 | 22 | assertEq(typeof other, "function"); |
michael@0 | 23 | } catch(e) { |
michael@0 | 24 | assertEq(typeof other !== "function", true); |
michael@0 | 25 | assertEq(e instanceof TypeError, true); |
michael@0 | 26 | } |
michael@0 | 27 | } |
michael@0 | 28 | f1(3); |
michael@0 | 29 | f1(null); |
michael@0 | 30 | f1({}); |
michael@0 | 31 | f1(Math.abs); |
michael@0 | 32 | f1(g2); |
michael@0 | 33 | } |
michael@0 | 34 | f(); |
michael@0 | 35 | assertEq(count, 150); |