Bug 86621 - Web Inspector: Copy ... actions in the context menu don't work in the remote debugging mode.
Summary: Web Inspector: Copy ... actions in the context menu don't work in the remote ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Mikhail Naganov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-16 06:48 PDT by Mikhail Naganov
Modified: 2012-05-17 12:38 PDT (History)
12 users (show)

See Also:


Attachments
Patch (5.04 KB, patch)
2012-05-16 06:50 PDT, Mikhail Naganov
mnaganov: commit-queue-
Details | Formatted Diff | Diff
Comments addressed (5.03 KB, patch)
2012-05-16 07:02 PDT, Mikhail Naganov
pfeldman: review-
mnaganov: commit-queue-
Details | Formatted Diff | Diff
Comments addressed (6.26 KB, patch)
2012-05-16 08:36 PDT, Mikhail Naganov
pfeldman: review-
mnaganov: commit-queue-
Details | Formatted Diff | Diff
Comments addressed (7.32 KB, patch)
2012-05-17 04:42 PDT, Mikhail Naganov
pfeldman: review+
mnaganov: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Naganov 2012-05-16 06:48:48 PDT
Programmatic access to clipboard is disabled by default.

For Chrome, this can be solved by installing a simple extension like this one: http://pastebin.com/kDxUacJd

We also need to support copying in InspectorFrontendHostStub.
Comment 1 Mikhail Naganov 2012-05-16 06:50:56 PDT
Created attachment 142244 [details]
Patch
Comment 2 Alexander Pavlov (apavlov) 2012-05-16 06:56:14 PDT
Comment on attachment 142244 [details]
Patch

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

You don't seem to have added a corresponding localizedStrings.js entry for the message.

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:117
> +            event.clipboardData.setData('text', this._textToCopy);

We use double-quotes around strings in the frontend.

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:121
> +        } else {

We don't use braces around one-line blocks

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:129
> +        if (!document.execCommand('copy')) {

We use double-quotes around strings in the frontend.

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:206
> +    p.textContent = WebInspector.UIString("You need to install \"Chrome Developer Tools Frontend\" Chrome extension.");

Missing "the"? "...install the \"Chrome....."
Comment 3 Mikhail Naganov 2012-05-16 07:02:01 PDT
Comment on attachment 142244 [details]
Patch

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

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:117
>> +            event.clipboardData.setData('text', this._textToCopy);
> 
> We use double-quotes around strings in the frontend.

Done.

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:121
>> +        } else {
> 
> We don't use braces around one-line blocks

Sorry, I was thinking they need to be symmetrical for both if branches. Removed.

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:129
>> +        if (!document.execCommand('copy')) {
> 
> We use double-quotes around strings in the frontend.

Done.

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:206
>> +    p.textContent = WebInspector.UIString("You need to install \"Chrome Developer Tools Frontend\" Chrome extension.");
> 
> Missing "the"? "...install the \"Chrome....."

Added, thanks!
Comment 4 Mikhail Naganov 2012-05-16 07:02:51 PDT
Created attachment 142250 [details]
Comments addressed

I will add strings to localizedStrings once we agree on wording.
Comment 5 Peter Beverloo 2012-05-16 07:09:28 PDT
Comment on attachment 142250 [details]
Comments addressed

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

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:205
> +    p.textContent = WebInspector.UIString("You need to install the \"Chrome Developer Tools Frontend\" Chrome extension.");

Since this code is in WebCore, it probably shouldn't be referring to specific products (in this case, Chrome)?
Comment 6 Pavel Feldman 2012-05-16 07:42:06 PDT
Comment on attachment 142250 [details]
Comments addressed

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

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:114
> +    documentCopy: function(event)

Why do you override this document's copy?

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:205
>> +    p.textContent = WebInspector.UIString("You need to install the \"Chrome Developer Tools Frontend\" Chrome extension.");
> 
> Since this code is in WebCore, it probably shouldn't be referring to specific products (in this case, Chrome)?

This code should be in WebKit/chromium/src/js/DevTools.js. Who is going to own this extension? Could it be more generic (i.e. "Clipboard access enabler"?) Or we could combine it with the Chrome extension used for filesystem persistence. I would not want to see a separate "Chrome Developer Tools Front-end" as an extension.
Comment 7 Mikhail Naganov 2012-05-16 08:36:13 PDT
Comment on attachment 142250 [details]
Comments addressed

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

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:114
>> +    documentCopy: function(event)
> 
> Why do you override this document's copy?

We need to get the Event instance passed to the copy command handler in order to set clipboardData. I've changed the code insert FrontendHost's action after the event has been processed by the default documentCopy handler.

>>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:205
>>> +    p.textContent = WebInspector.UIString("You need to install the \"Chrome Developer Tools Frontend\" Chrome extension.");
>> 
>> Since this code is in WebCore, it probably shouldn't be referring to specific products (in this case, Chrome)?
> 
> This code should be in WebKit/chromium/src/js/DevTools.js. Who is going to own this extension? Could it be more generic (i.e. "Clipboard access enabler"?) Or we could combine it with the Chrome extension used for filesystem persistence. I would not want to see a separate "Chrome Developer Tools Front-end" as an extension.

Moved platform-specific code to DevTools.js

The extension (in fact, this is a simple Web App) specifies the starting URL (localhost:9222), adds clipboard access permissions, and specifies the frontend hosting URL as the App's URL. I've posted a link to the sample already, have you seen it? http://pastebin.com/kDxUacJd

Do you already have the extension used for filesystem persistence? Can you please point me to it?
Comment 8 Mikhail Naganov 2012-05-16 08:36:40 PDT
Created attachment 142270 [details]
Comments addressed
Comment 9 Pavel Feldman 2012-05-16 08:48:07 PDT
> We need to get the Event instance passed to the copy command handler in order to set clipboardData. I've changed the code insert FrontendHost's action after the event has been processed by the default documentCopy handler.

You can only use event object while it is being dispatched. Storing it is not right.

> The extension (in fact, this is a simple Web App) specifies the starting URL (localhost:9222), adds clipboard access permissions, and specifies the frontend hosting URL as the App's URL. I've posted a link to the sample already, have you seen it? http://pastebin.com/kDxUacJd

Nope, now that I've seen it, name slearly looks wrong ("Chrome Developer Tools Frontend"). You probably want to point to a wiki describing how to enable copy / paste or something.

> Do you already have the extension used for filesystem persistence? Can you please point me to it?

https://github.com/NV/chrome-devtools-autosave,
http://code.google.com/p/devtools-save/,
Comment 10 Pavel Feldman 2012-05-16 08:49:40 PDT
Comment on attachment 142270 [details]
Comments addressed

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

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:116
> +        if (!this._textToCopy)

I still don't understand what is happening here...

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:195
> +function clipboardAccessDeniedMessage() {

{ on the next line. You should not declare top-level functions.
Comment 11 Pavel Feldman 2012-05-16 09:00:37 PDT
Comment on attachment 142270 [details]
Comments addressed

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

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:120
> +        this._textToCopy = null;

delete this._textToCopy.

> Source/WebKit/chromium/src/js/DevTools.js:60
> +    return "You need to install the \"Chrome Developer Tools Frontend\" Chrome extension.";

You need to install Chrome extension that allows clipboard access for this page.
Comment 12 Mikhail Naganov 2012-05-17 04:42:20 PDT
Comment on attachment 142270 [details]
Comments addressed

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

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:116
>> +        if (!this._textToCopy)
> 
> I still don't understand what is happening here...

Discussed offline.

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:120
>> +        this._textToCopy = null;
> 
> delete this._textToCopy.

Done.

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:195
>> +function clipboardAccessDeniedMessage() {
> 
> { on the next line. You should not declare top-level functions.

Done.

>> Source/WebKit/chromium/src/js/DevTools.js:60
>> +    return "You need to install the \"Chrome Developer Tools Frontend\" Chrome extension.";
> 
> You need to install Chrome extension that allows clipboard access for this page.

Done.
Comment 13 Mikhail Naganov 2012-05-17 04:42:59 PDT
Created attachment 142452 [details]
Comments addressed
Comment 14 Yury Semikhatsky 2012-05-17 07:35:33 PDT
Comment on attachment 142452 [details]
Comments addressed

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

> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:216
> +}

Please remove this.
Comment 15 Mikhail Naganov 2012-05-17 12:04:51 PDT
Comment on attachment 142452 [details]
Comments addressed

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

>> Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js:216
>> +}
> 
> Please remove this.

What do you mean by "this"? The bracket is a closing for the one in the beginning of the file: "if (!window.InspectorFrontendHost) {". It's the highlighting that is a bit misguiding.
Comment 16 Mikhail Naganov 2012-05-17 12:38:42 PDT
Committed r117481: <http://trac.webkit.org/changeset/117481>