Using canvas drawImage in chrome extension content script
google-chrome-extension
Solution
This is a bug, you should report it. Some more testing reveals that in Chrome 28.0.1498.0, the `Image` constructor does not create a valid `HTMLImageElement` instance (as seen in the screenshot below). This code is run in the context of a Content script. The same code works fine on regular pages and in the extension's process (background page).
To work around the problem, use `document.createElement('img')` instead of `new Image()`.
And don't forget to report the bug at https://code.google.com/p/chromium/issues/list.
Problem
I'm trying to use `drawImage` on Canvas Context in injected content script from my Chrome Extension. ``` testCanvas = document.createElement('canvas'); testContext = testCanvas.getContext('2d'); var image = new Image(); testContext.drawImage(image, 0, 0); ``` In Chrome 26 it works ok, but in dev channel (Chrome 28) this seams broken as I got this message: ``` Uncaught TypeError: Type error ``` When I move same script directly into background page, it works without any problem. I think this can be related to some security related change but I failed to find any relevant information.