Debugging a Thunderbird extension
Asked Answered
D

1

7

I'm working on a Thunderbird extension, and, unfortunately, can't sort out what's still valid from what's not. There's lots of stuff online, but, most of it is no longer applicable to recent Thunderbird.

  1. At a minimum, I need a way of seeing log messages from the extension, so I can see what's working and what's not. Ideally, I'd like a full debug console. There is a reference on Stackoverflow to Thunderbird Developer Tools, but there doesn't seem to be a way to download them.

  2. I'd also like to be able to execute Javascript that can reference my extension via the console. When I try this via Thunderbird's console, I get error messages. I get this even when using other people's extensions, so I have to assume that extensions are outside the scope of the console

How can I get visibility and interaction to a new Thunderbird extension?

Dannielledannon answered 22/2, 2016 at 19:13 Comment(1)
great question, same issue hereHartfield
R
5

2020 Update:

If you are writing a MailExtension (this is how WebExtension are called for Thunderbird) you should have a look at general debugging in WebExtensions, e.g. https://extensionworkshop.com/documentation/develop/debugging/

You should probably also take a look at the general developer documentation on MailExtension at https://developer.thunderbird.net/add-ons/about-add-ons

The thinks listed below there written for the Legacy Overlay Extension, which do not work in newer Thunderbird versions.


logging messages

As described in https://developer.mozilla.org/en-US/docs/Debugging_JavaScript, there exist 3 different consoles in Gecko. The one best accessible in Thunderbird is the Error Console. You can write messages to it through the nsIConsoleService. If you don't mind that the log messages show up as an error, you can also simply use Components.utils.reportError().

Another way is to log to the (native) console from which Thunderbird is started. This is done through dump().

The newest way to log messages is using the Log.jsm module. It is a very nice wrapper around the different logging methods, and my preferred way to log messages in Thunderbird.

Thunderbird Developer Tools

As you haven't linked to the reference, I'm not 100% sure, but I think you mean the possibility to remotely debug Thunderbird through Firefox. You don't need to download anything to use this, it is already integrated in Thunderbird.

execute Javascript that can reference my extension

Debugging Thunderbird remotely through Firefox gives also access to the console and Scratchpad in the Developer Tools. Both should have also access to the add-on.

You may also want to look at the Tiny JavaScript Debugger. It also allows the execution of arbitrary code while debugging.

Realize answered 24/2, 2016 at 14:51 Comment(6)
I wish there was a way to live-edit the addon's javascript until I get it right... or at least inject javascript (via scratchpad or Tiny Debugger) into the addon's script context.Clarino
Just a note for 2018 (Chrome 60): Tools -> Developer Tools -> Developer Toolbox will give you a debugger without needing to remotely attach Firefox.Hampson
@bluemorpho, Chrome 60 or Thunderbird 60?.Omor
Thunderbird 60, @Jaime. Sorry for the confusion.Hampson
But how do you debug a CONTENT script/html? For background you just do "inspect" on the add-on, but how do you breakpoint in content scripts?Hartfield
Can not say anything about content scripts, as I do not use them myself. I would try Thunderbird's global developer toolbox as an alternative. If that does not work, I suggest asking on Thunderbird's Add-On Developer Chat or Add-On Developer TopicboxRealize

© 2022 - 2024 — McMap. All rights reserved.