Proxy object with target of TypedArray (ex: Int32Array) fails on method slice
Reported by
drol...@yahoo.com,
Oct 21 2016
|
||||||
Issue description
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36
Steps to reproduce the problem:
1. var proxy = new Proxy(new Int32Array(5),{});
2. var newarray = proxy.slice();
What is the expected behavior?
variable newarray should be a copy of the array proxied by proxy object.
What went wrong?
proxy.slice() throws exception "Uncaught TypeError: this is not a typed array"
Did this work before? N/A
Chrome version: 54.0.2840.59 Channel: n/a
OS Version: Ubuntu 14.04
Flash Version: Shockwave Flash 23.0 r0
I couldn't find any documentation stating that TypedArrays cannot be the target of a proxy, but perhaps this is the case. However, the proxy object only seems to fail when calling methods that return a new typedarray such as slice and subarray. It works as expected to have the proxy trap intercept calls to set, get, etc.
,
Oct 21 2016
,
Nov 23 2016
+Michael as this isn't a V8 infra issue, but would like to know where to move this bug if it's a V8 issue.
,
Nov 24 2016
This got a wrong label assigned. No infra.
,
Nov 24 2016
Repros in current d8. CC rossberg to clarify expected behavior.
,
Nov 24 2016
Working as intended. You can proxy built-in ES objects like typed arrays or dates just fine, but you need to write a handler that delegates all methods requiring access to their private state, that does not happen automagically.
,
Nov 24 2016
To proxy an ES object like a typed array, do I need a handler like:
{
get: function(target,prop,receiver){
if (setOfTypedArrayMethodNames.has(prop) === true){
return (...args) => target[prop](...args);
}
else return target[prop];
}
}
so that I can direct all method calls, as they are, to the target? For proxy objects with Array and user-defined constructor targets, I believe the methods are called on the target without the need for the user-defined handler to intercept them and return the function bound to the target object.
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by drol...@yahoo.com
, Oct 21 2016