Bug 171907 - Web Inspector: Copy to clipboard fails via InspectorFrontendHostStub
Summary: Web Inspector: Copy to clipboard fails via InspectorFrontendHostStub
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-09 20:14 PDT by Ross Kirsling
Modified: 2017-05-10 11:53 PDT (History)
3 users (show)

See Also:


Attachments
Patch (1.84 KB, patch)
2017-05-09 20:22 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (1.84 KB, patch)
2017-05-10 11:22 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Kirsling 2017-05-09 20:14:03 PDT
Verification steps:
1. Ensure that InspectorFrontendHostStub is being used, or at the least, that InspectorFrontendHost.copyText is overridden to the stub implementation.
2. Do something that copies to the clipboard (e.g. Copy as cURL).
-- Clipboard is not updated (console error: "Clipboard access is denied").

Details:
- The copyText stub is calling document.execCommand("copy"), but there's no current selection, so this is guaranteed to fail.
- More specifically, instead of setting up the text to copy as a selection, we're just setting an unused field _textToCopy, which is a remnant of the old Inspector:
  https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js?rev=154828
Comment 1 Ross Kirsling 2017-05-09 20:22:21 PDT
Created attachment 309574 [details]
Patch
Comment 2 Joseph Pecoraro 2017-05-10 10:52:16 PDT
Comment on attachment 309574 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Base/InspectorFrontendHostStub.js:124
> +            const textarea = document.createElement("textarea");

Nit: We would typically use `let` instead of const, but it doesn't really matter.

Our style for when we use `const` tends to be when the value is the equivalent of a compile time constant. So `const timeToWait = 1000;" but not `const timeToWait = x * y;`. Maybe we should change that style though.
Comment 3 Ross Kirsling 2017-05-10 11:22:04 PDT
Created attachment 309619 [details]
Patch
Comment 4 WebKit Commit Bot 2017-05-10 11:53:37 PDT
Comment on attachment 309619 [details]
Patch

Clearing flags on attachment: 309619

Committed r216602: <http://trac.webkit.org/changeset/216602>
Comment 5 WebKit Commit Bot 2017-05-10 11:53:38 PDT
All reviewed patches have been landed.  Closing bug.