diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index ae9ac7ab9165..83a101cdaf9e 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -3362,7 +3362,9 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1, float a6, float a7, float a8, PRUint8 optional_argc) { - NS_ENSURE_ARG(imgElt); + if (!imgElt) { + return NS_ERROR_DOM_TYPE_MISMATCH_ERR; + } double sx,sy,sw,sh; double dx,dy,dw,dh; diff --git a/content/canvas/test/test_canvas.html b/content/canvas/test/test_canvas.html index 91b4e4ce0baa..b2ba6ea318de 100644 --- a/content/canvas/test/test_canvas.html +++ b/content/canvas/test/test_canvas.html @@ -3497,7 +3497,7 @@ var ctx = canvas.getContext('2d'); var _thrown = undefined; try { ctx.drawImage(null, 0, 0); -} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR"); +} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR"); } @@ -3669,7 +3669,7 @@ var ctx = canvas.getContext('2d'); var _thrown = undefined; try { ctx.drawImage(undefined, 0, 0); -} catch (e) { _thrown = e }; ok(_thrown && _thrown.result == Components.results.NS_ERROR_INVALID_ARG, "should throw NS_ERROR_INVALID_ARG"); +} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR"); var _thrown = undefined; try { ctx.drawImage(0, 0, 0); } catch (e) { _thrown = e }; ok(_thrown && _thrown.result == Components.results.NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL, "should throw NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL");