Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348302

Summary: Set XULRunner security policies to allow pasting
Product: z_Archived Reporter: Robert Munteanu <robert.munteanu>
Component: MylynAssignee: Project Inbox <mylyn-triaged>
Status: RESOLVED WONTFIX QA Contact: Tom Seidel <tom.seidel>
Severity: enhancement    
Priority: P3 CC: steffen.pingel
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Robert Munteanu CLA 2011-06-04 11:53:39 EDT
Right now I am unable to paste text directly ( using Ctrl-V ) in the HtmlComposer. Rather, I need to use the Right-Click -> Paste functionality.

This is problematic for two reasons:

# the user is confused since Ctrl-V fails silently;
# the dialog pops up inside the browser widget, and for small widget sizes there is not enough room to enter text in it.

Please consider adding enhanced paste support, so that pasting directly works.
Comment 1 Steffen Pingel CLA 2011-06-05 16:05:42 EDT
Sounds like a good enhancement.
Comment 2 Tom Seidel CLA 2011-06-06 04:51:24 EDT
I've tried to reproduce this behavior on Windows (Win7-IE8) and Linux (Ubuntu 10.04 - FF3.6.16), but was not able to. When I use Ctrl+V a paste is executed directly without any limitations.

Can you give me please a detailed configuration of your target system so that I can reproduce this error?
Comment 3 Robert Munteanu CLA 2011-06-06 05:56:07 EDT
I have had this problem on OpenSUSE 11.4 with FF 4.0 installed. I'll try and reproduce it again today.
Comment 4 Robert Munteanu CLA 2011-06-06 16:53:50 EDT
It definitely does happen for me. I can verify the following:

* Eclipse is running against xulrunner 1.9.2 - AFAIK that means Firefox 3.6
* Copy/paste is working in other fields in the task editor
* If I open e.g. the task url and try to paste data into a text field, that also works
* Focusing the editor and using the Edit menu to paste does not work either.

Is there any way I can debug this issue?
Comment 5 Tom Seidel CLA 2011-06-06 18:02:00 EDT
Ok, I'll take a look a that issue. Debugging can be done if you install the Firebug-Plugin and just open the base.html in your system-browser. I think this is a good starting point.
Comment 6 Robert Munteanu CLA 2011-06-07 04:44:44 EDT
I was able to test my particular combination on a Windows 7 machine, and it works. Therefore it seems to be a system-specific issue.

About the firebug integration, how should I do that? I guess Eclipse uses a private profile and I'm not sure how to install Firebug into it. Or do you mean opening base.html in Firefox like I would open any other page? I'm not sure what do afterwards.
Comment 7 Robert Munteanu CLA 2011-06-17 09:30:18 EDT
One more note - I am able to paste directly using the sample RCP app, but not in my implementation of a rich text task editor. Any idea what could be interfering?
Comment 8 Tom Seidel CLA 2011-06-17 10:03:40 EDT
I guess you're extending EditorParts from Mylyn.. - Probably they're hooking something like a handler that prevents pasting directly into the widget.
Comment 9 Robert Munteanu CLA 2011-06-19 05:23:37 EDT
Steffen, do you know of anything that the Mylyn tasks framework does that might prevent copy/paste from being handled properly by a custom task editor part?
Comment 10 Steffen Pingel CLA 2011-06-20 09:26:14 EDT
The task editor registers action handlers for cut/copy/paste to support these operations for different widget types. Take a look at CommonTextSupport.canPerformAction() (and AbstractTaskEditorPage.canPerformAction()). We may need to add support for browsers there.
Comment 11 Robert Munteanu CLA 2011-06-20 17:48:45 EDT
Thanks for the pointer Steffen, I managed to find the root cause - @CommonTextSupport.doAction@ only supports instances of Text and StyledText .

By overriding the @AbstractTaskEditorPage.doAction@ method I can access the Browser control, but not the wrapping HtmlComposer, which I would need to properly execute the commands.

