Closed Bug 1883261 Opened 7 months ago Closed 6 months ago

Unclear error thrown when ImageData constructor is called with invalid settings

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 123
defect

Tracking

()

RESOLVED DUPLICATE of bug 1770258

People

(Reporter: github, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0

Steps to reproduce:

Construct an ImageData object like so:

new ImageData(500, 500, {})

new ImageData(500, 500, {colorSpace: undefined})

Actual results:

The following error is thrown:

Uncaught TypeError: ImageData constructor: Argument 1 is not an object.

Expected results:

Either the error should describe the problem more accurately (something like 'expected valid colorSpace/settings object in Argument 3').

Or the empty setting should just be ignored like Chromium does.

The Bugbug bot thinks this bug should belong to the 'Core::JavaScript Engine' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Component: JavaScript Engine → Graphics: Canvas2D
Blocks: gfx-triage
Severity: -- → S3
Flags: needinfo?(lsalzman)

This looks like the error is actually accurate, in that it is dispatching to ImageData::Constructor(Uint8ClampedArray data, uint32_t width, uint32_t height), and it is complaining that 500 is in fact not the object it expected. So this is happening way higher up in the type checker for webidl.

The constructor that would even accept a settings dictionary doesn't exist at all. That in itself is probably fine, just that the problem as reported here is that it's not clear from the error message that the wrong constructor is being dispatched and what the expected argument type would be. Not really sure whether this is a DOM component issue or a JavaScript component issue?

Flags: needinfo?(lsalzman) → needinfo?(peterv)

(In reply to Lee Salzman [:lsalzman] from comment #2)

The constructor that would even accept a settings dictionary doesn't exist at all. That in itself is probably fine

Why is it fine? It is in the spec: https://html.spec.whatwg.org/multipage/canvas.html#imagedata

The overload resolution is working correctly given our definition of the ImageData interface.

Flags: needinfo?(peterv)
Status: UNCONFIRMED → RESOLVED
Closed: 6 months ago
Duplicate of bug: 1770258
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.