title: Key event from firefox addon error : Permission denied to access property 'type'
body: <p>I have a set of key events that i want to run, but am having a little trouble doing them from my extension.</p>
  
  <p>The goal is to fire these events on an input element that triggers an autocompletion list, and it will select the first on the list:</p>
  
  <pre><code>var  = document.getElementById(elementID);
  
  // END KEY
  var e = document.createEvent('KeyboardEvent');
  e.initKeyEvent('keydown', true, true, window, false, false, false, false, 35, 0);
  element.dispatchEvent(e);
  
  var e = document.createEvent('KeyboardEvent');
  e.initKeyEvent('keyup', true, true, window, false, false, false, false, 35, 0);
  element.dispatchEvent(e);
  
  // ARROW DOWN KEY
  var e = document.createEvent('KeyboardEvent');
  e.initKeyEvent('keydown', true, true, window, false, false, false, false, 40, 0);
  element.dispatchEvent(e);
  
  var e = document.createEvent('KeyboardEvent');
  e.initKeyEvent('keyup', true, true, window, false, false, false, false, 40, 0);
  element.dispatchEvent(e);
  
  //ENTER KEY
  var e = document.createEvent('KeyboardEvent');
  e.initKeyEvent('keydown', true, true, window, false, false, false, false, 13, 0);
  element.dispatchEvent(e);
  
  var e = document.createEvent('KeyboardEvent');
  e.initKeyEvent('keyup', true, true, window, false, false, false, false, 13, 0);
  element.dispatchEvent(e);
  </code></pre>
  
  <p>If I run this on firebug, it does exactly what I want.</p>
  
  <p>But when I run it from my extension, I get an error on the console that says </p>
  
  <blockquote>
    <p>Permission denied to access property 'type'
    wich points to a jQuery file of that website.</p>
  </blockquote>
  
  <p>I don't understand what triggers that error, since it is working with no hassle in Firebug.</p>
  
  <p>one example where this happens is on www.kayak.com with Paris on the "From" field. The elementID is "origin".</p>
  
  <p>Any input on why this might be happening?</p>
  
  <hr>
  
  <p>EDIT: With additional research on this kind of errors, it seems that this usually is related to same origin policy issues, but I can't figure out how this can happen from my extension. I can find the element, but when runing the key events it keeps giving that error.</p>
  
  <hr>
  
  <p>EDIT 2 :</p>
  
  <p>I've been testing this on multiple websites to try to figure what is happening, and it always gives some error on the console regarding the jQuery library file. At one of the websites, it wasn't a minified version and was able to see that the error was this block of code:</p>
  
  <pre><code>eventHandle = elemData.handle;
  if (!eventHandle) {
      elemData.handle = eventHandle = function (e) {
          return typeof jQuery !== "undefined" &amp;&amp; (!e || jQuery.event.triggered !== e.type) ? jQuery.event.dispatch.apply(eventHandle.elem, arguments) : undefined;
      };
      eventHandle.elem = elem;
  }
  </code></pre>
  
  <p>Any ideas on how this is getting in the way of the event i'm trying to send from my extension?</p>