Welcome to mirror list, hosted at ThFree Co, Russian Federation.

regress-7716.js « regress « mjsunit « test « v8 « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ac891ceec537e8aaf946b00bb285449fcad9b1b8 (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
// Copyright 2018 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.


// Deeply nested target.

let proxy = new Proxy(function(){}, {});
for (let i = 0; i < 100000; i++) {
  proxy = new Proxy(proxy, {});
}

// We get a stack overflow in all cases except for Reflect.apply, which here
// happens to run in constant space: Call jumps into CallProxy and CallProxy
// jumps into the next Call.
assertDoesNotThrow(() => Reflect.apply(proxy, {}, []));
assertThrows(() => Reflect.construct(proxy, []), RangeError);
assertThrows(() => Reflect.defineProperty(proxy, "x", {}), RangeError);
assertThrows(() => Reflect.deleteProperty(proxy, "x"), RangeError);
assertThrows(() => Reflect.get(proxy, "x"), RangeError);
assertThrows(() => Reflect.getOwnPropertyDescriptor(proxy, "x"), RangeError);
assertThrows(() => Reflect.getPrototypeOf(proxy), RangeError);
assertThrows(() => Reflect.has(proxy, "x"), RangeError);
assertThrows(() => Reflect.isExtensible(proxy), RangeError);
assertThrows(() => Reflect.ownKeys(proxy), RangeError);
assertThrows(() => Reflect.preventExtensions(proxy), RangeError);
assertThrows(() => Reflect.setPrototypeOf(proxy, {}), RangeError);
assertThrows(() => Reflect.set(proxy, "x", {}), RangeError);


// Recursive handler.

function run(trap, ...args) {
  let handler = {};
  const proxy = new Proxy(function(){}, handler);
  handler[trap] = (target, ...args) => Reflect[trap](proxy, ...args);
  return Reflect[trap](proxy, ...args);
}

assertThrows(() => run("apply", {}, []), RangeError);
assertThrows(() => run("construct", []), RangeError);
assertThrows(() => run("defineProperty", "x", {}), RangeError);
assertThrows(() => run("deleteProperty", "x"), RangeError);
assertThrows(() => run("get", "x"), RangeError);
assertThrows(() => run("getOwnPropertyDescriptor", "x"), RangeError);
assertThrows(() => run("has", "x"), RangeError);
assertThrows(() => run("isExtensible"), RangeError);
assertThrows(() => run("ownKeys"), RangeError);
assertThrows(() => run("preventExtensions"), RangeError);
assertThrows(() => run("setPrototypeOf", {}), RangeError);
assertThrows(() => run("set", "x", {}), RangeError);