Per current ES6 spec, this expression: Uint8Array() at global scope should throw, because the this object will not be a Uint8Array object. Currently Chrome and Safari do what the spec says. We and IE treat it the same as "new Uint8Array()". We should either fix this or get the spec fixed (e.g. for Array() the spec allows the variant without "new"). Note that there are extension compat problems here, by the way; the Add-On SDK has stuff like: return Uint8Array(TextEncoder(encoding).encode(subject).buffer);
(In reply to Boris Zbarsky [:bz] from comment #0) > Note that there are extension compat problems here, by the way; the Add-On > SDK has stuff like: > > return Uint8Array(TextEncoder(encoding).encode(subject).buffer); this shouldn't be too big of a problem. this issue is: a) localized to one module file (plus a unit test) b) relatively new, "shipped" less then 3 months ago with SDK 1.15 a) in a low-level module, with lesser guarantees for stability (marked 'experimental') c) introduced with SDK 1.15, which (by default) creates addons that use modules built into firefox so in my estimate, fixing one file and uplifting it to firefox should not result in too big compat problems.
Ah, didn't realize this part of the SDK was new. Hopefully none of the addons that include that are using it, then. Note that I plan to fix this tree-wide in bug 980962.
ah, the product/component of bug 980962 threw me off. ok, removing dependance and renaming 980989 to our "sync up trees" bug..
No longer depends on: 980989
OS: Mac OS X → All
Hardware: x86 → All
5 years ago
Chrome already requires `new`. So maybe we can do this now?
Try push https://treeherder.mozilla.org/#/jobs?repo=try&revision=14da7f820040 looks good to me. I hope we can land this without breaking the internet :)
Attachment #8673883 - Flags: review?(efaustbmo)
Comment on attachment 8673883 [details] [diff] [review] Throw when invoking a typed array constructor without new Review of attachment 8673883 [details] [diff] [review]: ----------------------------------------------------------------- Thanks!
Attachment #8673883 - Flags: review?(efaustbmo) → review+
Added the site compatibility doc: https://www.fxsitecompat.com/en-US/docs/2015/calling-typed-array-constructors-without-new-will-throw/
You need to log in before you can comment on or make changes to this bug.