<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Promise API does not fully process microtask checkpoint: spec violation"
   href="https://bugs.webkit.org/show_bug.cgi?id=160857">160857</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Promise API does not fully process microtask checkpoint: spec violation
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>JavaScriptCore
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>a&#64;totic.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=286076" name="attach_286076" title="This file will demonstrate the bug">attachment 286076</a> <a href="attachment.cgi?id=286076&amp;action=edit" title="This file will demonstrate the bug">[details]</a></span>
This file will demonstrate the bug

Promises microtask queue does not fully process microtasks queued while microtask is running.
According to spec, microtask queue should loop until it is empty.

Why is this bug important?
Promises are often used by developers for scheduling. When they are,
developers assume Promise.resolve() means &quot;execute this function right 
after this script returns&quot;. This bug violates this promise.

FF/Edge/Chrome get this right. It'd be great if all browsers worked the same.

Example:

Promise.resolved()
 .then(() =&gt; {
   console.log(&quot;Promise 1&quot;);
   return Promise.resolve();
 })
 .then(() =&gt; {
   console.log(&quot;Promise 2&quot;);
 }
window.setTimeout(function() {
  console.log('timeout');
}, 0);

Might also be related to <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - js/dom/Promise.html is flaky"
   href="show_bug.cgi?id=140043">Bug #140043</a>. I've attached a test case.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>