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 | load(libdir + "parallelarray-helpers.js"); |
michael@0 | 2 | |
michael@0 | 3 | function testICProto() { |
michael@0 | 4 | function C() {} |
michael@0 | 5 | C.prototype.foo = "foo"; |
michael@0 | 6 | var c = new C; |
michael@0 | 7 | assertArraySeqParResultsEq( |
michael@0 | 8 | range(0, minItemsTestingThreshold), |
michael@0 | 9 | "map", |
michael@0 | 10 | function() { return c.foo; }); |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | function f(o) { |
michael@0 | 14 | assertArraySeqParResultsEq( |
michael@0 | 15 | range(0, minItemsTestingThreshold), |
michael@0 | 16 | "map", |
michael@0 | 17 | function() { return o.foo; }); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | function g(o) { |
michael@0 | 21 | assertArraySeqParResultsEq( |
michael@0 | 22 | range(0, minItemsTestingThreshold), |
michael@0 | 23 | "map", |
michael@0 | 24 | function() { return o.length; }); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function testICMultiple() { |
michael@0 | 28 | var o1 = { foo: 0 }; |
michael@0 | 29 | var o2 = { foo: 0, bar: '' }; |
michael@0 | 30 | var o3 = { foo: 0, bar: '', baz: function () { } }; |
michael@0 | 31 | var o4 = { foo: { } }; |
michael@0 | 32 | f(o1); f(o2); f(o3); f(o2); f(o1); f(o4); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function testICSameShapeDifferentProto() { |
michael@0 | 36 | function A () { this.bar = 1; } |
michael@0 | 37 | A.prototype.foo = "a"; |
michael@0 | 38 | A.prototype.a = true; |
michael@0 | 39 | var x = new A; |
michael@0 | 40 | function B () { this.bar = 2; } |
michael@0 | 41 | B.prototype.foo = "b"; |
michael@0 | 42 | A.prototype.b = true; |
michael@0 | 43 | var y = new B; |
michael@0 | 44 | |
michael@0 | 45 | f(x); |
michael@0 | 46 | f(y); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function testICArrayLength() { |
michael@0 | 50 | var o1 = { length: 42 }; |
michael@0 | 51 | var o2 = [1,2,3,4]; |
michael@0 | 52 | g(o1); g(o2); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function testICTypedArrayLength() { |
michael@0 | 56 | var o1 = { length: 42 }; |
michael@0 | 57 | var o2 = new Int8Array(128); |
michael@0 | 58 | var o3 = new Uint8Array(128); |
michael@0 | 59 | var o4 = new Uint8ClampedArray(128); |
michael@0 | 60 | var o5 = new Int16Array(128); |
michael@0 | 61 | var o6 = new Uint16Array(128); |
michael@0 | 62 | var o7 = new Int32Array(128); |
michael@0 | 63 | var o8 = new Uint32Array(128); |
michael@0 | 64 | var o9 = new Float32Array(128); |
michael@0 | 65 | var o0 = new Float64Array(128); |
michael@0 | 66 | g(o1); g(o2); g(o3); g(o4); g(o5); g(o6); g(o7); g(o8); g(o9); g(o0); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | if (getBuildConfiguration().parallelJS) { |
michael@0 | 70 | testICProto(); |
michael@0 | 71 | testICMultiple(); |
michael@0 | 72 | testICSameShapeDifferentProto(); |
michael@0 | 73 | testICArrayLength(); |
michael@0 | 74 | testICTypedArrayLength(); |
michael@0 | 75 | } |