New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 754965 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

execCommand('copy') intermittently fails on programmatic selection without focus

Reported by d...@moqups.com, Aug 12 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36

Steps to reproduce the problem:
This is a simplified test case based on the article:
https://developers.google.com/web/updates/2015/04/cut-and-copy-commands

and refers to a previous comment I made on #722925:
https://bugs.chromium.org/p/chromium/issues/detail?id=722925#c20

1. open the attached test case
2. select "Lorem" and press Cmd + C to copy it to the clipboard, confirm by pasting into textarea below
3. Press the "copy" button to try to copy the email address to the clipboard
4. Pasting into the textarea

What is the expected behavior?
Pasting should reveal "matt@example.co.uk"

What went wrong?
Pasting reveals "Lorem" in (most) cases. 

Did this work before? Yes Chrome 59

Does this work in other browsers? Yes

Chrome version: 60.0.3112.90  Channel: stable
OS Version: OS X 10.12.6
Flash Version: 

Note that pressing "Copy" twice will indeed copy the email address to the clipboard.
 
jsbin.cuyuwakuvo.1.html
1.4 KB View Download

Comment 1 by woxxom@gmail.com, Aug 12 2017

Bisect info: 464694 (good) - 464699 (bad)
https://chromium.googlesource.com/chromium/src/+log/587d760b..6ea2f510?pretty=fuller
Suspecting r464698 "Do not send redundant selectionchange-events (decouple focus)"
Landed in 60.0.3072.0
Cc: mmanchala@chromium.org
Labels: hasbisect-per-revision Needs-Triage-M60 OS-Linux OS-Windows
Owner: hu...@opera.com
Status: Assigned (was: Unconfirmed)
Able to reproduce the issue on Windows-7,Windows-10,Mac-10.12.4 and Linux Ubuntu-14.04 using chrome stable version # 60.0.3112.90  and canary 62.0.3185.0 with the steps mentioned in comment#0

As per comment #1
Good Build Revision: 464694 
Bad Build Revision : 464699

Using the per-revision bisect providing Changelog:

You are probably looking for a change made after 464697 (known good), but no later than 464698 (first known bad).
CHANGE-LOG URL:
---------------
https://chromium.googlesource.com/chromium/src/+log/188c1056bbfb9c98eca691c12f5641d4204f6066..0f65d25a4097959d977dbb1077717323438240a6


Suspecting https://codereview.chromium.org/2616623002 from changelog

@hugoh: Could you please take a look into this issue and reassign if this issue is not related to your change.

Thanks..!!

Labels: M-62

Comment 4 by hu...@opera.com, Aug 14 2017

Cc: yosin@chromium.org hu...@opera.com aelias@chromium.org
Owner: xiaoche...@chromium.org
Assigning over to xiaochengh@ because he knows more about execCommand('copy').
Status: WontFix (was: Assigned)
The API is working as intended. The test case is not, because the button's event handler doesn't always select the link text:

// Select the email link anchor text  
var emailLink = document.querySelector('.js-emaillink');  
var range = document.createRange();  
range.selectNode(emailLink);  
window.getSelection().addRange(range);

Selection.addRange() doesn't do anything if the document already has a selection (*). To correct the test case, call Selection.removeAllRanges() before calling Selection.addRange().

(*) Spec of Selection.addRange(). http://w3c.github.io/selection-api/#dom-selection-addrange. "... If rangeCount is not 0, abort these steps. ..."

Comment 6 by d...@moqups.com, Aug 14 2017

Thank you for the clarification, and for reviewing my submission. You are correct, I had missed this aspect.

Comment 7 by hu...@opera.com, Aug 15 2017

If you wanna upstream your test, I think you can send it to https://github.com/w3c/web-platform-tests/tree/master/selection . We always need better test coverage :)

Sign in to add a comment