User input simulation

Hi

I want to simulate user input to a page, i.e. send events like “TAB key pressed”, “Mouse moved to 100, 100”, “string ‘hello world’ pasted from the clipboard”, “mouse clicked at 130, 150” for document to dispatch them as it wants.

This event should be treated by browser exactly like the natural event

I tried producing them in the content script:

var e = new ExampleEvent(...);
document.dispatch(e);

, but this way keyboard events are not processed naturally, e.g. <input>s don’t change their value (the focused one of course). As some resources point out, this seems to be a security feature.

Is there a natural way to create an event and send it for dispathing?