Last Comment Bug 405761 - drawImage should throw INVALID_STATE_ERR on invalid image, not NS_ERROR_NOT_AVAIL
: drawImage should throw INVALID_STATE_ERR on invalid image, not NS_ERROR_NOT_A...
Status: RESOLVED DUPLICATE of bug 1297211
Product: Core
Classification: Components
Component: Canvas: 2D (show other bugs)
: unspecified
: x86 Windows XP
P4 normal with 2 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
: Milan Sreckovic [:milan]
Depends on: 691186
  Show dependency treegraph
Reported: 2007-11-28 01:38 PST by Carsten Book [:Tomcat]
Modified: 2016-09-08 11:35 PDT (History)
9 users (show)
zackw: needinfo? (cabanier)
vladimir: blocking1.9-
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

very simple test case (388 bytes, text/html)
2011-07-28 11:27 PDT, Zack Weinberg (:zwol)
no flags Details

Description User image Carsten Book [:Tomcat] 2007-11-28 01:38:29 PST
Steps to reproduce:

Open the testcase from Bug 391028 and check the error console:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: :: anonymous :: line 9"  data: no]

reproduced on trunk and 1.8 branch
Comment 1 User image Vladimir Vukicevic [:vlad] [:vladv] 2007-11-28 12:46:02 PST
The testcase is supposed to do that; the png image isn't valid.  The spec says drawImage should throw INVALID_STATE_ERR however.
Comment 2 User image Zack Weinberg (:zwol) 2011-07-28 11:27:09 PDT
Created attachment 549180 [details]
very simple test case

It's my impression from that we should never produce NS_ERROR_NOT_AVAILABLE from drawImage; the only licensed failure modes are INVALID_STATE_ERR, TYPE_MISMATCH_ERR, INDEX_SIZE_ERR, and silently doing nothing.  The test case I'm attaching uses an uninitialized Image object (I presume this is the same as an HTMLImageElement under the hood).  I'm not sure what the *correct* behavior for this test case is; I'm guessing either INVALID_STATE_ERR or silent nop.  However, looking at I see several places where we return NS_ERROR_NOT_AVAILABLE inappropriately; they should all be audited and corrected (and the analogous code in the Azure reimplementation too).
Comment 3 User image joris 2012-11-26 06:31:11 PST
I can reproduce this problem with Firefox 16.0.2 on Mac OS X 10.8.2.
Comment 4 User image Rik Cabanier 2014-04-29 19:48:45 PDT

*** This bug has been marked as a duplicate of bug 1003380 ***
Comment 5 User image Zack Weinberg (:zwol) 2016-06-19 07:01:39 PDT
The fixes for bug 1003380 do not appear to have fixed this bug; if you load the test case attached here, you will see that it still generates NS_ERROR_NOT_AVAILABLE.  Again, as I understand the spec, NS_ERROR_NOT_AVAILABLE should *never* be generated by this API.

(I observe this with 45.2.0ESR/Linux.)
Comment 6 User image Oriol 2016-09-08 11:35:02 PDT
Fixed in bug 1297211. I didn't see this bug when I reported that one.

*** This bug has been marked as a duplicate of bug 1297211 ***

Note You need to log in before you can comment on or make changes to this bug.