Debian Codegraph @

js/src/tests/non262/object/setPrototypeOf-cycle.js

raw
1 // The cycle check in 9.1.2 [[SetPrototypeOf]] does not walk proxies.
2 // Therefore it's very easy to create prototype chain cycles involving proxies,
3 // and the spec requires us to accept this.
4
5 var t = {};
6 var p = new Proxy(t, {});
7 Object.setPrototypeOf(t, p); // 🙈
8
9 // Actually doing anything that searches this object's prototype chain
10 // technically should not terminate. We instead throw "too much recursion".
11 for (var obj of [t, p]) {
12 assertThrowsInstanceOf(() => "x" in obj, InternalError);
13 assertThrowsInstanceOf(() => obj.x, InternalError);
14 assertThrowsInstanceOf(() => { obj.x = 1; }, InternalError);
15 }
16 reportCompare(0, 0);