Adapt to Changes in Thunderbird 79-91
This document tries to cover all the internal changes that may be needed to make Experiment add-ons compatible with Thunderbird 91. If you find changes which are not yet listed on this page, you can ask for help and advice in one of our communication channels.
Changed API
nsISimpleEnumerator, nsIArray and nsIMutableArray
Most usage of nsIArray
and nsIMutableArray
has been replaced by standard JavaScript arrays and functions which returned a nsISimpleEnumerator
have been changed to return a JavaScript array as well. The following APIs have been updated (links to actual patches, showing how core handled the change):
nsIAbCard.properties (returns array)
nsIAbDirectory.childCards (returns array)
nsIAbDirectory.getCardsFromProperty (returns array)
nsIAbManager.directories (returns array)\
nsIMsgAccountManager.accounts (returns array)
nsIMsgAccountManager.allFolders (returns array)
nsIMsgAccountManager.allIdentities (returns array)
nsIMsgAccountManager.allServers (returns array)\
nsIMsgCompFields.attachments (returns array)\
nsIMsgCopyService.CopyFolders (has been renamed and now only accepts a single src folder)
nsIMsgCopyService.CopyMessages (expects an array for the second argument)
nsIMsgFilterCustomAction.getCustomActions (returns array)
nsIMsgFolder.addKeywordsToMessages (expects an array for the first argument)
nsIMsgFolder.deleteMessages (expects an array for the first argument)
nsIMsgFolder.listFoldersWithFlags (returns array)
nsIMsgFolder.markMessagesRead (expects an array for the first argument)
nsIMsgFolder.markMessagesFlagged (expects an array for the first argument)
nsIMsgFolder.removeKeywordsFromMessages (expects an array for the first argument)
nsIMsgFolder.setJunkScoreForMessages (expects an array for the first argument)
nsIMsgFolder.subFolders (returns array)\
nsIMsgFolderListener.msgsClassified (first parameter is an array)\
nsISmtpService.servers (returns array)
\
fixIterator() & iteratorutils.jsm
The function fixIterator()
is no longer needed by any core code and was subsequently removed together with iteratorutils.jsm
. It was mostly used in the following way:
Since MailServices.accounts.accounts
or MailServices.accounts.allIdentities
return a simple array since Thunderbird 75, there is no need to pipe it through fixIterator()
anymore. If your add-on is multi-version compatible and still supports Thunderbird 68 this has to be dealt with separately.\
nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL
Renamed in Beta 80 to SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL
. This is often used as the aSecurityFlags
argument in calls to Services.io.newChannelFromURI()
.
For example here.\
nsILoadInfo.SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS
Renamed in Beta 80 to SEC_REQUIRE_SAME_ORIGIN_INHERITS_SEC_CONTEXT
.
nsIMsgCompose.SendMsg
Renamed in Beta 86 to nsIMsgCompose.sendMsg
. It also returns a Promise now. More details can be found here.\
nsISocketTransportService.createTransport
Changed in Beta 87. Needs a fifth parameter to specify a nsIDNSRecord
value, but can be null
if not needed:
See here for more details.
IOUtils.jsm
The Thunderbird-specific IOUtils.jsm file was removed without a direct replacement. You need to alter your logic or copy code from the old JSM into your add-on. Bug 1678109 might be a good inspiration, as it contains the changes that were necessary for core code.
Renamed or Replaced API
nsIMsgCopyService.CopyFileMessage
Has been renamed to nsIMsgCopyService.copyFileMessage
.
nsIMsgCopyService.CopyMessages
Has been renamed to nsIMsgCopyService.copyMessages
.
nsIMsgCopyService.CopyFolders
Has been renamed to nsIMsgCopyService.copyFolder
and no longer accepts an Array of src folders, but a single src folder.
nsIMsgCopyService.NotifyCompletion
Has been renamed to nsIMsgCopyService.notifyCompletion
.
nsIMsgFolder.deleteSubFolders
Has been replaced by nsIMsgFolder.deleteSelf.
Removed API
Log4Moz
The file Log4moz.jsm
has been removed in Thunderbird 85. Instead, use console
:
console.debug()
console.log()
console.trace()
- same asconsole.log()
, but dumps a trace log additionally.console.info()
console.warn()
console.error()
These basic log functions accept multiple parameters, which are all dumped to the console. For example:
Alternatively,console.createInstance()
allows to define a custom console logger, with a prefix
and a maxLogLevel
. The maxLogLevel
can be used to disable/enable logging in debug or production builds or set the level based on users choice.
The levels Info
, Trace
and Log
are actually identical.
nsIAbListener
Interface has been dropped in favor of an observer based approach. See
nsIMsgFolder.listFoldersWithFlags
Use nsIMsgFolder.getFoldersWithFlagsinstead.
nsIMsgFolderNotificationService.notifyItemElement()
Use the dedicated function MailServices.mfn.notifyMsgsJunkStatusChanged or MailServices.mfn.notifyFolderReindexTriggered instead.
Broken/Removed XUL Elements
<xul:grid>
The grid element does not seem to work anymore. Alternative is to use <html:table>.
Changes in commonly used Files
folderPane.js
The ftvItem
object has been renamed to FtvItem
in Beta 86.
MsgComposeCommands.js
GetMsgAttachmentElement()
Has been replaced bygAttachmentBucket
. More information can be found here.
attachmentsCount()
Has been replaced by gAttachmentBucket.itemCount
.
attachmentsSelectedCount()
Has been replaced by gAttachmentBucket.selectedCount
.
chrome://messenger/content/newmailalert.xhtml
No longer supports the gAlertListener
, gUserInitiated
and gOrigin
parameters when being opened (argument 1-3). Instead, the following parameters are are used now:
Low-level changes
Thunderbird is now multi-process (e10s)
Thunderbird can now separate content into different processes, which can only communicate through limited channels. This change has advantages relative to security and performance, but restricts code from freely accessing data that belongs to a different process.
In Thunderbird 91, this is primarily affecting pages belonging to an Add-on, like the background page or frames injected with an experiment. Most other parts of Thunderbird did not (yet!) change as much.
In practical terms, this means that you may need to update your experiments:
If you create frames in Thunderbird's UI, these frames now need the appropriate attributes to load content in the right process. You can find an example of required changes in the E10S compatibility commit for the CustomUI experiment.
If you exchange raw objects between WebExtension scopes / "child" experiment code and Thunderbird / "parent" experiment code, you need to migrate to an indirect approach, usually based on explicit message passing. Depending on the complexity of your task, this can either happen through notifyTools, a custom experiment API or through custom experiment code directly using cross-process APIs (likely either message managers or actors).
As a consequence, if you load JavaScript modules in "child" experiment code, you will now get separate instances of the JSM: each process has its own instance, and there could be multiple child processes. If you keep using JSMs from "child" code, you may furthermore need to manually unload these separate instances on API shutdown (
ExtensionAPI.onShutdown
), even if you use a catch-all unloading solution like CachingFix or the WindowListener API.
Last updated