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 get_value_undefined(o) { |
michael@0 | 2 | return o.value |
michael@0 | 3 | } |
michael@0 | 4 | |
michael@0 | 5 | function get_value_null(o) { |
michael@0 | 6 | return o.value |
michael@0 | 7 | } |
michael@0 | 8 | |
michael@0 | 9 | function get_value_int(o) { |
michael@0 | 10 | return o.value |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | function get_value_effectfull(o) { |
michael@0 | 14 | return o.value |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | var count = 0 |
michael@0 | 18 | var o_undefined = {value: undefined} |
michael@0 | 19 | var o_null = {value: null} |
michael@0 | 20 | var o_int = {value: 3} |
michael@0 | 21 | var o_effectfull = {} |
michael@0 | 22 | Object.defineProperty(o_effectfull, "value", { get: function () { count++; return undefined; } }); |
michael@0 | 23 | |
michael@0 | 24 | // compiled as undefined |
michael@0 | 25 | for(var i=0; i<42; i++) |
michael@0 | 26 | get_value_undefined(o_undefined) |
michael@0 | 27 | |
michael@0 | 28 | // compiled as null |
michael@0 | 29 | for(var i=0; i<42; i++) |
michael@0 | 30 | get_value_null(o_null) |
michael@0 | 31 | |
michael@0 | 32 | // compiled as int |
michael@0 | 33 | for(var i=0; i<42; i++) |
michael@0 | 34 | get_value_int(o_int) |
michael@0 | 35 | |
michael@0 | 36 | // compiled as effectfull property access |
michael@0 | 37 | for(var i=0; i<42; i++) |
michael@0 | 38 | get_value_effectfull(o_effectfull) |
michael@0 | 39 | |
michael@0 | 40 | // Note: |
michael@0 | 41 | // because of bug 715111 when there is an invalidation we have bogus values on the stack. |
michael@0 | 42 | // So we get wrong values. Therefor I run them twice. On as 'warmup'. Second time to test |
michael@0 | 43 | |
michael@0 | 44 | count = 0 |
michael@0 | 45 | assertEq(get_value_undefined(o_undefined), undefined); |
michael@0 | 46 | get_value_undefined(o_null) |
michael@0 | 47 | assertEq(get_value_undefined(o_null), null); |
michael@0 | 48 | get_value_undefined(o_int) |
michael@0 | 49 | assertEq(get_value_undefined(o_int), 3); |
michael@0 | 50 | get_value_undefined(o_effectfull) |
michael@0 | 51 | assertEq(get_value_undefined(o_effectfull), undefined); |
michael@0 | 52 | assertEq(get_value_undefined(o_undefined), undefined); |
michael@0 | 53 | assertEq(count, 2); |
michael@0 | 54 | |
michael@0 | 55 | count = 0 |
michael@0 | 56 | assertEq(get_value_null(o_null), null); |
michael@0 | 57 | get_value_null(o_undefined) |
michael@0 | 58 | assertEq(get_value_null(o_undefined), undefined); |
michael@0 | 59 | get_value_null(o_int) |
michael@0 | 60 | assertEq(get_value_null(o_int), 3); |
michael@0 | 61 | get_value_null(o_effectfull) |
michael@0 | 62 | assertEq(get_value_null(o_effectfull), undefined); |
michael@0 | 63 | assertEq(get_value_null(o_null), null); |
michael@0 | 64 | assertEq(count, 2); |
michael@0 | 65 | |
michael@0 | 66 | count = 0 |
michael@0 | 67 | |
michael@0 | 68 | assertEq(get_value_int(o_int), 3); |
michael@0 | 69 | get_value_int(o_null) |
michael@0 | 70 | assertEq(get_value_int(o_null), null); |
michael@0 | 71 | get_value_int(o_undefined) |
michael@0 | 72 | assertEq(get_value_int(o_undefined), undefined); |
michael@0 | 73 | get_value_int(o_effectfull) |
michael@0 | 74 | assertEq(get_value_int(o_effectfull), undefined); |
michael@0 | 75 | assertEq(get_value_int(o_int), 3); |
michael@0 | 76 | assertEq(count, 2); |
michael@0 | 77 | |
michael@0 | 78 | count = 0 |
michael@0 | 79 | |
michael@0 | 80 | assertEq(get_value_effectfull(o_effectfull), undefined); |
michael@0 | 81 | get_value_effectfull(o_null) |
michael@0 | 82 | assertEq(get_value_effectfull(o_null), null); |
michael@0 | 83 | get_value_effectfull(o_undefined) |
michael@0 | 84 | assertEq(get_value_effectfull(o_undefined), undefined); |
michael@0 | 85 | get_value_effectfull(o_int) |
michael@0 | 86 | assertEq(get_value_effectfull(o_int), 3); |
michael@0 | 87 | assertEq(get_value_effectfull(o_effectfull), undefined); |
michael@0 | 88 | assertEq(count, 2); |