Thunderbird/Add-ons Guide 63: Difference between revisions

Tweaked section about nsIRequestObserver and nsIStreamListener and whole-sale replaced "tt" with "code" tags.
(document various things I ran into while upgrading my add-on for Thunderbird 68)
(Tweaked section about nsIRequestObserver and nsIStreamListener and whole-sale replaced "tt" with "code" tags.)
Line 51: Line 51:
</source>
</source>


The key <tt>open_in_tab</tt> is optional and defaults to value false. Value true corresponds to <tt>optionsType 3</tt> in <tt>install.rdf</tt>.
The key <code>open_in_tab</code> is optional and defaults to value false. Value true corresponds to <code>optionsType 3</code> in <code>install.rdf</code>.


Examples of extensions converted to this type (as of 3rd December 2018):
Examples of extensions converted to this type (as of 3rd December 2018):
Line 61: Line 61:


== Removed in Thunderbird 60 ==
== Removed in Thunderbird 60 ==
Overlays have been progressively removed starting from this version. By version 63, there are no overlays left in Thunderbird. Due to Thunderbird's own overlay loader, XUL add-ons can still use overlays, but they can of course not overlay the removed Thunderbird overlays any more. For example, if your add-on overlaid <tt>mailWindowOverlay.xul</tt>, that needs to be changed; in this example you most likely need to overlay <tt>messenger.xul</tt> now.
Overlays have been progressively removed starting from this version. By version 63, there are no overlays left in Thunderbird. Due to Thunderbird's own overlay loader, XUL add-ons can still use overlays, but they can of course not overlay the removed Thunderbird overlays any more. For example, if your add-on overlaid <code>mailWindowOverlay.xul</code>, that needs to be changed; in this example you most likely need to overlay <code>messenger.xul</code> now.


