Bug 171915 - [JSC] Proxy's GetPrototypeOf does not invoked during access to __proto__ property
Summary: [JSC] Proxy's GetPrototypeOf does not invoked during access to __proto__ prop...
Status: RESOLVED DUPLICATE of bug 164849
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 169040
Blocks:
  Show dependency treegraph
 
Reported: 2017-05-10 01:48 PDT by GSkachkov
Modified: 2017-05-30 12:18 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description GSkachkov 2017-05-10 01:48:37 PDT
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 ...`
Comment 1 Saam Barati 2017-05-10 09:39:42 PDT
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.
Comment 2 GSkachkov 2017-05-10 09:46:26 PDT
(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]
Comment 3 GSkachkov 2017-05-10 13:25:59 PDT
(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
Comment 4 GSkachkov 2017-05-30 12:18:10 PDT
Fixed by bug 164849

*** This bug has been marked as a duplicate of bug 164849 ***