Firebug 1.8 API Changes
From FirebugWiki
(→Globals) |
(→Removed Components) |
||
| Line 11: | Line 11: | ||
* Domplate still exists | * Domplate still exists | ||
| - | == | + | == JavaScript code modules == |
| - | * firebug-http-observer is | + | This section applies only to extension that explicitly import any of existing Firebug JS code modules. |
| - | * firebug-trace-service is | + | |
| + | Some [https://developer.mozilla.org/en/JavaScript_code_modules JavaScript code modules] has been transformed into AMD modules, but for now extension can still use the <code>Components.utils.import</code> to import them. | ||
| + | |||
| + | An example: | ||
| + | <source lang="javascript"> | ||
| + | Components.utils.import("resource://firebug/firebug-http-observer.js", scope); | ||
| + | </source> | ||
| + | |||
| + | * <code>"resource://firebug/firebug-http-observer.js"<code>: Firebug is using "firebug/http/requestObserver" AMD module. | ||
| + | * <code>"resource://firebug/firebug-trace-service.js"</code>: Firebug is using "firebug/lib/trace" AMD module. | ||
| + | |||
| + | The new way how to import these modules looks like as follows: | ||
| + | |||
| + | <source lang="javascript"> | ||
| + | define([ | ||
| + | "firebug/http/requestObserver" | ||
| + | ] | ||
| + | function (HttpRequestObserver) | ||
| + | { | ||
| + | // TODO: module implementation | ||
| + | } | ||
| + | </source> | ||
| + | |||
| + | The other modules will be transformed into AMD too. | ||
| + | |||
| + | * <code>"resource://firebug/debuggerHalter.js"</code> | ||
| + | * <code>"resource://firebug/firebug-annotation.js"</code> | ||
| + | * <code>"resource://firebug/firebug-service.js"</code> | ||
| + | * <code>"resource://firebug/observer-service.js"</code> | ||
| + | * <code>"resource://firebug/storageService.js"</code> | ||
== Removed API== | == Removed API== | ||
Revision as of 11:05, 26 May 2011
Firebug 1.8 introduces set of API changes that can impact existing Firebug extensions. This page summarizes these changes and offers solution how to fix broken extensions.
Contents |
RequireJS and AMD
Firebug source files are no longer loaded using <script> tags placed in a xul overlay (browserOverlay.xul). Firebug 1.8 uses RequireJS and Asynchronous Module Definition AMD. All files (there are still a few exception) follow the AMD syntax now (see an example).
Globals
- FirebugChrome doesn't exist anymore, you need to use
Firebug.chrome - FBTrace still exists
- Firebug still exists
- FBL still exists
- Domplate still exists
JavaScript code modules
This section applies only to extension that explicitly import any of existing Firebug JS code modules.
Some JavaScript code modules has been transformed into AMD modules, but for now extension can still use the Components.utils.import to import them.
An example:
Components.utils.import("resource://firebug/firebug-http-observer.js", scope);
-
"resource://firebug/firebug-http-observer.js"<code>: Firebug is using "firebug/http/requestObserver" AMD module. - <code>"resource://firebug/firebug-trace-service.js": Firebug is using "firebug/lib/trace" AMD module.
The new way how to import these modules looks like as follows:
define([ "firebug/http/requestObserver" ] function (HttpRequestObserver) { // TODO: module implementation }
The other modules will be transformed into AMD too.
-
"resource://firebug/debuggerHalter.js" -
"resource://firebug/firebug-annotation.js" -
"resource://firebug/firebug-service.js" -
"resource://firebug/observer-service.js" -
"resource://firebug/storageService.js"
Removed API
TODO: This is only a rough list of changes, more explanation needed.
- FBL.CCIN, FBL.CCSV and FBL.QI are obsolete, use "firebug/lib/xpcom"
- HTMLLib is not part of Firebug namespace, you need to include "firebug/lib/htmlLib"
- $STR, $STRP, $STRP, registerStringBundle, getStringBundle, getDefaultStringBundle, getPluralRule, internationalize and internationalizeElements are part of "firebug/lib/locale"
- dispatch and dispatch2 are part of "firebug/lib/events" module
- All preferences should be accessed through "firebug/lib/options" module
- FBL.deprecated is now Deprecated.deprecated (firebug/lib/deprecated)
- FBTrace comes from "firebug/lib/trace"
- New modules: url, wrapper (don't use the API from FBL)
- FBL.findNext and FBL.findPrevious no longer exist.
- FirebugChrome namespace: getBrowsers, getCurrentBrowsers, getCurrentURI API removed and part of firefox/firefox module
- There is a new
<div>fbMainFrame (wrapping fbContentBox)
- Firebug.getTabForWindow and getTabIdForWindow is removed, use firefox/window module (getWindowProxyIdForWindow).
- FBL.openWindow, FBL.viewSource, FBL.getBrowserForWindow are part of firefox/firefox
- FBL.ToggleBranch is now ToggleBranch.ToggleBranch
- FBL.Continued removed.
- FBL.isAncestorIgnored removed
- FBL.ErrorMessage -> FirebugReps.ErrorMessageObj
- FBL.fatalError removed
- FBL.ErrorCopy -> FirebugReps.ErrorCopy
- FBL.EventCopy -> DOM.EventCopy
- FBL.Property -> FirebugReps.PropertyObj
- FBL.findScripts -> Firebug.SourceFile.findScripts;
- FBL.findScriptForFunctionInContext -> Firebug.SourceFile.findScriptForFunctionInContext;
- FBL.findSourceForFunction -> Firebug.SourceFile.findSourceForFunction;
- FBL.getSourceLinkForScript -> Firebug.SourceFile.getSourceLinkForScript;
- FBL.getSourceFileByHref -> Firebug.SourceFile.getSourceFileByHref;
- FBL.sourceURLsAsArray -> Firebug.SourceFile.sourceURLsAsArray;
- FBL.sourceFilesAsArray -> Firebug.SourceFile.sourceFilesAsArray;
- FBL.mapAsArray -> Firebug.SourceFile.mapAsArray;
- FBL.NetFileLink -> Firebug.NetMonitor.NetFileLink
FBL.$
- FBL.$ is deprecate, if you use it you should explicitly provide the document where the element is expected as the second parameter.
var elem = FBL.$("myElem", document);
- See also: http://groups.google.com/group/firebug-working-group/browse_thread/thread/c8081f66a5139312
FBL in XUL Windows
- If you using FBL in separate XUL windows/dialogs, make sure you don't include files
<script type="application/x-javascript" src="chrome://firebug/content/xpcom.js"/> <script type="application/x-javascript" src="chrome://firebug/content/lib.js"/>
You need to pass FBL and Firebug globals through window arguments.
Or access it from the browser window:
const windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); var FBL = windowMediator.getMostRecentWindow("navigator:browser").FBL;