The note at the bottom of this Mozilla wiki page currently says: "Using canvas.drawWindow() while handling a document's onload event doesn't work. In Firefox 3.5 or later, you can do this in a handler for the MozAfterPaint event to successfully draw HTML content into a canvas on page load." Which is fine, except that I tried it in Firefox 3.6.6 and it did work, leading me to believe that perhaps it used to not work, due to some bug which has since been fixed. I'd rather not use MozAfterPaint since it won't work in versions earlier than 3.5. Is there an important reason not to use the "load" event, and if so what can I do instead that will be compatible with older versions of Firefox?
EDIT: This is how my code works. In the init()
function of my extension, I call gBrowser.addEventListener("load", MyExtension.onPageLoad, true);
Then MyExtension.onPageLoad
is essentially:
onPageLoad : function(e) {
var win = e.originalTarget.defaultView;
// create an html:canvas, adjust its size, etc. following the example of the "TabPreview" extension
var ctx = canvas.getContext("2d");
ctx.drawWindow(win, 0, 0, w, h, "rgb(255, 255, 255");
// add the canvas to the DOM
},