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

Issue 755459 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 1
Type: Bug-Regression

Blocked on:
issue 795212



Sign in to add a comment

pasting text in online editor even when not in focus

Reported by adam.yza...@gmail.com, Aug 15 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36

Steps to reproduce the problem:
1. go to https://ace.c9.io/build/kitchen-sink.html
2. Select text from inside the editor and press CTRL-C.
3. Press one of the checkboxes on the left
4.**Editor loses focus***
5.Press CTRL-V

What is the expected behavior?
Nothing should happen

What went wrong?
the text is copied from the clipboard to the editor. This Doesn't happen in IE and Firefox.

Did this work before? N/A 

Chrome version: 60.0.3112.90  Channel: n/a
OS Version: 10.0
Flash Version: 

This effects other online editor. ace editor is just an example.
 

Comment 1 by hdodda@chromium.org, Aug 16 2017

Cc: hdodda@chromium.org
Labels: Needs-Feedback
Tested the issue on windows 7 & 10 using chrome M60 #60.0.3112.101 and M62 #62.0.3187.0 and followed the steps mentioned in comment #0.

Observed similar behavior in chrome and firefox browsers.

Attached screencast for reference.

@adam.yzamri-- Could you please check attached screencast and confirm us if we had missed any steps in reproducing the issue and also please help us with the screencast of the expected and actual results for better traiging.

Thanks!
755459.mp4
1.6 MB View Download

Comment 2 by hdodda@chromium.org, Aug 16 2017

Labels: Needs-Triage-M60
chrome-actual result
firefox- expected result.
thx.
couldnt see if you used ctrl-v after checking a checkbox.
chrome.mp4
91.6 KB View Download
firefox.mp4
93.6 KB View Download
Project Member

Comment 4 by sheriffbot@chromium.org, Aug 17 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "hdodda@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: brajkumar@chromium.org yosin@chromium.org
Components: -UI Blink>Editing
Labels: -Type-Bug -Pri-2 hasbisect-per-revision M-63 OS-Linux OS-Mac Pri-1 Type-Bug-Regression
Owner: hu...@opera.com
Status: Assigned (was: Unconfirmed)
Able to reproduce on Mac OS 10.12.6, Ubuntu 14.04 and windows-10 using chrome latest stable #60.0.3112.113

Bisect Information:
-----------------------
Good build: 59.0.3071.132
Bad Build : 60.0.3072.0

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

From the above change log suspecting the same
hugoh@ - Could you please check whether this is caused with respect to your change, if not please help us in assigning it to the right owner.

Comment 6 by hu...@opera.com, Sep 11 2017

Hi Adam! Thanks for your bug report. Do you know of a smaller test case that triggers this?

Comment 7 by hu...@vewd.com, Oct 2 2017

Owner: hu...@vewd.com
adam.yzamri@, do you still see this problem? 
Does it repro in M61?

r472985 should have disabled pasting without focus, which is effective since M61.

Comment 9 by hu...@vewd.com, Oct 30 2017

brajkumar@, could you re-verify this?
Sorry for the late reply. Yes, still able to reproduce this issue on Ubuntu 14.04 using chrome latest stable #62.0.3202.89.

Thanks!

Comment 11 by hu...@vewd.com, Nov 27 2017

Cc: xiaoche...@chromium.org
I see one difference between Chrome and Firefox:
Chrome sends a paste-event to the <textarea> even though it doesn't have focus.

Minimal repro:

<input type="checkbox">
<textarea cols=40 rows=30>text here</textarea>
<p id="log"></p>
<script>
  var count = 0;
  var logPaste = function() {
    var log = document.getElementById("log");
    log.innerHTML = "Textarea got " + ++count + " paste-events!";
  }
  var textArea = document.querySelector("textarea");
  textArea.addEventListener("paste", logPaste);
</script>

1. Focus <textarea>.
2. Focus checkbox.
3. Paste some text with CTRL+V.

Actual: <textarea> gets a paste-event (but no text is pasted).
Expected (?): <textarea> gets no paste-events (and no text is pasted).

Comment 12 by hu...@vewd.com, Nov 30 2017

Status: Started (was: Assigned)
Fix up for review: https://chromium-review.googlesource.com/c/chromium/src/+/799697
Project Member

Comment 13 by bugdroid1@chromium.org, Dec 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/adad191b2de61531d8043a3ad2a4c717a66801e9

commit adad191b2de61531d8043a3ad2a4c717a66801e9
Author: Hugo Holgersson <hugoh@vewd.com>
Date: Wed Dec 13 17:55:56 2017

For readability, refactor some of blink::Editor's methods

This patch does not change any web facing logic.
Only private methods are changed, the public API is untouched.

Renamed methods:
  DispatchCPPEvent -> DispatchClipboardEvent
  TryDHTMLCopy     -> DispatchCopyEvent
  TryDHTMLCut      -> DispatchCutEvent
  TryDHTMLPaste    -> DispatchPasteEvent

These methods now return false upon preventDefault() from JavaScript.
Before this change, only the first method followed this convention.

Bug:  755459 
Change-Id: I2b9dd77b0c0cd6a2ad29136e1ec2f9dec7d37622
Reviewed-on: https://chromium-review.googlesource.com/810806
Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Hugo Holgersson <hugoh@vewd.com>
Cr-Commit-Position: refs/heads/master@{#523810}
[modify] https://crrev.com/adad191b2de61531d8043a3ad2a4c717a66801e9/third_party/WebKit/Source/core/editing/Editor.cpp
[modify] https://crrev.com/adad191b2de61531d8043a3ad2a4c717a66801e9/third_party/WebKit/Source/core/editing/Editor.h

Labels: TE-Verified-M65 TE-Verified-65.0.3294.0
Verified this issue on Windows-10, Ubuntu 14.04 and Mac OS 10.12.6 using chrome latest dev #65.0.3294.0 by following steps mentioned in the original comment. Observed the editor loses the focus and unable to paste the text in the editor as expected. Hence adding TE-Verified label for M65.

Thanks!

Comment 15 by hu...@vewd.com, Dec 14 2017

Labels: -TE-Verified-M65 -TE-Verified-65.0.3294.0
This is not yet fixed. The fix (at #12) has not yet landed. Maybe you couldn't reproduce it anymore because https://ace.c9.io/build/kitchen-sink.html changed in some way. When I try that page on ToT, I don't manage to paste at all, even when the editor has focus. Please try the stable reproduction steps from #11.

Comment 16 Deleted

Comment 17 by hu...@vewd.com, Dec 15 2017

Re #14, #15. Ace Editor's copy/paste still works in stable Chrome so the page itself has not regressed. The regression is on master, see  crbug.com/795212 .

Comment 18 by hu...@vewd.com, Dec 15 2017

Blockedon: 795212
Project Member

Comment 19 by bugdroid1@chromium.org, Dec 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4984f824b38645f904645e192b48c6c7b5cd37c6

commit 4984f824b38645f904645e192b48c6c7b5cd37c6
Author: Hugo Holgersson <hugoh@vewd.com>
Date: Tue Dec 19 14:55:01 2017

Do not target hidden selections with ClipboardEvents

In Chrome a selection can have 3 states:
- Focused (and visible)
- Visible but unfocused
- Hidden (NEW*)

The spec** currently says:

  "Set target to be the element that contains the start of the
   selection in document order, or the body element if there is
   no selection or cursor."

This CL treats hidden selections as "no selection or cursor"
(document.body is targeted).

Target:
  State:      |  Focused  | Visible but unfocused |  Hidden
  --------------------- ------------------------------------
  Copy        |     VS    |         VS            |   BODY
  Cut&Paste   |     VS    |         VS            |   BODY

VS = Visible Selection.
*  https://github.com/w3c/selection-api/issues/94
** https://www.w3.org/TR/clipboard-apis/#fire-a-clipboard-event

The spec is being updated in:
https://github.com/w3c/clipboard-apis/issues/57

Bug:  755459 
Change-Id: I62670944ca0a636f9530e9857fde9e68044c44bc
Reviewed-on: https://chromium-review.googlesource.com/799697
Commit-Queue: Hugo Holgersson <hugoh@vewd.com>
Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525029}
[add] https://crrev.com/4984f824b38645f904645e192b48c6c7b5cd37c6/third_party/WebKit/LayoutTests/editing/pasteboard/clipboard-event-targets-visible-unfocused-selection.html
[add] https://crrev.com/4984f824b38645f904645e192b48c6c7b5cd37c6/third_party/WebKit/LayoutTests/editing/pasteboard/no-clipboard-event-to-hidden-selection.html
[modify] https://crrev.com/4984f824b38645f904645e192b48c6c7b5cd37c6/third_party/WebKit/Source/core/editing/Editor.cpp
[modify] https://crrev.com/4984f824b38645f904645e192b48c6c7b5cd37c6/third_party/WebKit/Source/core/editing/Editor.h
[modify] https://crrev.com/4984f824b38645f904645e192b48c6c7b5cd37c6/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp

Comment 20 by hu...@vewd.com, Dec 20 2017

Status: Fixed (was: Started)

Sign in to add a comment