Closed
Bug 1297211
Opened 5 years ago
Closed 5 years ago
CanvasRenderingContext2D.drawImage can throw 0x80040111 (NS_ERROR_NOT_AVAILABLE)
Categories
(Core :: Canvas: 2D, defect)
Core
Canvas: 2D
Tracking
()
RESOLVED
FIXED
mozilla51
Tracking | Status | |
---|---|---|
firefox51 | --- | fixed |
People
(Reporter: Oriol, Assigned: lsalzman)
References
(Depends on 1 open bug)
Details
Attachments
(1 file)
3.09 KB,
patch
|
mchang
:
review+
|
Details | Diff | Splinter Review |
Run this code in the console: document.createElement("canvas").getContext("2d") .drawImage(new Image(), 0, 0, 0, 0); Result: [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: debugger eval code :: <TOP_LEVEL> :: line 1" data: no] I think that [checking the usability of the image argument][1] should return "bad" because the intrinsic width and height of the image are 0. And then [drawImage][2] should abort, but without throwing. Chrome and Edge don't throw. [1]: https://html.spec.whatwg.org/multipage/scripting.html#check-the-usability-of-the-image-argument [2]: https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage
Comment 1•5 years ago
|
||
Can you submit a webplatform test to https://github.com/w3c/web-platform-tests? That will make sure everyone has the same behaviour.
Flags: needinfo?(oriol-bugzilla)
Reporter | ||
Comment 2•5 years ago
|
||
The test already exists: https://github.com/w3c/web-platform-tests/blob/master/2dcontext/drawing-images-to-the-canvas/2d.drawImage.incomplete.nosrc.html However, Firefox expects it to fail: https://dxr.mozilla.org/mozilla-central/rev/b7f7ae14590aced450bb0b0469dfb38edd2c0ace/testing/web-platform/meta/2dcontext/drawing-images-to-the-canvas/2d.drawImage.incomplete.nosrc.html.ini
Flags: needinfo?(oriol-bugzilla)
Comment 3•5 years ago
|
||
Ok, great. Lee do you think you'd have time to look at this while I'm away next week? It should be pretty easy to fix.
Assignee | ||
Comment 4•5 years ago
|
||
This marks an image element with an empty source as available by letting its size be accessed so that canvas drawImage won't throw an error anymore, as the spec mandates. This also fixes our results on several web platform tests that check for this behavior.
Updated•5 years ago
|
Attachment #8787715 -
Flags: review?(mchang) → review+
Pushed by lsalzman@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/52eed50488c2 treat an empty src as available in image requests for canvas2d drawImage. r=mchang
Comment 6•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/52eed50488c2
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
status-firefox51:
--- → fixed
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in
before you can comment on or make changes to this bug.
Description
•