Faster extension development cycle: install changes automatically


The usual extension development cycle is less than optimal: change something, create a new extension build, install it in the browser (gonna love warnings), restart the browser, finally test it. I don’t like repeating this cycle all the time and so in the past years I’ve been using a test environment in which most extension files are loaded directly from my source code checkout (thanks to a manipulated chrome.manifest file). With this test environment many changes could be tested by simply reopening the extension window, for others you would restart the browser.

Unfortunately, this approach is less useful when working on restartless extensions — it requires me to restart the browser where updating the extension without a browser restart should be sufficient. And it completely broke down when I started testing Adblock Plus on an Android phone. My development machine and the browser where I test the extension are physically separated now. Add to this that getting Firefox Mobile to install an extension from the development machine is a rather complicated affair, and the result is that most of my “development” suddenly has nothing to do with writing code.

So I created a simple extension called Extension Auto-Installer that would listen for HTTP connections on a port. It would take the POST data of the incoming requests and install it as an extension. And if the extension isn’t restartless then it will also restart the browser automatically. Which means that installing an extension to a browser running Extension Auto-Installer can be done from the command line with a tool like wget:

wget --post-file=extension.xpi http://localhost:8888/

Instead of localhost it can also be the IP address of the phone running Firefox Mobile. To simplify things even further I integrated this functionality into the build tools used for my extensions so that I can write: autoinstall 8888

It will create an extension package and send it to port 8888 on localhost automatically. I guess that I can get rid of the old testenv command soon, I merely need to make Adblock Plus a restartless extension (all of my other extensions already are).

Now this extension is quite a security hole of course. I made sure that it doesn’t do anything by default and that it doesn’t use a predefined port, the user rather chooses a port himself. I’ve also added some warnings to the description. Already after uploading the extension it occurred to me that I can add a configuration option to define whether connections should be limited to loopback (defaulting to “yes”). Well, I was too focused on debugging mobile phones, probably in the next release…

Edit: Fixed the security issues in version 1.1 – there is now a whitelist for IP addresses that are allowed to install extensions. By default only is on that list.



Commenting is closed for this article.

← Older Newer →