Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/get/trap-is-missing-target-is-proxy.js

raw
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver
6 description: >
7 If "get" trap is null or undefined, [[Get]] call is properly
8 forwarded to [[ProxyTarget]] (which is also a Proxy object).
9 info: |
10 [[Get]] ( P, Receiver )
11
12 [...]
13 5. Let target be O.[[ProxyTarget]].
14 6. Let trap be ? GetMethod(handler, "get").
15 7. If trap is undefined, then
16 a. Return ? target.[[Get]](P, Receiver).
17 features: [Proxy, Symbol.match]
18 ---*/
19
20 var regExp = /(?:)/i;
21 var regExpTarget = new Proxy(regExp, {});
22 var regExpProxy = new Proxy(regExpTarget, {});
23
24 assert.sameValue(Object.create(regExpProxy).lastIndex, 0);
25 assert.sameValue(regExpProxy[Symbol.match], RegExp.prototype[Symbol.match]);
26
27
28 var functionTarget = new Proxy(function(_arg) {}, {});
29 var functionProxy = new Proxy(functionTarget, {});
30
31 assert.sameValue(Object.create(functionProxy).length, 1);
32
33 reportCompare(0, 0);