Thunderbird/Add-ons Guide 57: Difference between revisions

→‎Other changes relevant for TB60: Spilling from TB 67 nback into TB 60
(simplify preface. add where to ask for help)
(→‎Other changes relevant for TB60: Spilling from TB 67 nback into TB 60)
 
(20 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<big>'''Add-ons Guide for Thunderbird 57 and beyond'''</big>
<big>'''Add-ons Guide for Thunderbird 57 to Thunderbird 60 ESR'''</big>


'''Legacy add-ons''': Despite Mozilla core interface removals, Thunderbird 57-60 and beyond and Seamonkey will '''<u>still support</u> legacy add-ons <u>if</u> appropriate modifications are done to the add-on to adapt to the changed interfaces'''. Core interface changes and removals have come because Mozilla core have disabled "legacy" add-ons (add-ons which are not based purely on WebExtensions) in Firefox 57.
(For developer information about Thunderbird 61 and beyond visit the [[Thunderbird/Add-ons Guide 63|Add-ons Guide 63]]. Note: Thunderbird 61 and 62 betas were skipped. The next beta after 60 is 63.)


'''WebExtension''': WebExtension does not exist yet in Thunderbird. Thunderbird will be adding WebExtension support ({{bug|1396172}}) while maintaining "legacy" add-ons and hybrid add-ons.  
'''Ask Questions, Get Help''': Developers are encouraged to ask for help and advice in the mozilla.dev.apps.thunderbird newsgroup, see [[Thunderbird/CommunicationChannels#If_you.27re_a_developer|Communication Channels]].  Please check this document and ask questions in a forum before filing a bug report. Also, if you target version is 60, test and fix your add-on using [https://getthunderbird.com version 60 release], not nightly builds or beta.
 
'''Legacy, pre-version 57 add-ons''' - '''Thunderbird 57-60 (and Seamonkey) <u>still support</u> legacy add-ons''' (except binary add-ons, see [[#Removed_in_mozilla53|below]]), but all add-on authors must check to see whether code changes are needed. The complexity of the add-on determines how it is affected - many add-ons are not heavily affected, some not affected at all. '''Some add-ons do not need any code changes, and some only trivial or minor refactoring or name changes. Some need to adapt to changed interfaces. Some only need changes to startup and intialization, others may need more extensive changes.''' A non-exhaustive list of of things to be modified is below.  Every beta from 57 to 60 delivered changes. So for example if your add-on is compatible with beta 58 you may still need to make further changes.  Example changes to version 59 involve {{bug|1414398}} default preferences, and {{Bug|1419145}} menu to access add-on options and tab options.
 
'''Why''': Firefox platform have disabled "legacy" add-ons in Firefox 57 (that is, all add-ons not based purely on [[WebExtensions]]), so Mozilla removed some core interfaces which are also used by Thunderbird. However, unlike Firefox, Thunderbird has not killed legacy add-ons, because the Thunderbird team lessened the impact of those changes on Thunderbird add-on developers, where possible.
 
'''WebExtension''' aka futures: Thunderbird 60 does not have WebExtensions support. Going forwards, {{bug|1396172}} will add WebExtension support in Thunderbird beta 63, while maintaining "legacy" add-ons and hybrid add-ons.  


'''Questions and Help''': Add-on developers can get help in the mozilla.dev.apps.thunderbird newsgroup (the traditional venue) or in maildev mailing list. (see [[Thunderbird/CommunicationChannels#If_you.27re_a_developer]] Please [[Thunderbird/CommunicationChannels#If_you.27re_a_developer|ask there]] before filing a bug report in bugzilla, because these forums have more people available to help.
<br><p>
<br><p>


__TOC__
__TOC__
== Removed in mozilla53 ==
Binary add-ons are no longer supported by the Mozilla platfrom since Thunderbird 53. (Binary add-ons were already discontinued in Firefox 41, [https://blog.mozilla.org/addons/2015/05/04/dropping-support-for-binary-components/ see here].) Further reading: [https://mail.mozilla.org/pipermail/tb-planning/2016-November/004964.html tb-planning post] of November 2016, [https://bugzilla.mozilla.org/show_bug.cgi?id=1314955 bug 1314955] which removed the feature from the Mozilla platform. It is however still possible to install the "binary component" separately. As an example, check how Enigmail installs and communicates with both GPG and the pEp engine.


== Removed interfaces in mozilla57 ==
== Removed interfaces in mozilla57 ==
Line 16: Line 25:
* nsILocaleService and friends
* nsILocaleService and friends
* nsIScriptableDateFormat -- replacement: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat Intl.DateTimeFormat] and mozIntl.DateTimeFormat (use: |Services.intl.createDateTimeFormat(...)| in Thunderbird 57 and 58, changed to |new Services.intl.DateTimeFormat(...)| from Thunderbird 59).
* nsIScriptableDateFormat -- replacement: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat Intl.DateTimeFormat] and mozIntl.DateTimeFormat (use: |Services.intl.createDateTimeFormat(...)| in Thunderbird 57 and 58, changed to |new Services.intl.DateTimeFormat(...)| from Thunderbird 59).
* [https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIScriptableUnicodeConverter nsIScriptableUnicodeConverter] -- replacement: [https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder TextDecoder] and [https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder TextEncoder]; their web pages claim they only accept "utf-8" as the charset encoding, but that's not true, at least not in Thunderbird.
* nsIFilePicker.show() -- replacement: nsIFilePicker.open() (async), example: [https://hg.mozilla.org/comm-central/rev/d960dcde18c4#l6.12 Changeset where Thunderbird implemented that change]. There's also a "lazy" replacement:
* nsIFilePicker.show() -- replacement: nsIFilePicker.open() (async), example: [https://hg.mozilla.org/comm-central/rev/d960dcde18c4#l6.12 Changeset where Thunderbird implemented that change]. There's also a "lazy" replacement:
<pre>function PickerShow(fp) {
<pre>function PickerShow(fp) {
Line 74: Line 84:
* catch (ex if ...)
* catch (ex if ...)
* |Services.intl.createDateTimeFormat(...)| in Thunderbird 57 and 58 changed to |new Services.intl.DateTimeFormat(...)|
* |Services.intl.createDateTimeFormat(...)| in Thunderbird 57 and 58 changed to |new Services.intl.DateTimeFormat(...)|
* Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'] changed to new XMLHttpRequest();
* Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'] changed to new XMLHttpRequest(). Potentially you need to add  Components.utils.importGlobalProperties(["XMLHttpRequest"]), which might not be necessary from version 61.


== Changes in thunderbird59 ==
== Changes in thunderbird59 ==
Line 113: Line 123:
* Removed interfaces: nsIDOMXPathResult, nsIDOMNodeFilter, many methods of nsIDOMNode, nsIDOMElement::{Get|Set}Attribute(), nsIDOMHTMLElement, nsIDOMHTMLDocument, nsIDOMHTMLMediaElement, nsIDOMFormData. Some of the removed interfaces only affect C++ in Thunderbird internally but are listed here for completeness.
* Removed interfaces: nsIDOMXPathResult, nsIDOMNodeFilter, many methods of nsIDOMNode, nsIDOMElement::{Get|Set}Attribute(), nsIDOMHTMLElement, nsIDOMHTMLDocument, nsIDOMHTMLMediaElement, nsIDOMFormData. Some of the removed interfaces only affect C++ in Thunderbird internally but are listed here for completeness.
* All attributes of nsIURI.spec are read-only, use for example url.mutate().setQuery(aQuery).finalize(); More examples in {{bug|1440693}}.
* All attributes of nsIURI.spec are read-only, use for example url.mutate().setQuery(aQuery).finalize(); More examples in {{bug|1440693}}.
* Components.utils.import() has changed to ChromeUtils.import(). The old form still works.
* Components.utils.import() has changed to ChromeUtils.import(). The old form still works (but is slower)
* removed (no need to invoke it anymore) : Components.utils.importGlobalProperties(["XMLHttpRequest"]);
* Assignment to .innerHTML of an element does not work any more in chrome documents. As a temporary workaround, .setUnsafeInnerHTML or |document.allowUnsafeHTML = true;| can be used. This workaround was removed at mozilla61. The correct solution is to use .textContent, document.createElement(), DOMParser.parseFromString or document.execCommand("insertHTML", ...). Note that the jQuery library uses .innerHTML.
 
* Expression Closures have been dropped: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Expression_closures (use arrow functions).
== Outlook and Suggestion ==
'''Suggestion for add-on authors wishing to be compatible with Thunderbird 59: Go, go, go!''' The fix for {{bug|1414398}} (default preferences) and {{Bug|1419145}} (menu to access add-on options, tab options (3) work) has arrived (2017-12-12 and 2017-12-22). {{Bug|1418914}} has been fixed and then inline options can be achieved via an embedded WebExtension.


All add-ons compatible with TB 58 beta need further changes as mentioned above to be compatible with TB 59 Beta and TB 60 Daily.
== Other changes relevant for TB60 ==
* TB does no longer automatically pick up code changes if the addon is in a directory. Code changes are only picked up if install.rdf is changed. Also, it appears that TB needs to be restarted twice for the new code to come over (e.g. by restart addon or manually).
* Certain ways of defining Cu, Ci etc. do not work any longer, because Cc, Ci, Cu, and Cr are now defined by default in chrome (e.g. this does not work: const {classes: Cc, interfaces: Ci, utils: Cu, results : Cr} = Components; as found in some addons)
* Since ca. 60.6.1: Importing modules must be done like this: var { Gloda } = ChromeUtils.import("resource:///modules/gloda/public.js");, see TB 68 guide for more explanation


== Also Note ==
== Also Note ==
The list above only contains selected changes relevant to add-ons. The full list of changes can be seen at [https://developer.mozilla.org/en-US/Firefox/Releases Firefox developer release notes] where all the details, bugzilla bug reports and patches implementing those changes can be found.
The list above only contains selected changes relevant to '''Thunderbird''' add-ons. A larger list, some of which are only relevant to Firefox, can be seen at [https://developer.mozilla.org/en-US/Firefox/Releases Firefox developer release notes] where all the details, bugzilla bug reports and patches implementing the above changes, and more, can be found.  If you find something missing in the list above, please tell us <tbd>.
4

edits