Bug 213568

Summary: Allow the async clipboard API to write data when copying via menu action or key binding
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: HTML EditingAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: aestes, bdakin, darin, ews-watchlist, megan_gardner, mifenton, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Wenson Hsieh 2020-06-24 11:25:30 PDT
SSIA
Comment 1 Radar WebKit Bug Importer 2020-06-24 11:31:30 PDT
<rdar://problem/64711653>
Comment 2 Wenson Hsieh 2020-06-24 14:02:54 PDT
Created attachment 402684 [details]
Patch
Comment 3 Darin Adler 2020-06-24 14:10:07 PDT
Comment on attachment 402684 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402684&action=review

> Source/WebCore/Modules/async-clipboard/Clipboard.cpp:53
> +    if (settings.javaScriptCanAccessClipboard() || frame.editor().isCopyingFromMenuOrKeyBinding())

Is it always right to ask this Frame’s editor? Should we instead ask the main frame’s editor?
Comment 4 Wenson Hsieh 2020-06-24 14:35:49 PDT
Comment on attachment 402684 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402684&action=review

Thanks for the review!

>> Source/WebCore/Modules/async-clipboard/Clipboard.cpp:53
>> +    if (settings.javaScriptCanAccessClipboard() || frame.editor().isCopyingFromMenuOrKeyBinding())
> 
> Is it always right to ask this Frame’s editor? Should we instead ask the main frame’s editor?

I believe it's right to ask this Frame's editor, since (in the case of copying from menu/key binding) the information about the editor command source is propagated down to the Frame responsible for handling and dispatching the clipboard event, which might be a subframe instead of the mainframe.
Comment 5 EWS 2020-06-24 16:00:27 PDT
Committed r263480: <https://trac.webkit.org/changeset/263480>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402684 [details].
Comment 6 Darin Adler 2020-06-24 17:14:20 PDT
Comment on attachment 402684 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402684&action=review

>>> Source/WebCore/Modules/async-clipboard/Clipboard.cpp:53
>>> +    if (settings.javaScriptCanAccessClipboard() || frame.editor().isCopyingFromMenuOrKeyBinding())
>> 
>> Is it always right to ask this Frame’s editor? Should we instead ask the main frame’s editor?
> 
> I believe it's right to ask this Frame's editor, since (in the case of copying from menu/key binding) the information about the editor command source is propagated down to the Frame responsible for handling and dispatching the clipboard event, which might be a subframe instead of the mainframe.

I bet you are right. Probably should add a test to prove it at some point.
Comment 7 Wenson Hsieh 2020-06-24 17:17:46 PDT
(In reply to Darin Adler from comment #6)
> Comment on attachment 402684 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=402684&action=review
> 
> >>> Source/WebCore/Modules/async-clipboard/Clipboard.cpp:53
> >>> +    if (settings.javaScriptCanAccessClipboard() || frame.editor().isCopyingFromMenuOrKeyBinding())
> >> 
> >> Is it always right to ask this Frame’s editor? Should we instead ask the main frame’s editor?
> > 
> > I believe it's right to ask this Frame's editor, since (in the case of copying from menu/key binding) the information about the editor command source is propagated down to the Frame responsible for handling and dispatching the clipboard event, which might be a subframe instead of the mainframe.
> 
> I bet you are right. Probably should add a test to prove it at some point.

Will do! <https://webkit.org/b/213581>