WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
263724
document.execCommand("paste") has a different behavior in browsers
https://bugs.webkit.org/show_bug.cgi?id=263724
Summary
document.execCommand("paste") has a different behavior in browsers
Karl Dubost
Reported
2023-10-26 08:38:04 PDT
In
Bug 263590
, a Quirk has been created to handle a double paste issue with the Tableau application. Some background for document.queryCommandSupported("paste")
https://www.w3.org/2017/09/05-editing-minutes.html#item02
https://bugs.chromium.org/p/chromium/issues/detail?id=757140
https://bugzilla.mozilla.org/show_bug.cgi?id=1161721
The specification is not in a good place.
https://w3c.github.io/editing/docs/execCommand/
Kind of related specs too.
https://w3c.github.io/clipboard-apis/#clipboard-event-paste
and
https://w3c.github.io/input-events/#event-order-when-using-insertfrompaste
According to this test, paste is supported in privileged context in Firefox.
https://github.com/mozilla/gecko-dev/blob/df57c7356a3a2465412b76a403a7b24a46c369a4/dom/tests/mochitest/general/test_bug1161721.html#L22
And probably in Chromium (to find out)
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2023-10-26 08:38:16 PDT
<
rdar://problem/117535610
>
Karl Dubost
Comment 2
2023-10-26 09:18:09 PDT
In
Bug 263590
where the Quirk was created for Tableau app, see the commit message from Wenson: ========== In Tableau's analytics tool, pressing ⌘V to paste in any focused editable areas pastes content twice after showing a Paste menu item, if the user clicks "Paste" on this item. This is because Tableau's script does something akin to the following: ``` textField.addEventListener("keydown", event => { if (event.key === "v" && event.metaKey) document.execCommand("Paste"); }); ``` ... which triggers a programmatic paste upon `keydown`, without preventing default. This means that if the programmatic DOM paste is accepted, we'll end up triggering two paste commands: (1) due to the `execCommand`, and (2) due to the default behavior of ⌘V. While this is ostensibly a website bug, it works fine in other browsers (Firefox, Chrome) because they don't support DOM paste at all, so we just end up silently failing the programmatic paste before performing the real paste. ========== Firefox, and Chrome seems to support paste but they do not expose it to the Web or only under certain circumstances. Firefox
https://searchfox.org/mozilla-central/source/dom/base/Document.cpp#5404-5409
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug