When creating a `new ImageData(0,0)`, the resulting error message is incorrect.
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
People
(Reporter: d, Unassigned)
References
(Blocks 1 open bug)
Details
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0
Steps to reproduce:
In the Web Console, evaluate the following ECMAScript:
new ImageData(0,0)
Actual results:
The expected error stated, "Index or size is negative or greater than the allowed amount".
Expected results:
The error message should not be false.
The index or size is 0, it is not negative. -0 is a separate value, if rather hard to come by in ECMAScript. We are not using it here.
0 is also not greater than the expected amount. If it were, new ImageData(1,1)
would not succeed.
Therefore, the message should read something like Chromium's - "Failed to construct 'ImageData': The source width is zero or not a number." I might suggest "Index or size is less than 1 or greater than the allowed amount".
It is a minor detail but it cost me a few minutes tonight, trying to track down where a negative number was coming from as my numbers were very small.
Updated•2 years ago
|
Comment 1•2 years ago
|
||
By spec that call is supposed to produce an IndexSizeError. The string associated with that error is what this bug is about. The current wording we have seems to come from a commit from 1999, which links to https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html which has
INDEX_SIZE_ERR
If index or size is negative, or greater than the allowed value
So that seems to be where our wording came from.
If you look in a modern spec
https://webidl.spec.whatwg.org/#dom-domexception-index_size_err
It only says "Deprecated. Use RangeError instead." But if we find the commit that deprecated it in the spec
https://github.com/whatwg/webidl/commit/9d039f6e1df193162502737f8f11088c1f377cca
It used to say "The index is not in the allowed range." So we could update our text to say that, I'm unsure how concerned we need to be about webcompact with these (ie someone checking for that specific string).
Chrome seems to send a string along with the error code that is specific to each usage.
Updated•2 years ago
|
Description
•