js/src/jit-test/tests/ion/bug717466.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 Person(){}
michael@0 2 function Ninja(){}
michael@0 3 Ninja.prototype = new Person();
michael@0 4 function House(){}
michael@0 5
michael@0 6 var empty = {};
michael@0 7 var person = new Person();
michael@0 8 var ninja = new Ninja();
michael@0 9 var house = new House();
michael@0 10 var string = new String();
michael@0 11 var bindNinja = Ninja.bind({});
michael@0 12
michael@0 13 var array = {};
michael@0 14 array.__proto__ = Array.prototype;
michael@0 15 var array2 = {};
michael@0 16 array2.__proto__ = array.prototype;
michael@0 17
michael@0 18 function test(v, v2) {
michael@0 19 return v instanceof v2;
michael@0 20 }
michael@0 21 function test2(v, v2) {
michael@0 22 return v instanceof v2;
michael@0 23 }
michael@0 24 function test3(v, v2) {
michael@0 25 return v instanceof v2;
michael@0 26 }
michael@0 27 function test4(v, v2) {
michael@0 28 return v instanceof v2;
michael@0 29 }
michael@0 30
michael@0 31 // Test if specialized for object works
michael@0 32 for (var i=0; i!=41; i++) {
michael@0 33 assertEq(test(person, Person), true);
michael@0 34 assertEq(test(empty, Person), false);
michael@0 35 assertEq(test(ninja, Person), true);
michael@0 36 assertEq(test(house, Person), false);
michael@0 37 assertEq(test(string, Person), false);
michael@0 38 assertEq(test(new bindNinja(), Person), true);
michael@0 39 assertEq(test(new Ninja(), bindNinja), true);
michael@0 40 assertEq(test(string, String), true);
michael@0 41 assertEq(test(array, Array), true);
michael@0 42 assertEq(test(empty, Object), true);
michael@0 43
michael@0 44 // Test if bailout works
michael@0 45 assertEq(test(0.1, Object), false);
michael@0 46
michael@0 47 // Should generate TypeError
michael@0 48 var err = false;
michael@0 49 try {
michael@0 50 test(0.1, 5);
michael@0 51 } catch (e) { err = true; }
michael@0 52 assertEq(err, true);
michael@0 53
michael@0 54 // Should generate TypeError
michael@0 55 var err = false;
michael@0 56 try {
michael@0 57 test(empty, empty);
michael@0 58 } catch (e) { err = true; }
michael@0 59 assertEq(err, true);
michael@0 60
michael@0 61 // Should generate TypeError
michael@0 62 var err = false;
michael@0 63 try {
michael@0 64 test(5.0, empty);
michael@0 65 } catch (e) { err = true; }
michael@0 66 assertEq(err, true);
michael@0 67 }
michael@0 68
michael@0 69 // Test if specialized for non-object lhs
michael@0 70 for (var i=0; i!=41; i++) {
michael@0 71 assertEq(test2(0.1, Object), false);
michael@0 72 }
michael@0 73
michael@0 74 // Check if we don't regress on https://bugzilla.mozilla.org/show_bug.cgi?id=7635
michael@0 75 function Foo() {};
michael@0 76 theproto = {};
michael@0 77 Foo.prototype = theproto;
michael@0 78
michael@0 79 for (var i=0; i!=41; i++) {
michael@0 80 assertEq(test3(theproto, Foo), false);
michael@0 81 }
michael@0 82

mercurial