Firefox extension开发之开发环境配置

来源:互联网 发布:1元抢购软件 编辑:程序博客网 时间:2024/06/11 01:17

官方教程:https://developer.mozilla.org/en/Setting_up_extension_development_environment


概述

1、创建开发专用的用户配置文件来运行和测试所开发的firefox扩展

2、在dev配置文件中,安装firefox扩展开发所需的扩展

3、使用dev配置文件启动应用


开发配置文件

为了避免与开发相关的设置和扩展降低扩展性能,及避免丢失个人信息,我们使用一个单独的firefox配置文件来做我们的开发工作。

在Windows中运行:

cd D:\Program Files\Mozilla Firefox\

进入firefox目录下,运行  firefox.exe  -no-remote -P dev

新建配置文件dev用于firefox插件开发,下次启动时使用firefox.exe  -no-remote -P "dev",变可启动开会环境。


开发参数选择

有许多开发参数设置,当激活它们时,能看到更多关于应用的信息,并且更容易debug。但是,也有可能会降低性能,因此,我们使用一个独立的配置文件来启动firefox进行开发。firefox中所有的参数都是默认的,输入about:config可以进行配置。

  • 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.