title: paste data from clipboard using document.execCommand("paste"); within firefox extension
body: <p>I am trying to paste clipboard data into a variable that gets fed into and fired via XMLhttprequest POST message.</p>
  
  <p>I have created a firefox user.js with this code to increase access to clipboard based on this <a href="http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard" rel="nofollow noreferrer">recommendation</a>.</p>
  
  <pre><code>user_pref("capability.policy.policynames", "allowclipboard");
  user_pref("capability.policy.allowclipboard.sites", "mydomain");
  user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
  user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");
  </code></pre>
  
  <p>Do I need to change "mydomain" in line two? I do not want any sites to have access. Just my internal firefox extension.</p>
  
  <p>I have read several guides <a href="https://stackoverflow.com/questions/23910353/not-able-to-execute-command-window-document-execcommandpaste-in-brackets">here</a> and <a href="https://stackoverflow.com/questions/22702446/how-to-get-clipboard-data-in-chrome-extension/22702538#22702538">here</a> as well as <a href="https://developer.mozilla.org/en-US/docs/Web/API/document.execCommand#Commands" rel="nofollow noreferrer">mozilla</a>.</p>
  
  <p>Here is the code I have so far. The clipboard contents should get sent POST method via <code>XMLHttpRequest</code>. <code>XMLHttpRequest</code> works, as I have been using it for other variables.</p>
  
  <pre><code> var pastetext = document.execCommand('paste');
   var req = new XMLHttpRequest();
   req.open('POST', pastetext, true);
   req.onreadystatechange = function(aEvt) {
       if (req.readyState == 4) {
           if (req.status == 200)
               dump(req.responseText);
           else
               dump("Error loading page\n");
       }
   };
   req.send(null);
  </code></pre>
  
  <p>I am grateful for any help.
  Thank you</p>