New issue
Advanced search Search tips

Issue 889618 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 4
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug-Regression



Sign in to add a comment

Copying of a partial URL is disabled when using AppleScript

Reported by aspirant...@gmail.com, Sep 26

Issue description

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

Steps to reproduce the problem:
1. Create an AppleScript (i.e., a .scpt file) with the following one line of code:
tell application "System Events" to keystroke "c" using {command down}
2. Highlight a *partial* amount of text in Chrome's address bar.
3. Trigger the AppleScript.

What is the expected behavior?
Obviously, only the selected text should be copied, not the unselected text as well.

What went wrong?
The clipboard will *always* contain the full URL, no matter which part of the URL you have selected.

Did this work before? Yes I have been using Chrome for 5 years and this is the first version that contains this bug.

Chrome version: 69.0.3497.100  Channel: stable
OS Version: OS X 10.11.6
Flash Version: 

I found a similar bug report here:
"Copying of a partial URL is disabled in Canary?"
https://productforums.google.com/forum/#!topic/chrome/yPm5fqtKE5U;context-place=forum/chrome

However, I have no issues with copying manually. only with copying via AppleScript keyboard shortcut.

And, yes, "Allow JavaScript from Apple Events" has been enabled in the "View" menu.
 
Labels: Needs-Triage-M69 Needs-Bisect
Cc: viswa.karala@chromium.org
Labels: Triaged-ET Needs-Feedback
Thanks for filing the issue!

@Reporter: Could you please provide sample Test File/URL that reproduces the issue which help in further triaging it and if possible provide the screencast of the issue which help in better understanding. As per comment# 0, issue was seen on 10.11.6 and could you please confirm if this is specific to 10.11.6.

Thanks!

Cc: erikc...@chromium.org a...@chromium.org lgrey@chromium.org ellyjo...@chromium.org sdy@chromium.org
Labels: -Pri-2 Proj-MacViews MacViews-Controls Group-Views_Regressions_from_Cocoa Pri-3
Status: Available (was: Unconfirmed)
The easiest way to confirm this that I found was

1. Open Script Editor
2. Write
  delay 5
  tell application "System Events" to keystroke "c" using {command down}
3. Run it
4. Within 5 seconds, switch to a Chrome window and partially select the URL
5. After 5 seconds, go to the Finder and go Edit > Show Clipboard

For whatever reason, the synthesized Command-C that System Events generates causes a selection of the entire Omnibox. Not sure why.
Labels: -Needs-Feedback
@viswa.karala@chromium.org:

There is no specific URL or string that triggers this bug. ANY text selection will trigger the bug.

I cannot determine if this bug is specific to OS X 10.11.6, as I do not have access to another Mac.



Comment #3 described how to reproduce this issue better than I did in my original post.
Might be related to  Issue 885163 . Both involve trying to copy substrings from the Omnibox indirectly.
Owner: lgrey@chromium.org
We're seeing this event come in from AppleScript right before the copy:
2018-10-02 11:10:12.195 Chromium[73322:491035] Event NSEvent: type=FlagsChanged loc=(877.172,613.176) time=63492.6 flags=0 win=0x7fd6821414b0 winNum=820 ctxt=0x0 keyCode=0

Which we end up interpreting as Cmd+A since keycode 0 is A, but I think might just be garbage?

I'm tempted to just not process this if we see it, or at least not try to interpret the key code.
That's a FlagsChanged; isn't that the command key being pressed?
That looks like this (down/up IIRC)
2018-10-02 11:14:34.996 Chromium[73322:491035] Event NSEvent: type=FlagsChanged loc=(573.133,266.039) time=63755.4 flags=0x100108 win=0x7fd6821414b0 winNum=820 ctxt=0x0 keyCode=55
2018-10-02 11:14:35.708 Chromium[73322:491035] Event NSEvent: type=FlagsChanged loc=(573.133,266.039) time=63756.1 flags=0x100 win=0x7fd6821414b0 winNum=820 ctxt=0x0 keyCode=55
Project Member

Comment 11 by bugdroid1@chromium.org, Oct 3

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

commit 59048c8cc3894851410543095756e0e74ffe1cc5
Author: Leonard Grey <lgrey@chromium.org>
Date: Wed Oct 03 19:21:10 2018

Mac: Bail on flagsChanged: if keycode is 0

flagsChanged: is under-documented, but in Apple's examples, the actual
key which causes the change flag is provided in the |keyCode| property
and |modifierFlags| is used to determine whether it's a keyup or keydown.

When sending command key combinations via AppleScript (and possibly other
methods), the system feeds us a flags changed event with modifier flags
set correctly for "Command down" but an unset key code. Since key code 0
is A, we interpret this as Cmd+A (select all) when no such thing was intended.

The correct event is sent as well (with, for example, key code 55 for left command),
so we should drop the key code 0 event instead of trying to intepret it.

Hopefully this change also fixes  https://crbug.com/885163 

Bug:  889618 
Change-Id: Ibc8fe0216b917cc50a23c252209f2ac09a10edf9
Reviewed-on: https://chromium-review.googlesource.com/c/1259243
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596319}
[modify] https://crrev.com/59048c8cc3894851410543095756e0e74ffe1cc5/ui/views_bridge_mac/bridged_content_view.mm

Labels: -Needs-Bisect TE-Verified-71.0.3570.0 TE-Verified-M71 Target-70 FoundIn-70
Able to reproduce the issue as per comment# 3 on chrome reported version# 69.0.3497.100
Verified the fix on Mac 10.12.6 on chrome version# 71.0.3570.0 as per comment# 3
Attaching screencast for reference
Observed "Only selected text got copied into clipboard"
Hence, the fix is working as excepted
Adding the verified labels.

@Leonard Grey: As the issue is still seen on M-70, hence adding FoundIn-70 and Target-70 labels to it and if applicable help in merging it to M-70 as well. Removing Needs-Bisect label to it.

Thanks!

889618.mp4
3.1 MB View Download
Status: Fixed (was: Available)

Sign in to add a comment