<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>263724</bug_id>
          
          <creation_ts>2023-10-26 08:38:04 -0700</creation_ts>
          <short_desc>document.execCommand(&quot;paste&quot;) has a different behavior in browsers</short_desc>
          <delta_ts>2023-10-26 09:18:09 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>HTML Editing</component>
          <version>Safari 17</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=263590</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>263725</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Karl Dubost">karlcow</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annevk</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1987739</commentid>
    <comment_count>0</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-26 08:38:04 -0700</bug_when>
    <thetext>In Bug 263590, a Quirk has been created to handle a double paste issue with the Tableau application.

Some background for document.queryCommandSupported(&quot;paste&quot;)
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)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1987740</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-10-26 08:38:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/117535610&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1987753</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-26 09:18:09 -0700</bug_when>
    <thetext>In Bug 263590 where the Quirk was created for Tableau app, see the commit message from Wenson:

==========
In Tableau&apos;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 &quot;Paste&quot; on this item. This is because Tableau&apos;s script does something akin to the following:

```
textField.addEventListener(&quot;keydown&quot;, event =&gt; {
    if (event.key === &quot;v&quot; &amp;&amp; event.metaKey)
        document.execCommand(&quot;Paste&quot;);
});
```

... which triggers a programmatic paste upon `keydown`, without preventing default. This means that if the programmatic DOM paste is accepted, we&apos;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&apos;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</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>