Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/get/trap-is-undefined-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]
18 includes: [compareArray.js]
19 ---*/
20
21 var plainObject = {
22 get 0() {
23 return 1;
24 },
25 foo: 2,
26 set bar(_value) {},
27 };
28
29 var plainObjectTarget = new Proxy(plainObject, {});
30 var plainObjectProxy = new Proxy(plainObjectTarget, {
31 get: undefined,
32 });
33
34 assert.sameValue(Object.create(plainObjectProxy)[0], 1);
35 assert.sameValue(plainObjectProxy.foo, 2);
36 assert.sameValue(plainObjectProxy.bar, undefined);
37
38
39 var array = [1, 2, 3];
40 var arrayTarget = new Proxy(array, {});
41 var arrayProxy = new Proxy(arrayTarget, {
42 get: undefined,
43 });
44
45 assert.compareArray(arrayProxy, array);
46
47 reportCompare(0, 0);