Can't set permissions to allow javascript to copy to clipboard on custom firefox

RESOLVED WONTFIX

Status

()

Firefox
Untriaged
RESOLVED WONTFIX
5 years ago
5 years ago

People

(Reporter: Don Kleppinger, Unassigned)

Tracking

24 Branch
x86_64
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0 (Beta/Release)
Build ID: 20130910160258

Steps to reproduce:

We have a corporate web app for which we use a custom installation of firefox and in the autoadmin config file we give permission for the browser to copy text to the clipboard.  This worked on 10esr but no longer works on 24esr

the config file sets these parameters to give clipboard permission
// give permission to javascript to be able to copy to the clipboard.
pref("signed.applets.codebase_principal_support", true);

// prevents asing for users permission when copying to the clipboard.
// must be specified for each environment.
pref("capability.principal.codebase.p0.granted", "UniversalXPConnect");
pref("capability.principal.codebase.p0.id", "http://127.0.0.1:7101");
pref("capability.principal.codebase.p0.subjectName", "");

pref("capability.principal.codebase.p1.granted", "UniversalXPConnect");
pref("capability.principal.codebase.p1.id", "http://eawebvip-dev-dr.mydomain.com");
pref("capability.principal.codebase.p1.subjectName", "");


Actual results:

Permission to copy to the clipboard is denied
(Reporter)

Comment 1

5 years ago
function  copyTextToClipboard(copytext){
      
        try{  
        
         if (window.clipboardData) // Internet Explorer
        {  
          window.clipboardData.setData("Text", copytext);
          return;
        }

        // the property must be set in the firefox about:config for this function to work.
        // pref("signed.applets.codebase_principal_support", true); should be set in the eagle-config.cfg file
        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); // warns user first time
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        str.data=copytext;
        trans.addDataFlavor('text/unicode');
        trans.setTransferData("text/unicode",str,copytext.length*2);
        var clipid=Components.interfaces.nsIClipboard;
        clip.setData(trans,null,clipid.kGlobalClipboard);
        } catch(e){
            alert("This browser does not have permission to copy to the clipboard");
            return;
        }
  
}
(Reporter)

Comment 2

5 years ago
I was able to make this work by removing the PrivilegeManager reference and moving the copyTextToClipboard function to my extension and calling it from the page using an event.  I'm closing this as invalid.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.