title: Submitting a form with submit() using Promise
body: <p>I am trying to write something that could do the following in that particular order: (1) submit a form (2) print "Print me." (3) wait 3 seconds (4) print "Print me too."</p>
  
  <p><strong>Why doesn't my code accomplish this?</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function sleep(ms) { return new Promise(resolve =&gt; setTimeout(resolve, ms));}
  function submitForm() { return new Promise(resolve =&gt; document.getElementById('form').submit());}
  
  async function test() {
      wait submitForm();
      console.log("Print me.")
      wait sleep(3000);
      console.log("Print me too.")
  };
  
  test();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form id="form" type="hidden"&gt;
      &lt;input value="" id="id" type="text"&gt;
      &lt;input value="Submit" type="submit"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>