diff --git a/test/built-ins/Proxy/get/trap-is-undefined-receiver.js b/test/built-ins/Proxy/get/trap-is-undefined-receiver.js new file mode 100644 index 0000000000000000000000000000000000000000..8a0a44502fb5c6c6e294fb346440f09cd4100ff2 --- /dev/null +++ b/test/built-ins/Proxy/get/trap-is-undefined-receiver.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.8 +esid: sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver +description: > + Pass to target's [[Get]] correct receiver if trap is missing +info: > + [[Get]] (P, Receiver) + + 7. If trap is undefined, then + a. Return ? target.[[Get]](P, Receiver). +---*/ + +var target = { + get attr() { + return this; + } +}; + +var p = new Proxy(target, { get: null }); +assert.sameValue(p.attr, p); + +var pParent = Object.create(new Proxy(target, {})); +assert.sameValue(pParent.attr, pParent); diff --git a/test/built-ins/Proxy/set/trap-is-undefined-receiver.js b/test/built-ins/Proxy/set/trap-is-undefined-receiver.js new file mode 100644 index 0000000000000000000000000000000000000000..a82fcdb191395f795d3099f0aa54827eee58332b --- /dev/null +++ b/test/built-ins/Proxy/set/trap-is-undefined-receiver.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.9 +esid: sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver +description: > + Pass to target's [[Set]] correct receiver if trap is missing +info: > + [[Set]] (P, V, Receiver) + + 7. If trap is undefined, then + a. Return ? target.[[Set]](P, V, Receiver). +---*/ + +var context; +var target = { + set attr(val) { + context = this; + } +}; + +var p = new Proxy(target, { set: null }); +p.attr = 1; +assert.sameValue(context, p); + +var pParent = Object.create(new Proxy(target, {})); +pParent.attr = 3; +assert.sameValue(context, pParent);