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 testBitOrInconvertibleObjectInconvertibleObject() |
michael@0 | 2 | { |
michael@0 | 3 | var count1 = 0; |
michael@0 | 4 | function toString1() { ++count1; if (count1 == 95) return {}; return count1; } |
michael@0 | 5 | var o1 = {valueOf: undefined, toString: toString1}; |
michael@0 | 6 | var count2 = 0; |
michael@0 | 7 | function toString2() { ++count2; if (count2 == 95) return {}; return count2; } |
michael@0 | 8 | var o2 = {valueOf: undefined, toString: toString2}; |
michael@0 | 9 | |
michael@0 | 10 | var threw = false; |
michael@0 | 11 | try |
michael@0 | 12 | { |
michael@0 | 13 | for (var i = 0; i < 100; i++) |
michael@0 | 14 | var q = o1 | o2; |
michael@0 | 15 | } |
michael@0 | 16 | catch (e) |
michael@0 | 17 | { |
michael@0 | 18 | threw = true; |
michael@0 | 19 | if (i !== 94) |
michael@0 | 20 | return "expected i === 94, got " + i; |
michael@0 | 21 | if (q !== 94) |
michael@0 | 22 | return "expected q === 94, got " + q; |
michael@0 | 23 | if (count1 !== 95) |
michael@0 | 24 | return "expected count1 === 95, got " + count1; |
michael@0 | 25 | if (count2 !== 94) |
michael@0 | 26 | return "expected count2 === 94, got " + count2; |
michael@0 | 27 | } |
michael@0 | 28 | if (!threw) |
michael@0 | 29 | return "expected throw with o1 | o2"; |
michael@0 | 30 | |
michael@0 | 31 | return "pass"; |
michael@0 | 32 | } |
michael@0 | 33 | assertEq(testBitOrInconvertibleObjectInconvertibleObject(), "pass"); |