Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 94a1cd4ef3a758acbc871df5501a1ed1563bef18
https://github.com/WebKit/WebKit/commit/94a1cd4ef3a758acbc871df5501a1ed1563bef18
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-11 (Fri, 11 Sep 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear-read-only-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear-read-only.html
A
LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear.html
M LayoutTests/platform/glib/TestExpectations
M LayoutTests/platform/ios/TestExpectations
M Source/WebCore/dom/DataTransferItemList.cpp
Log Message:
-----------
DataTransferItemList.clear() ignores the drag data store mode
https://bugs.webkit.org/show_bug.cgi?id=323928
rdar://187160061
Reviewed by Chris Dumez.
https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-clear
says:
The clear() method, if the DataTransferItemList object is in the read/write
mode, must remove all the items from the drag data store. Otherwise, it must
do nothing.
WebKit performed the removal unconditionally. add() and remove() in the same
class
already implement their own mode checks to the letter -- add() returns null and
remove() throws an InvalidStateError -- so clear() was the one mutating method
missing its guard.
The store is in the protected mode during dragenter/dragover/dragleave/dragend
and
in the read-only mode during drop, and in each of those cases the DataTransfer
is
backed by the real drag pasteboard rather than a StaticPasteboard. Calling
items.clear() from such a handler therefore reached Pasteboard::clear(), which
on
macOS is setTypes({}) on the live NSPasteboardNameDrag, letting a page destroy
the
drag payload mid-drag; dropped items.length to zero on a store it was only
allowed
to read; and, for a file-backed item, tripped ASSERT(canWriteData()) in
DataTransfer::updateFileList().
Add the missing canWriteData() guard, matching Blink and Gecko, which both
already
early-return here. Uses that are genuinely read/write -- a DataTransfer from the
constructor, or the one exposed during dragstart -- are unaffected, which the
first
test below pins down.
As drive-by, also drop get().
Tests:
imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear-read-only.html
imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear.html
*
LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear-read-only-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear-read-only.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransferitemlist-clear.html:
Added.
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/dom/DataTransferItemList.cpp:
(WebCore::DataTransferItemList::clear):
Canonical link: https://commits.webkit.org/320919@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications