New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 658068 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 1
Type: Bug



Sign in to add a comment

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.
 

Comment 1 by drol...@yahoo.com, Oct 21 2016

var newarray = new Int32Array(proxy);

will throw the same exception "Uncaught TypeError" as thrown on proxy.slice().

Comment 2 by e...@chromium.org, Oct 21 2016

Components: -Blink Infra>Client>V8 Blink>Bindings

Comment 3 by benhenry@google.com, Nov 23 2016

Cc: machenb...@chromium.org
Components: -Infra>Client>V8
+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.
Cc: -machenb...@chromium.org hablich@chromium.org
Components: -Blink>Bindings Blink>JavaScript
This got a wrong label assigned. No infra.
Cc: rossberg@chromium.org
Labels: -Pri-2 Pri-1
Status: Untriaged (was: Unconfirmed)
Repros in current d8.

CC rossberg to clarify expected behavior.
Status: WontFix (was: Untriaged)
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.

Comment 7 by drol...@yahoo.com, 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