How click a link ?
The difficult stuff starts

The following code simulates a mouse click on the "login" link on
http://lazarus.freepascal.org/var
s,s2:IInterfacedString;
EVT:nsIDOMEvent;
DV:nsIDOMAbstractView;
begin
//create a mouse event
s2:=newstring('MouseEvents');
EVT:=(GeckoBrowser1.ContentDocument as nsIDOMDocumentEvent).CreateEvent(s2.AString);
//get window AbstractView
DV:=(GeckoBrowser1.ContentDocument as nsIDOMDocumentView).DefaultView;
//make the event a 'click' event
s2:=newstring('click');
(EVT as nsIDOMMouseEvent).InitMouseEvent(s2.AString,true,false,DV,0,0,0,0,0,false, false, false, false, 0, GeckoBrowser1.ContentDocument as nsIDOMEventTarget );
//look for <li id="button_login">, our target <a> is 2nd child, cast to event target and dispatch event
s:=newstring(widestring('button_login'));
(GeckoBrowser1.ContentWindow.GetDocument().GetElementById(s.AString).GetChildNodes.Item(1) as nsIDOMEventTarget).DispatchEvent(EVT);
end;
The code hard codes a lot but you'll get the idea behind it.
I didn't find a way to pas a null XPCOM interface. The last parameter of InitMouseEvent is a secondary event target and not used for 'click'. So normally I should have passed null but fpc doesn't know how to cast a null (variant) to a nsIDOMEventTarget. I simply passed the document as secondary target and it works fine.
The <a> on this page doesn't contain javascript but since the click event is triggered explicitly, I would be surprised if an onclick wouldn't be triggered.