Simulating mouse events in Firefox extension

1.5k views Asked by At

I need to simulate trusted mousemove event in JavaScript. As I read there:

http://help.dottoro.com/ljoljvsn.php

In Firefox, an event is trusted if it is invoked by the user and not trusted if it is invoked by script.

And after that I started search other solution. I found this:

Are events generated by Firefox extension 'trusted'?

Yes, events generated by extensions are always trusted.

So, now I want write FireFox extension to allow me create mousemove trusted event. Unfortunately, I've never written extensions FireFox, so I need to clarify some points. What I have:

  1. I downloaded example of XPI file
  2. I created install.rdf and bootstrap.js for bootstraped extension (like FireBug)

But now I don't understand:

  1. In this article: https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Miscellaneous#Simulating_mouse_and_key_events

i see code:

var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                      .getInterface(Components.interfaces.nsIDOMWindowUtils);
utils.sendMouseEvent("mousedown", 10, 10, 0, 1, 0); utils.sendMouseEvent("mouseup", 10, 10, 0, 1, 0);

what point in bootstrap.js I must insert this code? How I understand I must attach it in some active(or specified?) window.

  1. How can I can run extension code in my JavaScript like global object "console" in FireBug extension?

I would appreciate an explanation

0

There are 0 answers