== Removed in Thunderbird 61 ==
== Removed in Thunderbird 61 ==
* XUL element method <tt>.insertItemAt()</tt>, replacement: <tt>.insertBefore()</tt>
* XUL element method <code>.insertItemAt()</code>, replacement: <code>.insertBefore()</code>
* XUL element method <tt>.removeItemAt()</tt>, replacement: <tt>.remove()</tt>, example: <tt>listElement.removeItemAt(i)</tt> -> <tt>listElement.getItemAtIndex(i).remove()</tt>
* XUL element method <code>.removeItemAt()</code>, replacement: <code>.remove()</code>, example: <code>listElement.removeItemAt(i)</code> -> <code>listElement.getItemAtIndex(i).remove()</code>
* You can also use <tt>.setUnsafeInnerHTML()</tt> or <tt>document.allowUnsafeHTML = true</tt>, as a workaround to the above, see [[Thunderbird/Add-ons_Guide_57#Removed_and_changed_in_mozilla60|here]].
* You can also use <code>.setUnsafeInnerHTML()</code> or <code>document.allowUnsafeHTML = true</code>, as a workaround to the above, see [[Thunderbird/Add-ons_Guide_57#Removed_and_changed_in_mozilla60|here]].
* The interface of <tt>AddonManager.getAddonByID</tt> has changed. It now returns a promise, so instead of calling it as <tt>AddonManager.getAddonByID(''addon_id'', ''callback_function'')</tt>, you need to call it as <tt>AddonManager.getAddonByID(''addon_id'').then(''callback_function')</tt>.
* The interface of <code>AddonManager.getAddonByID</code> has changed. It now returns a promise, so instead of calling it as <code>AddonManager.getAddonByID(''addon_id'', ''callback_function'')</code>, you need to call it as <code>AddonManager.getAddonByID(''addon_id'').then(''callback_function')</code>.


== Removed in Thunderbird 63 ==
== Removed in Thunderbird 63 ==
* XUL elements <tt>listbox</tt>, <tt>listboxitem</tt> and <tt>listcell</tt>. <br/>Replacement: <tt>richlistbox</tt> ([https://github.com/jobisoft/CategoryManager/commit/2267888be7de0d7ebe4f5b4626c48210c071b16f example migration])  
* XUL elements <code>listbox</code>, <code>listboxitem</code> and <code>listcell</code>. <br/>Replacement: <code>richlistbox</code> ([https://github.com/jobisoft/CategoryManager/commit/2267888be7de0d7ebe4f5b4626c48210c071b16f example migration])  
* XUL <tt>stringbundleset</tt> / <tt>stringbundle</tt>. You will also be unable to use the `nsIStringBundleService` interface.<br/>Replacement: Use <tt>Services.strings.createBundle(...)</tt>.<br/>In order to use stringbundles, you need to load stringbundle.js in your XUL: <tt>&lt;script type="application/x-javascript" src="chrome://global/content/elements/stringbundle.js"/&gt;</tt>, but the XUL Overlay loader takes care of this. See also [https://bugzil.la/1459743 bug 1459743].
* XUL <code>stringbundleset</code> / <code>stringbundle</code>. You will also be unable to use the `nsIStringBundleService` interface.<br/>Replacement: Use <code>Services.strings.createBundle(...)</code>.<br/>In order to use stringbundles, you need to load stringbundle.js in your XUL: <code>&lt;script type="application/x-javascript" src="chrome://global/content/elements/stringbundle.js"/&gt;</code>, but the XUL Overlay loader takes care of this. See also [https://bugzil.la/1459743 bug 1459743].


{{note|I am not sure the above information is correct with current Thunderbird trunk builds as of March 30, 2019. I got errors when attempting to embed <tt>stringbundle</tt> elements in XUL overlays. [[User:Jikamens|Jikamens]] ([[User talk:Jikamens|talk]]) 00:34, 31 March 2019 (UTC)}}
{{note|I am not sure the above information is correct with current Thunderbird trunk builds as of March 30, 2019. I got errors when attempting to embed <code>stringbundle</code> elements in XUL overlays. [[User:Jikamens|Jikamens]] ([[User talk:Jikamens|talk]]) 00:34, 31 March 2019 (UTC)}}
* <tt>mailServices.js</tt> has been renamed to <tt>MailServices.jsm</tt>. The old name keeps working for now, but you get a deprecation warning in the error console if you use the old name.
* <code>mailServices.js</code> has been renamed to <code>MailServices.jsm</code>. The old name keeps working for now, but you get a deprecation warning in the error console if you use the old name.
* Starting in Thunderbird 63, all XBL-bindings will be removed from Thunderbird. That means, that if you have a XBL=binding in your add-on that extends a binding that is removed, your binding will fail. With [https://bugzilla.mozilla.org/buglist.cgi?o1=equals&v1=1484976&f1=blocked this] query, you can see all the bugs related to de-xbl-ing Thunderbird, and see how the removal of each binding is handled.
* Starting in Thunderbird 63, all XBL-bindings will be removed from Thunderbird. That means, that if you have a XBL=binding in your add-on that extends a binding that is removed, your binding will fail. With [https://bugzilla.mozilla.org/buglist.cgi?o1=equals&v1=1484976&f1=blocked this] query, you can see all the bugs related to de-xbl-ing Thunderbird, and see how the removal of each binding is handled.
* A bunch of globals in the message composition window were removed: <tt>nsIMsgCompDeliverMode</tt>, <tt>nsIMsgCompSendFormat</tt>, <tt>nsIMsgCompConvertible</tt>, <tt>nsIMsgCompType</tt>, <tt>nsIMsgCompFormat</tt>, <tt>nsIAbPreferMailFormat</tt>, <tt>nsIPlaintextEditorMail</tt>, <tt>nsISupportsString</tt>, and <tt>mozISpellCheckingEngine</tt>. If you use any of these, there are available as the same names underneath <tt>Ci.</tt> (a.k.a. <tt>Components.interfaces.</tt>).
* A bunch of globals in the message composition window were removed: <code>nsIMsgCompDeliverMode</code>, <code>nsIMsgCompSendFormat</code>, <code>nsIMsgCompConvertible</code>, <code>nsIMsgCompType</code>, <code>nsIMsgCompFormat</code>, <code>nsIAbPreferMailFormat</code>, <code>nsIPlaintextEditorMail</code>, <code>nsISupportsString</code>, and <code>mozISpellCheckingEngine</code>. If you use any of these, there are available as the same names underneath <code>Ci.</code> (a.k.a. <code>Components.interfaces.</code>).
== Removed in Thunderbird 64 ==
== Removed in Thunderbird 64 ==
* XUL element <tt>colorpicker</tt>.<br/>Replacement: HTML <tt>input type=color</tt>
* XUL element <code>colorpicker</code>.<br/>Replacement: HTML <code>input type=color</code>


== Removed in Thunderbird 65 ==
== Removed in Thunderbird 65 ==
* XUL element <tt>progressmeter</tt>.<br/>Replacement: HTML <tt>progress</tt> ([https://github.com/jobisoft/CategoryManager/commit/be23d9abfba29e5585d485348d84bd36c3c6bcaf example migration])
* XUL element <code>progressmeter</code>.<br/>Replacement: HTML <code>progress</code> ([https://github.com/jobisoft/CategoryManager/commit/be23d9abfba29e5585d485348d84bd36c3c6bcaf example migration])


* There is no longer a <tt>statusbar</tt> element. Instead of putting <tt>statusbar</tt> elements inside a <tt>statusbarpanel</tt> in your XUL, they need to go inside an <tt>hbox</tt>. The <tt>hbox</tt> contains have the same names as the old <tt>statsusbar</tt> containers, so you just need to change the element type. Also, if your status bar items had popup menus attached to them, you will need to do that differently now as well. See [https://github.com/jikamens/send-later/blob/664468e4c29ba435edfeba8524d19a37a47dfda5/chrome/content/backgrounding.xul#L9 this example].
* There is no longer a <code>statusbar</code> element. Instead of putting <code>statusbar</code> elements inside a <code>statusbarpanel</code> in your XUL, they need to go inside an <code>hbox</code>. The <code>hbox</code> contains have the same names as the old <code>statusbar</code> containers, so you just need to change the element type. Also, if your status bar items had popup menus attached to them, you will need to do that differently now as well. See [https://github.com/jikamens/send-later/blob/664468e4c29ba435edfeba8524d19a37a47dfda5/chrome/content/backgrounding.xul#L9 this example].


== Changes in Thunderbird 67 ==
== Changes in Thunderbird 67 ==
* Thunderbird no longer passes in the <tt>aContext</tt> argument to the <tt>onDataAvailable</tt> methods of stream listeners, so stream listeners need to be updated so that they no longer expect this argument.
* The <code>nsIRequestObserver.onStopRequest</code> and <code>nsIStreamListener.onDataAvailable</code> interfaces have changed. The <code>aContext</code> argument has been removed. Especially stream listeners need to be updated so that they no longer expect this argument.


* <tt>MailUtils.getFolderForUri</tt> was renamed to <tt>MailUtils.getExistingFolder</tt>.
* <code>MailUtils.getFolderForUri</code> was renamed to <code>MailUtils.getExistingFolder</code>.


==== Importing javascript modules ====
==== Importing javascript modules ====
Line 117: Line 117:
==== Editable menulists ====
==== Editable menulists ====


The standard XUL element <tt>menulist</tt> no longer supports the <tt>editable</tt> attribute. However, editable menulists have been re-implemented using a custom element. To be able to use it, one has to include <tt>menulist.css</tt> and <tt>customElements.js</tt>:
The standard XUL element <code>menulist</code> no longer supports the <code>editable</code> attribute. However, editable menulists have been re-implemented using a custom element. To be able to use it, one has to include <code>menulist.css</code> and <code>customElements.js</code>:


<source lang="xml">
<source lang="xml">
316

edits