overwrite in paste event

by dandclark_msft

HTML

<div>Steps to observe the issue:</div>
<ol>
  <li>Copy some text on this page</li>
  <li>Initiate a paste into the text box</li>
  <li>While the paste event handler is spinning, copy some text from outside of the page</li>
  <li>Wait for paste initiated in step 2 to finish</li>
</ol>
<div><b>Expected:</b> The text copied in step 1 is pasted into the text box</div>
<div><b>Actual:</b> The text copied in step 3 is pasted into the text box</div>
<br>
<label>Paste here: <input id="target"></label>
<script>
document.querySelector("#target").addEventListener("paste", (e) => {
  const end = performance.now() + 4500;
  while (performance.now() < end) {}
    console.log("overwrote clipboard");
  });
</script>