[w3c/clipboard-apis] Async clipboard read and race conditions. (Issue #180)

In Chromium browsers, the data from the system clipboard is accessed asynchronously from Browser process (that calls the system clipboard APIs). When the browser reads the clipboard data, it will send that to the renderer, which will sanitize (if necessary) the data before sending it to JS. If the contents change between the browser read and the renderer sending to JS (sanitization can take some time), we do NOT notice this and pass this (outdated) clipboard data to JS.
What should be the right behavior here?
Should async clipboard APIs reject the promise if the clipboard data changed between the read call and the data that is returned after the read is executed successfully?
On Windows, we could detect changes to the system clipboard by checking for the [sequence numbers](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclipboardsequencenumber), or is it OK to send data that may not be in the clipboard at the time of read in JS?
@annevk @whsieh @BoCupp-Microsoft 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/180
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/clipboard-apis/issues/180@github.com>

Received on Friday, 24 June 2022 00:15:34 UTC