开发者

Does Firefox expose an assertion library to extension authors?

I'm writing a Firefox extension and am wondering about the best way to assert my application's invariants. From what I understand if I set browser.dom.window.dump.enabled = true in about:config, then window.dump() becomes available for logging (is this the recommended way to do the equivalent of console.log()?) but I'm wondering if there is an actual assertions library.

If not it's easy enough to write a tiny function that logs 开发者_C百科an error and throws an exception, but a built-in alternative would be cool.


There's nsIDebug which allows you to generate run-time assertions and aborts, but that may be overkill for what you want.

The recommended way to log is to use Services.console.logStringMessage (or its equivalent in older Firefox versions) or Components.reportError, both of which log to the Error console.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