diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index 94bf8d684ae..2c08b623f01 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -1677,6 +1677,9 @@ nsCanvasRenderingContext2D::CreatePattern(nsIDOMHTMLElement *image, const nsAString& repeat, nsIDOMCanvasPattern **_retval) { + if (!image) { + return NS_ERROR_DOM_TYPE_MISMATCH_ERR; + } gfxPattern::GraphicsExtend extend; if (repeat.IsEmpty() || repeat.EqualsLiteral("repeat")) { diff --git a/content/canvas/test/test_canvas.html b/content/canvas/test/test_canvas.html index 63c8436fae2..2ae8604256b 100644 --- a/content/canvas/test/test_canvas.html +++ b/content/canvas/test/test_canvas.html @@ -14768,7 +14768,7 @@ var ctx = canvas.getContext('2d'); var _thrown = undefined; try { ctx.createPattern(null, 'repeat'); -} 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"); } @@ -14806,7 +14806,7 @@ var ctx = canvas.getContext('2d'); var _thrown = undefined; try { ctx.createPattern(undefined, 'repeat'); -} 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"); }