开发者

Debugging tools for Firefox extension development

开发者 https://www.devze.com 2023-02-25 16:36 出处:网络
I am debugging a FF extension for a client (3500 lines). I have a separated development profile with just firebug && extension developer extensions to work.

I am debugging a FF extension for a client (3500 lines). I have a separated development profile with just firebug && extension developer extensions to work.

1.- I had developed a couple of extensions for FF some time in the previous 2 years. I remember that I used Firebug's console.debug/trace for debugging. Now, with Firebug 1.6.2 console is not defined. Any advise to fix this?

2.- Last night I installed console2 (an upgrade for the normal error console) that can help pretty well with a custom function like:

function debug(aMsg) {

setTimeout(function()开发者_如何学Go { throw new Error("[debug] " + aMsg); }, 0);

}

But Firebug.console.debug is superior. Please advise about alternative techniques for debugging FF extensions.


Recent Firebug releases include an excellent log/trace component to use when debugging an extension, use code like the following.

// When initialising extension
var myLogger = {}
try {
    Components.utils["import"]("resource://firebug/firebug-trace-service.js");
    myLogger = traceConsoleService.getTracer("extensions.myextension");
} catch (e) {
    // firebug not installed
}

// later on
if (myLogger.DBG_MINE) {
    myLogger.sysout("my message", obj); // intelligently handles obj exceptions too
}

To enable this logging, create a preference using about:config for extensions.myextension.DBG_MINE set to true. You can find more information, albeit slightly outdated at http://www.softwareishard.com/blog/firebug/tracing-console-for-firebug/ .

For more advanced debugging, it's worth checking out Chromebug, which lets you inspect XUL interfaces and debug extension code and Venkmann, which is just a debugger, but which I've found to be much faster than waiting for Chromebug to start up.

0

精彩评论

暂无评论...
验证码 换一张
取 消