Closed Bug 1297211 Opened 5 years ago Closed 5 years ago
Rendering Context2D .draw Image can throw 0x80040111 (NS _ERROR _NOT _AVAILABLE)
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] should return "bad" because the intrinsic width and height of the image are 0. And then [drawImage] should abort, but without throwing. Chrome and Edge don't throw. : https://html.spec.whatwg.org/multipage/scripting.html#check-the-usability-of-the-image-argument : https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage
Can you submit a webplatform test to https://github.com/w3c/web-platform-tests? That will make sure everyone has the same behaviour.
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
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.
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.
Assignee: nobody → lsalzman
Status: NEW → ASSIGNED
Attachment #8787715 - Flags: review?(mchang)
Attachment #8787715 - Flags: review?(mchang) → review+
Pushed by email@example.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/52eed50488c2 treat an empty src as available in image requests for canvas2d drawImage. r=mchang
You need to log in before you can comment on or make changes to this bug.