Debian Codegraph @

js/src/jit-test/tests/basic/bug1492920.js

raw
1 var N = 20;
2 var k = 15; // k < N
3
4 /* test 1: insertion of new blank object in ctor.__proto__ chain */
5
6 function C() {}
7 C.__proto__ = Object.create(Function.prototype);
8
9 for (var i = 0; i < N; i++) {
10 var o = new C();
11 assertEq(o instanceof C, true);
12 }
13
14 /* test 2: overriding of @@hasInstance on the proto chain, partway
15 * through execution (should trigger a guard) */
16
17 function D() {}
18
19 for (var i = 0; i < N; i++) {
20 var o = new D();
21 if (i == k) {
22 D.__proto__ = {[Symbol.hasInstance]() { return false; }};
23 }
24 assertEq(o instanceof D, i < k);
25 }
26
27 /* test 3: overriding of @@hasInstance on an intermediate object in the proto
28 * chain */
29
30 function E() {}
31
32 E.__proto__ = Object.create(Object.create(Object.create(Function.prototype)));
33 var intermediateProto = E.__proto__.__proto__;
34
35 for (var i = 0; i < N; i++) {
36 var o = new E;
37 if (i == k) {
38 intermediateProto.__proto__ = {[Symbol.hasInstance]() { return false; }};
39 }
40 assertEq(o instanceof E, i < k);
41 }