From MozillaZine Knowledge Base
(Difference between revisions)
|Revision as of 11:49, 14 December 2005
Asqueella (Talk | contribs)
<-- Previous diff
|Revision as of 23:17, 18 December 2005
Asqueella (Talk | contribs)
Next diff -->
| ||** Extension Builder—a tool for editing install.rdf, packaging and installing your extension; still under development|| ||** Extension Builder—a tool for editing install.rdf, packaging and installing your extension; still under development|
| ||** As a bonus, it can toggle the debugging prefs listed above with a single menu click.|| ||** As a bonus, it can toggle the debugging prefs listed above with a single menu click.|
| || |
Revision as of 23:17, 18 December 2005
This describes some changes you can do to your system to make extension development easier. See also Getting started with extension development.
Set development prefs
Before you start doing any development, you should set some preferences to make life easier:
- nglayout.debug.disable_xul_cache = true. Disables the XUL cache (in your user.js) so that changes do not require a restart (more).
- browser.dom.window.dump.enabled = true. Enables the use of the dump() statement to print to the standard console. (The application must be started using the -console flag; read more)
Install development extensions
It is also a good idea to install a few developer extensions:
- The DOM Inspector is useful when you are trying to find the id of XUL elements which you wish to modify.
- Extension developer's extension for Firefox/Thunderbird/Mozilla (discussion). Includes these tools:
- JS Shell—execute statements from main application window. Features tab completion!
- JS Environment—run code snippets
- XUL Editor—XUL editor with real-time preview
- HTML Editor—same for HTML
- Extension Builder—a tool for editing install.rdf, packaging and installing your extension; still under development
- As a bonus, it can toggle the debugging prefs listed above with a single menu click.
Having the above prefs set is very helpful when developing extensions, but they will slow down Firefox a bit, particularly at startup and when opening new browser windows, especially if you have many extensions installed. For these reasons you may choose to use a separate profile for development.
Warning: Especially in Thunderbird you should use a separate profile as you could destroy your old one. Development versions and nightlies often harm a profile!
You can run two instances of Firefox using separate profiles if you set MOZ_NO_REMOTE environment variable to 1. For example, on Windows you can use the following bat file to run Firefox with development profile, whether "normal" Firefox is already running or not. (Assuming your development profile is called "dev"):
firefox -P dev
To run Firefox with default profile just run "firefox" or "firefox -P default", as usual. See article on the Profile Manager for more info on creating a new profile in Firefox.
Non-essential setup tips
Using an unpacked version of Thunderbird/Firefox for development
- Note: these instructions will not work with Firefox/Thunderbird 1.5 and later (as installed-chrome.txt and chrome.rdf are gone). See below for instructions in newer versions.
It's often necessary to extract all the jar files of the Thunderbird/Firefox/Mozilla Suite version you want to develop with: it makes debugging easier, you can include the code directly in the original sources, and you can make links from the sources to your extension sources. That describes what you need to do, at the example of the Thunderbird headerScroll extension (Windows users can use Cygwin to run these commands):
- Extract the
.tar.gz distribution file to a directory, e.g. "thunderbird-1.0.6"
for file in *.jar; do unzip $file; done
perl -pi.orig -e 's/(jar:)|(\/[^.\/]+\.jar!)//g' chrome.rdf installed-chrome.txt
ln -s /path/to/extension/src messenger-extensionname - see below for an explanation
mail/content/messenger/mailWindowOverlay.xul and add
<?xul-overlay href="chrome://messenger-headerscroll/content/headerscroll_overlay.xul"?> at the beginning after the other overlay defs - DON'T do
content/messenger-headerscroll/headerscroll_overlay.xul - it's a chrome directory name, so we have to omit the
chrome/installed-chrome.txt to give permissions
The explanation to point 5:
I don't like to mix the Thunderbird sources and my extension sources, so the extension code lies in a different folder. The structure of that is as follows:
+- all released versions go here
+- other files
So all I do with the
ln -s is to link the extension's directory
src directory in the
thunderbird/chrome/ directory, so that it's accessible from there.
Firefox 1.5 and later
Simply edit the chrome.manifest the same way as described above, i.e. remove all JAR references. For example change
content myExtension jar:chrome/myExtension.jar!/content/
content myExtension chrome/content/
See Getting started with extension development for detailed description and an example.