`

Setting up an extension development environment

阅读更多

This article gives suggestions on how to set up your Mozilla application for extension development. Unless otherwise specified, these suggestions apply to both Firefox and Thunderbird as well as SeaMonkey version 2.0 and above.

Overview

  • Create a development user profile to run your development firefox session; with special development preferences in about:config .
  • Install some Firefox development extensions to your dev profile.
  • Edit files in the extensions folder of your profile and restart the application with the dev profile.

Development profile

To avoid performance degradation from development-related prefs and extensions, and to avoid losing your personal data, you can use a separate profile for development work.

You can run two instances of Thunderbird or Firefox at the same time by using separate profiles and starting the application with the -no-remote parameter. For example, the following command will start Firefox with a profile called "dev" whether an instance of Firefox is already running or not.

On Ubuntu (and many other Linux distributions):

/usr/bin/firefox -no-remote -P dev

On some other distributions of Linux/Unix:

/usr/local/bin/firefox -no-remote -P dev

On Mac OS Snow Leopard (10.6) and newer:

/Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev &

On Mac OS Leopard (10.5) and older, you must request the 32-bit portion of the Universal Binary (https://bugzilla.mozilla.org/show_bug.cgi?id=622970 ):

arch -arch i386 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev &

On Windows:

Start -> Run "%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -P dev

On Windows 64 bit:

Start -> Run "%ProgramFiles(x86)%\Mozilla Firefox\firefox.exe" -no-remote -P dev

To start Thunderbird or SeaMonkey instead of Firefox, substitute "thunderbird" or "seamonkey" for "firefox" in the examples above.

If the profile specified does not exist (or if no profile is specified), Thunderbird or Firefox will display the Profile Manager. To run with the default profile, specify "default" as the profile (or omit the "-P" switch).

(There is a thread in the Mozillazine forums that explains how to use both stable and development versions of Firefox to check extension compatibility. See Installing Firefox 3 or Minefield while keeping Firefox 2 .)

To make the numerous restarts easier, you can make one for reading documentation / for regular use, and the other one for extensions' testing, and run them at the same time using the no-remote command switch as described at http://kb.mozillazine.org/Command_line_arguments . The first one often needs lots of restarts, and you can launch both of them at the same time, like these two shortcuts on Windows:

...firefox.exe -no-remote -p "profile1"

...firefox.exe -no-remote -p "profile2"

These are Windows-specific lines. If you find the same instructions for Linux / Mac OS / etc please place them here too.

replace "..." with some real path. It is simple - just two shortcuts on the desktop - and lets you keep one of the profiles always open.

Development command flags

As ofGecko 2 (Firefox 4), JavaScript files are cached("fastload"). The -purgecaches command-line flag disables this behavior. Alternatively, you can set the MOZ_PURGE_CACHESenvironment variable. See this bug for more information.

Development preferences

There is a set of development preferences that, when enabled, allows you to view more information about application activity, thus making debugging easier. However, these preferences can degrade performance, so you may want to use a separate development profile when you enable these preferences. For more information about Mozilla preferences, refer to the mozillaZine article on "about:config ".

Not all preferences are defined by default, and are therefore not listed in about:config by default. You will have to create new (boolean) entries for them.

  • 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 use nsIConsoleService instead of dump() from a 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 .
  • devtools.chrome.enabled = true. This enables to run JavaScript code snippets in the chrome context of the Scratchpad from the Tools menu. Don't forget to switch from content to chrome as context.
  • extensions.logging.enabled = true . This will send more detailed information about installation and update problems to the Error Console . (Note that the extension manager automatically restarts the application at startup sometimes, which may mean you won't have time to see the messages logged before the automatic restart happens. To see them, prevent the automatic restart by setting the environment NO_EM_RESTART to 1 before starting the application.)
  • nglayout.debug.disable_xul_fastload = true . For Gecko 2.0+(Firefox 4.0+). See this bug for more information. Although the bug has been closed, it is believed that this pref is still relevant.
  • You might also want to set dom.report_all_js_exceptions = true . See Exception logging in JavaScript for details.
Gecko 2.0 note
(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

The Error Console is disabled by default starting in Firefox 4. You can re-enable it by changing the devtools.errorconsole.enabled preference to true and restarting the browser. With this, javascript.options.showInConsole is also set to true by default.

Accessing Firefox development preferences

To change preference settings in Firefox or SeaMonkey, type about:config in the Location Bar. Alternatively, use the Extension Developer's Extension , which provides a menu interface for Firefox settings.

Accessing Thunderbird development preferences

To change preference settings in Thunderbird, open the "Preferences" (Unix) or "Options" (Windows) interface. On the "Advanced" page, select the "General" tab then click the "Config Editor" button.

Development extensions

These extensions may help you with your development.

Firefox extension proxy file

Extension files are normally installed in the user profile. However, it is usually easier to place extension files in a temporary location, which also protects source files from accidental deletion. This section explains how to create a proxy file that points to an extension that is installed in a location other than the user profile.

  1. Get the extension ID from the extension's install.rdf file.
  2. Create a file in the "extensions " directory under your profile directory with the extension's ID as the file name (for example "your_profile_directory/extensions/{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58} "). (How to find your profile directory ) Alternatively, rather than using a GUID, create a unique ID using the format "name@yourdomain" (for example chromebug@mydomain.com ).
  3. The contents of this file should be the path to the directory that contains your install.rdf file. (eg. "/full/path/to/yourExtension/ ". Windows users should use the drive name (CAPS) and backslashes instead of frontslashes (for example "C:\full\path\to\yourExtension\ " or "C:\sam\workspace\toolbar\helloWorldtoolbar\ "). Remember to include the closing slash and remove any trailing whitespace.

    • Important:In Firefox 3, if you already installed the extension via XPI, you might need to delete one or all of the extensions.* files in the profile folder. Backup first, but these files will be regenerated. (I don't know what the original author had in mind here, but the files extensions.cache , extensions.ini , extensions.rdf , are all regenerated by Firefox if deleted. You need to delete them if you mess with 'components', no harm done. If you do not initially delete these files the first time you try to load your extension, then the extension will silently not load. Firefox will disconnect from its parent process when it regens these files, so you may have to exit once and restart if you use the OS console.)
    • Important: Note that the use of proxy files requires that the extension's chrome.manifest defines its chrome urls using traditional directories, rather than a JARed structure. See below.
  4. Place the file in the extensions folder of your profile and restart the application.

Using directories rather than JARs

Regardless of whether you choose to eventually 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/
分享到:
评论

相关推荐

    php.ini-development

    The PHPRC environment variable. (As of PHP 5.2.0) ; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0) ; 4. Current working directory (except CLI) ; 5. The web server's directory ...

    Learning Phalcon PHP(PACKT,2015)

    You will begin the journey by installing and setting up Phalcon for your environment followed by the development of each module. You will be introduced to Phalcon’s ORM and ODM. Furthermore, you will...

    C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition

    development environment and using various tools to create the simplest application possible with C#. You will learn how to write and compile code using Visual Studio 2017 on Windows, or Visual Studio ...

    Beginning Python (2005).pdf

    Setting Up a Database 260 Try It Out: Creating a Gadfly Database 261 Using the Python Database APIs 262 Downloading Modules 263 Creating Connections 263 Working with Cursors 264 Try It Out: ...

    数位板压力测试

    Users should be able to use the tablet to set up an effi-cient, comfortable work environment. Questions to ask when thinking about tablet feature support include: • Does the interface provide the ...

    Java邮件开发Fundamentals of the JavaMail API

    addition, you will need a development environment such as the JDK 1.1.6+ or the Java 2 Platform, Standard Edition (J2SE) 1.2.x or 1.3.x. A general familiarity with object-oriented programming ...

    BURNINTEST--硬件检测工具

    - Correction to setting the CD burn test drive in preferences. - Changed the mechanism to check for the required DirectX Direct3D as the previous method did not work on some system (some W2003 ...

    Apache Geronimo 2.1_ Quick Reference.pdf

    Developing an Administration Console extension 238 Plugins portlet 243 Custom server assemblies and server profiles 245 Summary 247 Chapter 10: Administration 249 Administration Console 249 ...

    python3.6.5参考手册 chm

    PYTHONMALLOC environment variable DTrace and SystemTap probing support Other Language Changes New Modules secrets Improved Modules array ast asyncio binascii cmath collections concurrent....

    Radmin自动登录器v3.0-多国语言绿色版-Release1-20150615

    1、程序功能和使用环境介绍 2、程序操作方法介绍 3、登录信息文件RadminM.txt介绍 4、登录信息文件RadminM.txt的转换和编制 5、v3.0版新增解锁远程桌面功能 6、相关配置和多种语言支持介绍 ...

    Radmin自动登录器v3.0

    1、程序功能和使用环境介绍 2、程序操作方法介绍 3、登录信息文件RadminM.txt介绍 4、登录信息文件RadminM.txt的转换和编制 5、v3.0版新增解锁 远程桌面功能 6、相关配置和多种语言支持介绍 ...

    DebuggingWithGDB 6.8-2008

    4.7 Debugging an Already-running Process . . . . . . . . . . . . . . . . . . . . . . 4.8 Killing the Child Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.9 Debugging ...

    最新版的DebuggingWithGDB7.05-2010

    4.7 Debugging an Already-running Process . . . . . . . . . . . . . . . . . . . . . . . . 4.8 Killing the Child Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.9 ...

Global site tag (gtag.js) - Google Analytics