Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 02741dfccee549e335bc3d542a0f5f851f9a153c
https://github.com/WebKit/WebKit/commit/02741dfccee549e335bc3d542a0f5f851f9a153c
Author: Karl Dubost <[email protected]>
Date: 2026-06-28 (Sun, 28 Jun 2026)
Changed paths:
A
LayoutTests/editing/async-clipboard/clipboard-read-text-resolves-after-input-event-expected.txt
A
LayoutTests/editing/async-clipboard/clipboard-read-text-resolves-after-input-event.html
M Source/WebCore/Modules/async-clipboard/Clipboard.cpp
M Source/WebCore/dom/TaskSource.h
Log Message:
-----------
Async Clipboard API should request paste access asynchronously
https://bugs.webkit.org/show_bug.cgi?id=223597
rdar://75969974
Reviewed by Wenson Hsieh.
The Clipboard API spec requires readText() to settle on a queued task,
not on the calling task.
Clipboard.readText() — step 3
https://w3c.github.io/clipboard-apis/#dom-clipboard-readtext
3. Run the following steps in parallel:
1. Let r be the result of running [check clipboard read permission].
2. If r is false, then queue a global task on the clipboard task
source ... reject p with "NotAllowedError" DOMException ...
3. Let data be a copy of the system clipboard data.
4. Queue a global task on the clipboard task source ... resolve p
with textString ...
Clipboard.read() has the same shape (#dom-clipboard-read).
WebKit walked the pasteboard read synchronously and called
promise->resolve() on the same call stack as the JS await. The promise
settled as a microtask of the calling task. Firefox and Chrome queue a
real task and settle later.
The user-visible symptom is the webcompat bug with a six-box OTP
component. It calls navigator.clipboard.readText() inside a paste handler
that does not preventDefault. Two writes race. The microtask resolve
runs first and distributes "123456" to all six boxes. The native paste's
input event task then runs and a single-box state write clears boxes 2-6.
Firefox and Chrome show the input event first, so distribution wins
last and all six boxes stay filled.
Test:
editing/async-clipboard/clipboard-read-text-resolves-after-input-event.html
*
LayoutTests/editing/async-clipboard/clipboard-read-text-resolves-after-input-event-expected.txt:
Added.
*
LayoutTests/editing/async-clipboard/clipboard-read-text-resolves-after-input-event.html:
Added.
* Source/WebCore/Modules/async-clipboard/Clipboard.cpp:
(WebCore::Clipboard::readText):
(WebCore::Clipboard::read):
* Source/WebCore/dom/TaskSource.h:
Canonical link: https://commits.webkit.org/315997@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications