summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/harmony/proxies-prototype-target-stackoverflow.js
blob: ba55f6aad9357cfff3b600addb70a02148a415b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-proxies --harmony-reflect

// Test that traps that involve walking the target object's prototype chain
// don't overflow the stack when the original proxy is on that chain.

(function TestGetPrototype() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  try { return p.__proto__; } catch(e) { assertInstanceof(e, RangeError); }
})();

(function TestSetPrototype() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  try { p.__proto__ = p; } catch(e) { assertInstanceof(e, RangeError); }
})();

(function TestHasProperty() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  try {
    return Reflect.has(p, "foo");
  } catch(e) { assertInstanceof(e, RangeError); }
})();

(function TestSet() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  try { p.foo = 1; } catch(e) { assertInstanceof(e, RangeError); }
})();

(function TestGet() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  try { return p.foo; } catch(e) { assertInstanceof(e, RangeError); }
})();

(function TestEnumerate() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  try { for (var x in p) {} } catch(e) { assertInstanceof(e, RangeError); }
})();

// The following traps don't involve the target object's prototype chain;
// we test them anyway for completeness.

(function TestIsExtensible() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  return Reflect.isExtensible(p);
})();

(function TestPreventExtensions() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  Reflect.preventExtensions(p);
})();

(function TestGetOwnPropertyDescriptor() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  return Object.getOwnPropertyDescriptor(p, "foo");
})();

(function TestDeleteProperty() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  delete p.foo;
})();

(function TestDefineProperty() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  Object.defineProperty(p, "foo", {value: "bar"});
})();

(function TestOwnKeys() {
  var p = new Proxy({}, {});
  p.__proto__ = p;
  return Reflect.ownKeys(p);
})();

(function TestCall() {
  var p = new Proxy(function() {}, {});
  p.__proto__ = p;
  return p();
})();

(function TestConstruct() {
  var p = new Proxy(function() { this.foo = 1; }, {});
  p.__proto__ = p;
  return new p();
})();