title: Is it okay to call canvas.drawWindow() from the "onload" handler?
body: <p>The note at the bottom of <a href="https://developer.mozilla.org/en/Drawing_Graphics_with_Canvas" rel="nofollow noreferrer">this Mozilla wiki page</a> 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 <a href="https://developer.mozilla.org/en/Gecko-Specific_DOM_Events#MozAfterPaint" rel="nofollow noreferrer">MozAfterPaint</a> 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 <em>did</em> 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 <em>not</em> to use the "load" event, and if so what can I do instead that will be compatible with older versions of Firefox?</p>
  
  <p>EDIT: This is how my code works. In the <code>init()</code> function of my extension, I call <code>gBrowser.addEventListener("load", MyExtension.onPageLoad, true);</code> Then <code>MyExtension.onPageLoad</code> is essentially:</p>
  
  <pre><code>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
  },
  </code></pre>