Last Comment Bug 742202 - IsArrayLike needs to check for various typed array stuff
: IsArrayLike needs to check for various typed array stuff
Product: Core
Classification: Components
Component: DOM (show other bugs)
: Trunk
: x86 Mac OS X
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
Depends on: 748267
Blocks: ParisBindings
  Show dependency treegraph
Reported: 2012-04-03 22:09 PDT by Boris Zbarsky [:bz]
Modified: 2012-06-13 08:46 PDT (History)
7 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description Boris Zbarsky [:bz] 2012-04-03 22:09:30 PDT
Basically, any typed-array-thing (ArrayBuffer, ArrayBufferView, any of the typed arrays) that supports indexed access needs to return true from IsArrayLike.
Comment 1 Steve Fink [:sfink] [:s:] 2012-04-04 08:38:45 PDT
I'm not sure I follow. Which of these should return true? (Note that some of these statements will only be true after I land everything in my patch stack.)

 - ArrayBuffer: does not support indexed access.

 - DataView: it is an ArrayBufferView, but it does not support indexed access. You need to use typed getters like getUint8(index) to access the ArrayBuffer data.

 - Float32Array.prototype (or any typedarray.prototype): "supports" indexed access, but is always length zero.

 - A typed array view of a neutered ArrayBuffer: we haven't 100% pinned down the semantics here. Either it acts as if it is length zero, or it throws an exception if you try to access it.

If the answer is "none of the above", then I think I know what you should use, but I'll wait until it makes it through review first.
Comment 2 Boris Zbarsky [:bz] 2012-04-04 08:49:43 PDT
Per WebIDL, I need to return true here for instances of interfaces that have indexed properties.

Given your description in comment 1, I definitely want to return false for ArrayBuffer DataView, and the typed array protos.

Not sure about typed arrays views of a neutered ArrayBuffer.  Cameron?

The fact that our typed array impl is only loosely related to the typed array spec is a bit annoying.  :(
Comment 3 Cameron McCormack (:heycam) 2012-04-05 17:39:32 PDT
I would say it's simpler to return true for typed array views always, without looking to see if the ArrayBuffer is neutered.
Comment 4 Boris Zbarsky [:bz] 2012-06-12 23:15:47 PDT
Bug 748267 just made us use JS_IsTypedArrayObject here.  sfink, I assume that tests false for dataviews?
Comment 5 Steve Fink [:sfink] [:s:] 2012-06-13 07:58:10 PDT
Yes, that is correct.
Comment 6 Boris Zbarsky [:bz] 2012-06-13 08:46:23 PDT
OK, then this is fixed.

Note You need to log in before you can comment on or make changes to this bug.