Setting up extension development environment: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
(the second link is not useful and distracts from the first one, removed)
 
(28 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{extdev}}
See [http://developer.mozilla.org/en/docs/Setting_up_extension_development_environment Setting up extension development environment] at MDC.
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 ==
[[Category:Redirects]]
Before you start doing any development, you should [[Editing configuration|set]] some preferences to make life easier:
* '''javascript.options.showInConsole = true'''. Logs errors in chrome files to the [[JavaScript Console]] to make debugging easier.
* '''nglayout.debug.disable_xul_cache = true'''. Disables the XUL cache so that changes do not require a restart ([[Dev : Tips : Disable XUL cache|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; [[Viewing_dump()_output|read more]])
* '''javascript.options.strict = true'''.  Enables strict Javascript warnings in the JavaScript 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.
 
== 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.
* Not really a developer extension, but the [[JavaScript Console]] can be surprisingly useful. Open it every time you have made changes to your JS files; it serves as a handy syntax checker (but make sure you have set the preferences listed above).
* For more advanced Javascript aid, check out [[Venkman]], the Mozilla-based Javascript debugger ([http://www.mozilla.org/projects/venkman/ project home], [http://www.hacksrus.com/~ginda/venkman/ latest info]).
* [http://ted.mielczarek.org/code/mozilla/extensiondev/ Extension developer's extension] for Firefox/Thunderbird/Mozilla ([http://forums.mozillazine.org/viewtopic.php?t=116052 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.
 
== Development profile ==
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.
 
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"''):
set MOZ_NO_REMOTE=1
firefox -p dev
 
To run Firefox with default profile just run "firefox" or "firefox -p default", as usual.

Latest revision as of 16:35, 24 May 2007