title: Why is JavaScript executed in any browser apart from Chrome?
body: <p>I am using Vaadin and want to execute a click on an Upload Component via JavaScript when a MenuItem of a MenuBar is clicked. That works well in any browser apart from Chrome. Someone mentioned that this is due to the content security policy of Chrome, but Firefox has this as well and the script is executed in FF.</p>
  
  <p>The script looks as follows:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function clickUpload(element) {
   // DOM 2 Events
   var dispatchMouseEvent = function(target, var_args) {
     var e = document.createEvent("MouseEvents");
     // If you need clientX, clientY, etc., you can call
     // initMouseEvent instead of initEvent
     e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));
     target.dispatchEvent(e);
   };
   dispatchMouseEvent(element, 'mouseover', true, true);
   dispatchMouseEvent(element, 'mousedown', true, true);
   dispatchMouseEvent(element, 'click', true, true);
   dispatchMouseEvent(element, 'mouseup', true, true);
  }</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>menuBar.addItem("Import",
          e -&gt; JavaScript.getCurrent().execute("clickUpload(document.getElementsByClassName('gwt-FileUpload')[0])"));
  </code></pre>
  
  <p>I tried several other possibilities (like direct click() on element etc.) and anything works well in FF and Edge but not in Chrome. If I type "clickUpload(document.getElementsByClassName('gwt-FileUpload')[0])" in the console of Chrome the script is executed as well.</p>
  
  <p>Does anyone have an idea where this behaviour comes from?</p>
  
  <p>Best regards</p>