Closed
Bug 980945
Opened 10 years ago
Closed 8 years ago
Typed array constructors should not work without "new" per spec
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla44
Tracking | Status | |
---|---|---|
firefox44 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: evilpie)
References
Details
(Keywords: dev-doc-complete, site-compat, Whiteboard: [DocArea=JS])
Attachments
(1 file)
14.95 KB,
patch
|
efaust
:
review+
|
Details | Diff | Splinter Review |
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);
Updated•10 years ago
|
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
Comment 2•10 years ago
|
||
(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.
![]() |
Reporter | |
Comment 3•10 years ago
|
||
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.
Comment 4•10 years ago
|
||
ah, the product/component of bug 980962 threw me off. ok, removing dependance and renaming 980989 to our "sync up trees" bug..
Updated•10 years ago
|
Keywords: site-compat
Assignee | ||
Comment 5•8 years ago
|
||
Chrome already requires `new`. So maybe we can do this now?
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → evilpies
Assignee | ||
Comment 6•8 years ago
|
||
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 7•8 years ago
|
||
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+
Comment 8•8 years ago
|
||
Added the site compatibility doc: https://www.fxsitecompat.com/en-US/docs/2015/calling-typed-array-constructors-without-new-will-throw/
Comment 11•8 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/31561a5ce4de https://hg.mozilla.org/mozilla-central/rev/f7e8784f32b9
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox44:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
Comment 12•8 years ago
|
||
Updated following documents: https://developer.mozilla.org/en-US/Firefox/Releases/44 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
You need to log in
before you can comment on or make changes to this bug.
Description
•