title: Uncaught TypeError: Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob'
body: <p>I wrote a function to read HTML from a file and set the innerHTML of a certain div to equal the HTML inside the file, as a kind of save/load system. This used to work fine, however after a browser update I am getting the error seen in the title.</p>
  <p>HTML:</p>
  <pre><code>&lt;div id=&quot;target&quot;&gt;
      &lt;button onclick=&quot;saveDiv()&quot;&gt;Save&lt;/button&gt;
      &lt;button onclick=&quot;loadDiv()&quot;&gt;Load&lt;/button&gt;
      &lt;input id=&quot;file&quot; type=&quot;file&quot; style=&quot;hidden&quot;&gt;
      &lt;input&gt;
  &lt;/div&gt;
  </code></pre>
  <p>JS:</p>
  <pre><code>const div = document.getElementById('target')
  function saveDiv() {
      var divContent = div.innerHTML.toString();
      var ran = (Math.random() + 1).toString(36).substr(2, 8)
      var fileName = `${ran}.txt`;
      download(fileName, divContent);
  }
  function download(name, content) {
      var e = document.createElement('a');
      e.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(content));
      e.setAttribute('download', name);
      e.style.display = 'none';
      document.body.appendChild(e);
      e.click();
      document.body.removeChild(e);
  }
  function loadActors() {
      document.getElementById('file').click();
  
      var file = document.getElementById('file').files[0];
      var r = new FileReader();
  
      r.onload = (function(reader) {
          return function() {
              var contents = reader.result;
              div.innerHTML = contents;
          }
      })(r);
  
      r.readAsText(file);
  }
  </code></pre>
  <p>I think what may be happening is that the FileReader is trying to read the file before the user has selected it, but I'm not exactly sure. Anyone know what may be happening here?</p>
  <p>Edit: Seems that if I select the file after the error then click the load button again it runs fine. How would I make it only run after the user has selected the file?</p>