From 07363bf919c25330f1541485fa70d5157f63bbfa Mon Sep 17 00:00:00 2001 From: Shweta Bindal Date: Tue, 9 Jun 2026 00:26:40 -0700 Subject: [PATCH] Change ClipboardItem::getType() rejection to InvalidStateError ClipboardItem.getType() should reject with InvalidStateError when the clipboard data has changed between read() and getType(), or when a null blob is returned from the clipboard reader. Chromium was using DataError at these rejection sites in clipboard_item.cc. This changes them to InvalidStateError for spec compliance. Bug: 519633341 Change-Id: Idd2458219b4d2b1b706b644e3f40ca84c1254057 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7902351 Commit-Queue: Shweta Bindal Reviewed-by: Rohan Raja Cr-Commit-Position: refs/heads/main@{#1643732} --- ...ync-clipboard-cached-getType-reject.tentative.https.html | 6 +++--- ...sync-clipboard-stale-getType-reject.tentative.https.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clipboard-apis/async-clipboard-cached-getType-reject.tentative.https.html b/clipboard-apis/async-clipboard-cached-getType-reject.tentative.https.html index ca2d5e31ccf79c..32e3fb0990c222 100644 --- a/clipboard-apis/async-clipboard-cached-getType-reject.tentative.https.html +++ b/clipboard-apis/async-clipboard-cached-getType-reject.tentative.https.html @@ -43,8 +43,8 @@ await waitForUserActivation(); await navigator.clipboard.write([newItem]); - // Step 5: getType() on the now-stale item should reject with DataError, + // Step 5: getType() on the now-stale item should reject with InvalidStateError, // even though the data was previously read and cached in step 3. - await promise_rejects_dom(t, 'DataError', item.getType('text/plain')); -}, 'getType() rejects with DataError on cached ClipboardItem after clipboard.write()'); + await promise_rejects_dom(t, 'InvalidStateError', item.getType('text/plain')); +}, 'getType() rejects with InvalidStateError on cached ClipboardItem after clipboard.write()'); diff --git a/clipboard-apis/async-clipboard-stale-getType-reject.tentative.https.html b/clipboard-apis/async-clipboard-stale-getType-reject.tentative.https.html index 386b201297b2af..f07de00827943d 100644 --- a/clipboard-apis/async-clipboard-stale-getType-reject.tentative.https.html +++ b/clipboard-apis/async-clipboard-stale-getType-reject.tentative.https.html @@ -41,7 +41,7 @@ await waitForUserActivation(); await navigator.clipboard.write([newItem]); - // Step 4: getType() on the stale item should reject with DataError. - await promise_rejects_dom(t, 'DataError', staleItem.getType('text/plain')); -}, 'getType() rejects with DataError on stale ClipboardItem after clipboard.write()'); + // Step 4: getType() on the stale item should reject with InvalidStateError. + await promise_rejects_dom(t, 'InvalidStateError', staleItem.getType('text/plain')); +}, 'getType() rejects with InvalidStateError on stale ClipboardItem after clipboard.write()');