Setting up extension development environment
From MDC
This article gives suggestions on how to set up your Mozilla application for extension development.
Contents
[hide]- 1 Development preferences
- 2 Development extensions
- 3 Development profile
- 4 Custom code location
- 5 Using directories rather than JARs
[edit] Development preferences
These preferences will make debugging easier at the expense of lower performance.
See Editing Configuration Files for information on setting preferences. Note that some of these preferences are not listed in about:config by default, so you'll need to create new (boolean) entries for them.
See below under "Development Profile" to setup a separate development profile before you make these changes.
- javascript.options.showInConsole = true. Logs errors in chrome files to the Error Console.
- nglayout.debug.disable_xul_cache = true. Disables the XUL cache so that changes to windows and dialogs do not require a restart. This assumes you're using directories rather than JARs. Changes to XUL overlays will still require reloading of the document overlaid.
- browser.dom.window.dump.enabled = true. Enables the use of the dump() statement to print to the standard console. See
window.dump
for more info. You can also usensIConsoleService
from privileged script. - javascript.options.strict = true. Enables strict JavaScript warnings in the Error Console. Note that since many people have this setting turned off when developing, you will see lots of warnings for problems with their code in addition to warnings for your own extension. You can filter those with Console2.
[edit] Development extensions
These extensions may help you with your development.
- DOM Inspector, an option of a custom installation.
- Venkman, a JavaScript Debugger.
- Extension Developer's Extension
- Console2
- Chrome List
- Firebug
- Execute JS
- XPCOMViewer, an XPCOM inspector
[edit] Development profile
To avoid the performance hit of development-related prefs and extensions, and to avoid borking your personal data, you can use a separate profile for development work.
You can run two instances of Firefox using separate profiles if you start Firefox with the -no-remote parameter. For example, the following command will run your development profile whether "normal" Firefox is already running or not. (Assuming your development profile is called "dev"):
start "" "%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -P dev
To run Firefox with default profile just run "firefox" or "firefox -P default", as usual.
[edit] Custom code location
Rather than having to constantly reinstall the extension whenever you change something and to protect your source files from accidental deletion when uninstalling, you can place your source outside your profile in a location of your choosing.
- Find the extension ID from the install.rdf included with your extension
- Create a file in your_profile_directory/extensions/ with the above ID as the filename (eg. `your_profile_directory/extensions/{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58}`) (Find your profile directory)
- The contents of this file should be the path to the folder that contains your install.rdf file. (eg. `/full/path/to/yourExtension`. Windows users should use the drive name (CAPS) and backslashes instead of slashes: eg. `C:\full\path\to\yourExtension`). In Firefox 3, if you already the extension installed via XPI, you might need to install one or all of the extensions.* files in the profile folder. Backup first, but these files will be regenerated.
- Place the file in the extensions folder of your profile and restart the application.
[edit] Using directories rather than JARs
Regardless of whether you choose to package your extension's chrome in a JAR or in directories, developing in directories is simpler. If you choose a JARed structure for releasing, you can still develop with a directory structure by editing your chrome.manifest. For example, rather than having
content myExtension jar:chrome/myExtension.jar!/content/
use
content myExtension chrome/content/
没有评论:
发表评论