Ensure Proxy [[Get]] and [[Set]] pass correct receiver (#792)

* Ensure Proxy [[Get]] passes correct receiver

* add [[Get]] test for proxy in prototype

* diversify how traps are missing

* ensure [[Set]] passes correct receiver

* rename to match other tests

* remove extra tests

* add esid

* add description
This commit is contained in:
Aleksey Shvayka 2016-11-18 00:26:34 +02:00 committed by Tom Care
parent 84e6ba81d0
commit bef7f988d2
2 changed files with 53 additions and 0 deletions

View File

@ -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);

View File

@ -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);