title: Selenium: enable XPCOM access and write to a file from Javascript in Firefox
body: <p>In this question there is an example how to request XPCOM access from Javascript:</p>
  
  <p><a href="https://stackoverflow.com/questions/3067774/how-to-create-a-file-using-javascript-in-mozilla-firefox">How to create a file using javascript in Mozilla Firefox</a></p>
  
  <pre><code> netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  </code></pre>
  
  <p>I was hoping to find a way to enable XPCOM access in similar manner for my Selenium test scripts, so that Javascript could directly write  RAW image data to a file. This actually continues my previous questions how to extract pixel data from  in optimized manner:</p>
  
  <p><a href="https://stackoverflow.com/questions/6514812/firefox-selenium-todataurl-uint8clampedarray-and-python">Firefox, Selenium, toDataURL, Uint8ClampedArray and Python</a></p>
  
  <p>What I am hoping to achieve</p>
  
  <ul>
  <li><p>Enable XPCOM access for Javascripts run through Selenium</p></li>
  <li><p>Render image on  Canvas</p></li>
  <li><p>Read canvas pixels as raw image data (public API should be available on the canvas itself)</p></li>
  <li><p>Write  RAW image data to a file using XPCOM interfaces in a known path location</p></li>
  </ul>
  
  <p>Note: PNG etc. encoding is unaccetable. This must be raw data for the speed, as it will be directly feed to a video encoding,</p>