How to create restart-less #Firefox4 extension *WITHOUT* Jetpack
On Firefox 4, users can install and uninstall Jetpack extensions without a browser restart. The traditional extensions are needed for a browser restart.

Jetpack is not required
Jetpack itself does not provide the restart-less feature. Jetpack SDK is a rich development environment for Restart-less extensions (which are called by Bootstrapped extensions).
To make a bootstrapped extension, you need:
- add the
em:bootstrap="true"
in install.rdf; and - add bootstrap.js
Hello world of bootstrapped extensions
Step1. Write install.rdf with em:bootstrap="true"
There is no difference from traditional extensions... Only one exception is to add em:bootstrap="true"
.
<?xml version="1.0" encoding="utf-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bootstraptest@cat-in-136.blogspot.com</em:id>
<em:version>1.0</em:version>
<em:type>2</em:type><!-- extension! -->
<em:bootstrap>true</em:bootstrap>
<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0b5</em:minVersion>
<em:maxVersion>4.0</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>bootstraptest</em:name>
<em:description>bootstraptest</em:description>
<em:creator>@cat_in_136</em:creater>
<em:iconURL/>
<em:optionsURL/>
</Description>
</RDF>
Step2. Write bootstrap.js
This file shall contains entry point functions : install(data,reason)
, startup(data,reason)
, shutdown(data,reason)
and uninstall(data,reason)
.
function install(data, reason) {
}
function startup(data, reason) {
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
prompts.alert(null,
"Startup!",
"Hello world.");
}
function shutdown(data, reason) {
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
prompts.alert(null,
"Shutdown!",
"Good bye.");
}
function uninstall(data, reason) {
}
This extension says "Hello world." after it is installed and/or enabled, and "Good bye." after it is uninstalled and/or disabled.
Above code is very very simple. bootstrap.js in the general bootstrapped extensions (for example Jetpack) are complexity.
Step3. Packaging
All you have to do is compress the files.
$ zip -9r ../bootstraptest.xpi *
adding: bootstrap.js (deflated 66%)
adding: install.rdf (deflated 54%)
$
Open the XPI file to install. As soon as it is installed, a following dialog is displayed.
