title: Javascript Promise not waiting to resolve before next Then()
body: <p>Anyone know why this does not run synchronically? The last promise seems to resolve before the first</p>
  
  <pre><code>...
  
  var promise = Promise.resolve();
  promise.then( () =&gt; {
      return new Promise((resolve, reject) =&gt; {
          var file1 = fileChooserCSV.files[0];
          var reader1 = new FileReader();
          reader1.onload = function(){
              var csv = reader1.result;
              csvJson = csvJSON(csv);
              resolve();
          };
          reader1.readAsText(file1);
      });
  });
  
  
  
  promise.then( () =&gt; {
      return new Promise((resolve, reject) =&gt; {
          var file2 = fileChooserConfig.files[0];
          var reader2 = new FileReader();
          reader2.onload = function(){
              var config = reader2.result;
              configJson = JSON.parse(config);
              resolve();
          };
          reader2.readAsText(file2);
      });
  });
  
  
  promise.then( () =&gt; {
      return new Promise((resolve, reject) =&gt; {
          console.log('end');
          resolve();
      });
  });
  </code></pre>
  
  <p>The reader onload methods never seem to execute though they really should (there is data passed to them), and did so before they were moved to the promise. As the onload doesn't run the resolve() never fires ether to go onto the next then(), but the last then() does execute...</p>
  
  <p>This code runs in a chrome extension popup if that makes any difference?</p>
  
  <p>Many thanks!</p>
  
  <p>UPDATE..</p>
  
  <p>Restructuring it in a classic nested way works fine</p>
  
  <pre><code>var file1 = fileChooserCSV.files[0];
      var reader1 = new FileReader();
      reader1.onload = function(){
          var csv = reader1.result;
          csvJson = csvJSON(csv);
  
          var file2 = fileChooserConfig.files[0];
          var reader2 = new FileReader();
          reader2.onload = function(){
              var config = reader2.result;
              configJson = JSON.parse(config);
              console.log('end');
          };
          reader2.readAsText(file2);
      };
      reader1.readAsText(file1);
  </code></pre>