Tom, do you have any ideas of how I can access the HtmlComposer associated with a Browser, or execute commands on the browser control in any other manner? I could maintain my own mapping of Brower to HtmlComposer references, but things can get messy quickly with that approach.
Comment 12 Steffen Pingel CLA 2011-06-20 18:07:47 EDT
To maintain mappings from StyledText to SourceViewer controls we use setData(). That way you can easily get the viewer reference if you have access to the control.
Comment 13 Robert Munteanu CLA 2011-06-20 18:12:21 EDT
Thanks, somehow I missed that.
Comment 14 Robert Munteanu CLA 2011-06-20 18:33:37 EDT
Now I seem to be making progress. To handle a 'copy' command I use the following code:

bc. 
        if (actionId.equals(ActionFactory.COPY.getId())) {
            composer.execute(new Command() {
                @Override
                public String getCommandIdentifier() {
                    return "copy";
                }
            });
            return;
        }
        
But when I press Control-C I get a Javascript popup which informs me that 'Your browser security settings don't permit the editor to automatically execute copying operations. Please use the keyboard for that (Ctrl/Cmd+C).' .  I understand what it says, but I have no idea how to work around it in Eclipse.
Comment 15 Tom Seidel CLA 2011-06-21 02:27:55 EDT
This is definitely the security policy of XULRunner which prevents direct pasting. I must admit that my knowledge about XULRunner is already some years old, but I remember that some of the configuration can be set directly via JavaScript via something like netscape.security.PrivilegeManager.enablePrivilege.

I'll take a look how this can be set, Robert probably you could do also some research :)
Comment 16 Robert Munteanu CLA 2011-06-21 03:10:24 EDT
Thanks, I'll have a look at the way the XULRunner security policy is configured.
Comment 17 Robert Munteanu CLA 2011-06-21 04:33:14 EDT
Copy/paste support is problematic for XULRunner. I have found that I need to set the user preference @signed.applets.codebase_principal_support@ to true. Obviously this does not work with a fresh SWT Browser instance, as it would be a security risk. Instead, according to http://www-archive.mozilla.org/unix/customizing.html#prefs I need to fiddle with user.js and prefs.js .

This seems quite unlikely to be possible to me, unless there is support from platform which I'm missing. If that is the case, I'm inclined to leave this as it is, as Eclipse 3.7 will try to use a WebKit-based browser widget on GTK by default ( http://www.eclipse.org/swt/faq.php#browserwebkitgtk ).
Comment 18 Tom Seidel CLA 2011-06-21 04:57:58 EDT
Ok, this is not really a solution :). Another possibility I've already tried to enable Flash-content in a XULRunner was shipping my own XULRunner. Mozilla provides AFAIK osgi-bundles with an integrated XULRunner. You could specifiy the global settings directly within that bundle and point eclipse to your own XULRunner.

Regarding Webkit: Have you already tried Webkit with Eclipse 3.7? - Is this also an issue with Webkit?
Comment 19 Robert Munteanu CLA 2011-06-21 07:53:39 EDT
With Eclipse 3.7 on Linux I am able to use all keyboard actions without even overriding doAction: copy, paste, select all, redo, undo. If I instantiate the composer with the SWT.MOZILLA flag then the actions stop working.

I am not sure why this happens only with Mozilla, but I can tell that it works on WebKit/GTK and IE. I can test on Mac OSX also, but since it also uses WebKit it should work.

As for shipping a custom/private XulRunner bundle, this would be too heavyweight for me. I would be content with the composer working properly on Windows, MacOS and Linux+WebKit and warning the users of limitations on Linux + Mozilla. Perhaps there is value in opening a bug against platform, but given that the trend is towards using the web kit browser I don't think that the situation will be improved.
Comment 20 Robert Munteanu CLA 2011-06-21 08:03:05 EDT
To try and sum up: if I can identify the problem with the Mozilla-backed browser I will report this to Platform/SWT . I just need to isolate the problem from the Mylyn framework. I've also looked for an existing bug report but was unable to find one.
Comment 21 Tom Seidel CLA 2011-06-21 08:39:27 EDT
Ok, marking this as WONTFIX, since there is no easy way to fix that. In addition ther is this workaround with the popup and the fact of the replacement of XULRunner with Webkit.

Thanks for your investigations Robert.