Monday, January 29, 2007

Friday, January 26, 2007

Firefox development with Ant

I want to share with you a little build file that saved a lot of time for me.
Firefox extension development assumes that you need to
create two zip archives, install extension, restart firefox, etc.
Entire process can be automated with the help of the following
Ant build file :

<?xml version="1.0"?>
<project name="helloworld" default="xpi">

<property name="firefox" value="C:\...\firefox.exe"/>
<property name="ext_dir"
="C:\Program Files\Mozilla Firefox\extensions"/>
<property name="workdir" value="myxpi"/>
<property name="build" value="build"/>
<property name="extension.xpi" value="helloworld.xpi"/>
<property name="extension.jar" value="helloworld.jar"/>
<property name="guid" value="{...}"/>

<target name="jar">
includes="content/**" />

<target name="xpi" depends="jar">
<zip destfile="${build}\${extension.xpi}">
prefix="chrome" />
includes="install.rdf" />

<target name="install" depends="xpi, kill">
<exec executable="${firefox}">
<arg value="-install-global-extension"/>
<arg value="${build}\${extension.xpi}"/>

<target name="uninstall">
<delete dir="${ext_dir}\${guid}"/>

<target name="kill">
<exec executable="taskkill">
<arg value="/F"/>
<arg value="/IM"/>
<arg value="firefox.exe"/>

<target name="start">
<exec executable="${firefox}"/>


In target named jar we are creating a jar file to
put into our final xpi.
It is mechanics :) More interesting thing
happens in install target -
installation of extension as global extension
using command line.
When extension is installed in the following way,
it can be found in (for example)
C:\Program Files\Mozilla Firefox\extensions\${guid}.
${guid} actually is the same value as we defined
in our extension in install.rdf in the section em:id.
is simple -
just remove this directory. Restarting firefox in my script
is just killing windows app with taskkill command.

Wednesday, January 24, 2007


I have found an open source project which can help me to implement browser objects for my bot. This tool can be very useful for testing web applications. It is HtmlUnit. Very nice idea. But JavaScript support isn't so good as in browser ! Here is an example what you can do with HtmlUnit

final WebClient webClient = new WebClient();
final URL url = new URL("");
System.out.println("Starting at URL : "+url.toString());
final HtmlPage page = (HtmlPage)webClient.getPage(url);
List anchors = page.getAnchors();
//lets go to the first link at page
HtmlPage p = ((HtmlAnchor)anchors.get(0)).click();

JavaScript support is implemented with the help of Rhino, Web client - wrapper for commons httpclient. It is all OK, but all this stuff do not works with my JavaScript... damn !

Monday, January 22, 2007

Thursday, January 18, 2007

JavaScript evaluation with Rhino

OK, at this moment I can evaluate this snip of JavaScript code. I mean determine value of x or get a result of f() function from Java code :

var x = 'hello world !' ;
function a()
return 'a';
function f(x)
return a();
return 'b';

But... it seems to be that there are no any browser objects ! It is mean that I need to implement in some way all this stuff : window.* document.* Ohh-nooo :)

Wednesday, January 17, 2007

Web bot with JavaScript support

I'm not forgot about my blog. Really :) I'm just working on very complex and interesting project. It is command line web robot with JavaScript support. It is because some of functionality is provided with JavaScript i.e. passing cookies, adding fields to forms dynamically. Web robot maybe is not a great deal, but JavaScript support is pain ! You need to implement fetching URL-s, parsing HTML and evaluation of JavaScript. I hope I'll not go crazy when the project will be finished...

Thursday, January 11, 2007

OOP in PHP 5

New things in PHP 5 are mostly new OOP features. But what I see there ? Take a look at least at keywords and you'll see : interface, abstract (classes), final, instanceof, extends, clone(). Stealing nice features from Java is a good practice ? :)

Monday, January 08, 2007

How are you, freelancers ?

I want to share with you some sites for freelancers. They are different, so probably you can find some interesting here.

As for me, I'm not taking freelance seriously. I'm prefer to work for something big for a long time. From the other side, freelancer can work when he wants to work on task which is interesting to him. But I'm doubt they get really high payment for the work of big complexity. It is just my opinion, I can be wrong.