title: canvas drawImage fails
body: <p>I'm fairly new to Canvas so please excuse if this is to simple. I want to resize images prior to upload if the browser supports this using canvas. However, this code</p>
  
  <pre><code>var img = document.createElement("img");
  var reader = new FileReader();  
      reader.onload = function(e) {img.src = e.target.result};
  var files = event.target.files;
      reader.readAsDataURL(files[0]);
  var canvas = document.createElement('canvas');
      canvas.width = 100;
      canvas.height = 100;
  var ctx = canvas.getContext("2d");
      ctx.drawImage(img, 0, 0);
  </code></pre>
  
  <p>fails with </p>
  
  <blockquote>
    <p>NS_ERROR_NOT_AVAILABLE: Component is not available
    slice.call( docElem.childNodes, 0 )[0].nodeType;</p>
  </blockquote>
  
  <p>in my test-browser Firefox. What could be wrong?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Very strange: If I add a "alert(canvas);" as the 3rd last line (I do that sometimes for debugging, I know I could and should use console.log), the error does not appear, however, I still do not see anything from my image...</p>