[Webkit-unassigned] [Bug 156529] New: document.execCommand("copy") only triggers if there is a selection.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Apr 12 18:56:09 PDT 2016


            Bug ID: 156529
           Summary: document.execCommand("copy") only triggers if there is
                    a selection.
    Classification: Unclassified
           Product: WebKit
           Version: Safari Technology Preview
          Hardware: Macintosh
                OS: OS X 10.11
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: HTML Editing
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: lgarron at chromium.org

Safari 9.1.1 
OSX 10.11.4

1. Visit https://permission.site
2. Click on "Copy"

The text "This text was copied from the permission.site clipboard example." is placed on the clipboard.

No change in the clipboard.

However, if you select (any) text on the page before step 2, then step 2 will result in the expected behaviour.

It appears that document.execCommand("copy") does not fire a copy event if there is no selection on the current page.
Thus, the following idiom does not work as expected if there is no selection at the time you copy:

      document.addEventListener("copy", function(e){
            e.clipboardData.setData("text/plain", "test");

      var copyButton = document.createElement("button");

      copyButton.addEventListener("click", function() {

(Firefox, Chrome, Opera, and IE/Edge all trigger the copy event even when there is no selection.)

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160413/a5eba25c/attachment.html>

More information about the webkit-unassigned mailing list