blob: 3da36c451d6814e2824797206a9a95eddf190adb [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Ben Murdochda12d292016-06-02 14:46:10 +01005// Flags: --stack-size=100
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00006
7// Test that traps that involve walking the target object's prototype chain
8// don't overflow the stack when the original proxy is on that chain.
9
10(function TestGetPrototype() {
11 var handler = {};
12 var p = new Proxy({}, handler);
13 handler.__proto__ = p;
14 try { return p.__proto__; } catch(e) { assertInstanceof(e, RangeError); }
15})();
16
17(function TestSetPrototype() {
18 var handler = {};
19 var p = new Proxy({}, handler);
20 handler.__proto__ = p;
21 try { p.__proto__ = p; } catch(e) { assertInstanceof(e, RangeError); }
22})();
23
24(function TestHasProperty() {
25 var handler = {};
26 var p = new Proxy({}, handler);
27 handler.__proto__ = p;
28 try {
29 return Reflect.has(p, "foo");
30 } catch(e) { assertInstanceof(e, RangeError); }
31})();
32
33(function TestSet() {
34 var handler = {};
35 var p = new Proxy({}, handler);
36 handler.__proto__ = p;
37 try { p.foo = 1; } catch(e) { assertInstanceof(e, RangeError); }
38})();
39
40(function TestGet() {
41 var handler = {};
42 var p = new Proxy({}, handler);
43 handler.__proto__ = p;
44 try { return p.foo; } catch(e) { assertInstanceof(e, RangeError); }
45})();
46
47(function TestEnumerate() {
48 var handler = {};
49 var p = new Proxy({}, handler);
50 handler.__proto__ = p;
51 try { for (var x in p) {} } catch(e) { assertInstanceof(e, RangeError); }
52})();
53
54(function TestIsExtensible() {
55 var handler = {};
56 var p = new Proxy({}, handler);
57 handler.__proto__ = p;
58 try {
59 return Reflect.isExtensible(p);
60 } catch(e) { assertInstanceof(e, RangeError); }
61})();
62
63(function TestPreventExtensions() {
64 var handler = {};
65 var p = new Proxy({}, handler);
66 handler.__proto__ = p;
67 try {
68 Reflect.preventExtensions(p);
69 } catch(e) { assertInstanceof(e, RangeError); }
70})();
71
72(function TestGetOwnPropertyDescriptor() {
73 var handler = {};
74 var p = new Proxy({}, handler);
75 handler.__proto__ = p;
76 try {
77 return Object.getOwnPropertyDescriptor(p, "foo");
78 } catch(e) { assertInstanceof(e, RangeError); }
79})();
80
81(function TestDeleteProperty() {
82 var handler = {};
83 var p = new Proxy({}, handler);
84 handler.__proto__ = p;
85 try { delete p.foo; } catch(e) { assertInstanceof(e, RangeError); }
86})();
87
88(function TestDefineProperty() {
89 var handler = {};
90 var p = new Proxy({}, handler);
91 handler.__proto__ = p;
92 try {
93 Object.defineProperty(p, "foo", {value: "bar"});
94 } catch(e) { assertInstanceof(e, RangeError); }
95})();
96
97(function TestOwnKeys() {
98 var handler = {};
99 var p = new Proxy({}, handler);
100 handler.__proto__ = p;
101 try {
102 return Reflect.ownKeys(p);
103 } catch(e) { assertInstanceof(e, RangeError); }
104})();
105
106(function TestCall() {
107 var handler = {};
108 var p = new Proxy(function() {}, handler);
109 handler.__proto__ = p;
110 try { return p(); } catch(e) { assertInstanceof(e, RangeError); }
111})();
112
113(function TestConstruct() {
114 var handler = {};
115 var p = new Proxy(function() { this.foo = 1; }, handler);
116 handler.__proto__ = p;
117 try { return new p(); } catch(e) { assertInstanceof(e, RangeError); }
118})();