Bug 171915
Summary: | [JSC] Proxy's GetPrototypeOf does not invoked during access to __proto__ property | ||
---|---|---|---|
Product: | WebKit | Reporter: | GSkachkov <gskachkov> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | keith_miller, saam, ysuzuki |
Priority: | P2 | ||
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | 169040 | ||
Bug Blocks: |
GSkachkov
Also I found interesting behavior of proxy:
```
var target = {};
proxy = new Proxy(target, {
getPrototypeOf(t) { console.log("get prototype:", t); return t.__proto__; }
});
proxy.__proto__ === target.__proto__;
```
In Chrome & FireFox it prints:
// get prototype: ....
// Object ...
In jsc we do not print `get prototype: ....`, just `Object ...`
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Saam Barati
Maybe we don't properly forward the receiver?
I think this code should definitely go down the get() path in Proxy, but maybe the issue is we don't call get() on target in the correct way.
GSkachkov
(In reply to Saam Barati from comment #1)
> Maybe we don't properly forward the receiver?
> I think this code should definitely go down the get() path in Proxy, but
> maybe the issue is we don't call get() on target in the correct way.
Hmm, It seems that you right.
If I add get, it start invoke getPrototypeOf
```
var target = {};
var proxy = new Proxy(target, {
getPrototypeOf(t, ) { print("get prototype:", t); return t; },
get(t, property, receiver) { print("get", property); return Reflect.get(t, property, receiver); }
});
```
Output:
>>> proxy.__proto__
get __proto__
get prototype: [object Object]
[object Object]
GSkachkov
(In reply to Saam Barati from comment #1)
> Maybe we don't properly forward the receiver?
> I think this code should definitely go down the get() path in Proxy, but
> maybe the issue is we don't call get() on target in the correct way.
In casa if we use only getPrototypeOf handler, we just call target->get() for __proto__ property in performProxyGet, so we forget that we are executing in proxy context, that why we do not call proxy getPrototypeOf handler, but according to spec we should invoke
target.[[Get]](P, Receiver) - where Receiver is current Proxy. So I think we need create new method for JSObject that support Receiver as the parameter
GSkachkov
Fixed by bug 164849
*** This bug has been marked as a duplicate of bug 164849 ***