Weird incompatibility between two TB add-ons; JavaScript issue?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Kamens
Hi all,

I'm running into an extremely weird incompatibility between
my add-on, Send Later 3, and another one. Enigmail.

In a nutshell, when my add-on, Send Later 3, is installed,
two Enigmail icons that are supposed to appear in the status
bar at the bottom of the message compose window do not appear.

The strange thing is that my add-on doesn't go anywhere near
the status bar in the message compose window.

Through strategic commenting out of code in my add-on, I
managed to isolate the incompatibility to this single line of
code which is inside a function in my add-on:

  var sComposeMsgsBundle = document.getElementById("bundle_composeMsgs");

When I comment out this single line of code, the Enigmail
buttons appear; when I leave this single line of code active,
they do not.

This seems bizarre, to say the least. On the one hand, it
doesn't seem like my add-on is doing anything wrong here, so
the problem doesn't seem to be a bug in my add-on. On the
other hand, I've got users of my add-on complaining about it,
so I'd like to resolve it if I can. Any suggestions?

Thanks.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Mark Banner-4
On 13/03/2012 15:43, Jonathan Kamens wrote:
> Through strategic commenting out of code in my add-on, I
> managed to isolate the incompatibility to this single line of
> code which is inside a function in my add-on:
>
>    var sComposeMsgsBundle = document.getElementById("bundle_composeMsgs");
>
> When I comment out this single line of code, the Enigmail
> buttons appear; when I leave this single line of code active,
> they do not.

Is this from a function called in the global scope, i.e. whilst a window
is still loading?

We've had issues in the past where code has touched the DOM whilst a
window has been loading and that's stopped the status bar being
displayed in the 3-pane window.

Mark.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Protzenko
You're basically trigerring the firing of the XBL bindings, which
triggers a cascade of failures. See my comment in
MsgComposeCommands.js:117 for the full explanation (which was kindly
provided to me by Neil I think).

Cheers,

jonathan

On Tue 13 Mar 2012 04:51:20 PM CET, Mark Banner wrote:

> On 13/03/2012 15:43, Jonathan Kamens wrote:
>> Through strategic commenting out of code in my add-on, I
>> managed to isolate the incompatibility to this single line of
>> code which is inside a function in my add-on:
>>
>>    var sComposeMsgsBundle =
>> document.getElementById("bundle_composeMsgs");
>>
>> When I comment out this single line of code, the Enigmail
>> buttons appear; when I leave this single line of code active,
>> they do not.
>
> Is this from a function called in the global scope, i.e. whilst a
> window is still loading?
>
> We've had issues in the past where code has touched the DOM whilst a
> window has been loading and that's stopped the status bar being
> displayed in the 3-pane window.
>
> Mark.
> _______________________________________________
> dev-apps-thunderbird mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-apps-thunderbird
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Protzenko
In your specific case, I think you're trigerring a XBL binding that
belongs to Enigmail, and that binding expects the DOM to be fully
built, while your function accesses the stringbundle at script-load
time, where the DOM is partially built, that is, only up to the
<script> element you're in.

Have you thought about using StringBundle.js, a very convenient wrapper
for *not* dealing with XUL <stringbundle> elements?

http://mxr.mozilla.org/comm-central/source/mailnews/base/util/StringBundle.js

On Tue 13 Mar 2012 04:58:58 PM CET, Jonathan Protzenko wrote:

> You're basically trigerring the firing of the XBL bindings, which
> triggers a cascade of failures. See my comment in
> MsgComposeCommands.js:117 for the full explanation (which was kindly
> provided to me by Neil I think).
>
> Cheers,
>
> jonathan
>
> On Tue 13 Mar 2012 04:51:20 PM CET, Mark Banner wrote:
>> On 13/03/2012 15:43, Jonathan Kamens wrote:
>>> Through strategic commenting out of code in my add-on, I
>>> managed to isolate the incompatibility to this single line of
>>> code which is inside a function in my add-on:
>>>
>>>    var sComposeMsgsBundle =
>>> document.getElementById("bundle_composeMsgs");
>>>
>>> When I comment out this single line of code, the Enigmail
>>> buttons appear; when I leave this single line of code active,
>>> they do not.
>>
>> Is this from a function called in the global scope, i.e. whilst a
>> window is still loading?
>>
>> We've had issues in the past where code has touched the DOM whilst a
>> window has been loading and that's stopped the status bar being
>> displayed in the 3-pane window.
>>
>> Mark.
>> _______________________________________________
>> dev-apps-thunderbird mailing list
>> [hidden email]
>> https://lists.mozilla.org/listinfo/dev-apps-thunderbird
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Kamens
In reply to this post by Jonathan Protzenko
Thanks for the responses.

I'm trying to follow the advice you gave to try to address
the problem, but I can't seem to do it.

I moved the vast majority of the code I was running when the
compose window loaded from my compose-window-init hook into
the NotifyComposeBodyReady function of my compose listener.
All I am doing now before the NotifyComposeBodyReady function
gets called is:

* Define a few variables
* Add my compose-window-init listener:
        window.addEventListener("compose-window-init",
                                mysleventListener, false);
* Replace DoSpellCheckBeforeSend with my own custom version
  of it.

My compose-window-init listener registers the state listener:

        var mysleventListener = {
            handleEvent : function(event) {
                if (gMsgCompose != null) {
                    gMsgCompose.RegisterStateListener(Sendlater3Composing
                                                      .composeListener);
                }
            }
        }

Even with these changes in place, the problem persists. What
am I missing?

Two questions about StringBundle.js:

1. How long has it been available? My add-on is compatible
all the way back to TB2. I don't know if I've still got any
TB2 users, but I do know I have some TB3 users.

2. Judging from the comment at the top, to use
StringBundle.js, you need to know the URL of the string
bundle. But the bundle I'm using is one that's part of core
Thunderbird, and it seems more portable for me to be
retrieving it from the DOM than to be hard-coding its URL,
which might change, in my code. What are your thoughts about
that?
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Kamens-4
OK, so the questions I asked about StringBundle.js in my last
posting still apply:

>Two questions about StringBundle.js:
>
>1. How long has it been available? My add-on is compatible
>all the way back to TB2. I don't know if I've still got any
>TB2 users, but I do know I have some TB3 users.
>
>2. Judging from the comment at the top, to use
>StringBundle.js, you need to know the URL of the string
>bundle. But the bundle I'm using is one that's part of core
>Thunderbird, and it seems more portable for me to be
>retrieving it from the DOM than to be hard-coding its URL,
>which might change, in my code. What are your thoughts about
>that?

But the other questions don't, since I figured out what to do
to resolve the problem. I went through all my JavaScript and
made sure I wasn't executing anything at all until the "load"
event on the window had fired, and that appears to have
solved the problem.

Thanks for your help, guys. I've been schooled. :-)
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Philip Chee
On Tue, 13 Mar 2012 21:50:11 +0000 (UTC), Jonathan Kamens wrote:

> OK, so the questions I asked about StringBundle.js in my last
> posting still apply:
>
>>Two questions about StringBundle.js:
>>
>>1. How long has it been available? My add-on is compatible
>>all the way back to TB2. I don't know if I've still got any
>>TB2 users, but I do know I have some TB3 users.
>>
>>2. Judging from the comment at the top, to use
>>StringBundle.js, you need to know the URL of the string
>>bundle. But the bundle I'm using is one that's part of core
>>Thunderbird, and it seems more portable for me to be
>>retrieving it from the DOM than to be hard-coding its URL,
>>which might change, in my code. What are your thoughts about
>>that?

You don't have to use StringBundle.jsm, just extract the core
functionality and put it into your code.

e.g.

var strBundleService =
Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);

var bundle =
strBundleService.createBundle("chrome://yourextension/locale/yourextension.properties");

Phil

--
Philip Chee <[hidden email]>, <[hidden email]>
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Protzenko
In reply to this post by Jonathan Kamens-4
On 03/13/2012 10:50 PM, Jonathan Kamens wrote:
> OK, so the questions I asked about StringBundle.js in my last
> posting still apply:
>
>> Two questions about StringBundle.js:
>>
>> 1. How long has it been available? My add-on is compatible
>> all the way back to TB2. I don't know if I've still got any
>> TB2 users, but I do know I have some TB3 users.
I'm unsure but I guess it's a recent addition, since JS modules weren't
available in the 2.0 days if my memories are correct. The file has been
added on: Thu Aug 20 16:23:24 2009 -0700
>>
>> 2. Judging from the comment at the top, to use
>> StringBundle.js, you need to know the URL of the string
>> bundle. But the bundle I'm using is one that's part of core
>> Thunderbird, and it seems more portable for me to be
>> retrieving it from the DOM than to be hard-coding its URL,
>> which might change, in my code. What are your thoughts about
>> that?
Indeed that shouldn't bring you any advantage. I hadn't realized that
the string bundle you were using was defined already in the DOM. It
tends to be useful in a context where you don't have any relevant XUL
document at hand. I'm using it all over the place in Thunderbird
Conversations, because 1) the UI is HTML, so no <stringbundle> there and
2) all the code is in JS modules, which means no obvious window to poke at.

Cheers,

jonathan

> But the other questions don't, since I figured out what to do
> to resolve the problem. I went through all my JavaScript and
> made sure I wasn't executing anything at all until the "load"
> event on the window had fired, and that appears to have
> solved the problem.
>
> Thanks for your help, guys. I've been schooled. :-)
> _______________________________________________
> dev-apps-thunderbird mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-apps-thunderbird


_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Simon Paquet-2
In reply to this post by Jonathan Kamens
Jonathan Kamens wrote on 13. Mar 2012:

> Two questions about StringBundle.js:
>
> 1. How long has it been available? My add-on is compatible
> all the way back to TB2. I don't know if I've still got any
> TB2 users, but I do know I have some TB3 users.

Looking at the publicly available statistics for your addon on
https://addons.mozilla.org/de/thunderbird/addon/send-later-3/statistics/usage/applications/?last=30

I can say this:

For the last week

- 0,49% of your users used TB2
- 0,61% of your users used TB3.0
- 8,12 of your users used TB3.1
- 0,47% of your users used TB5
- 0,82% of your users used TB6
- 0,91% of your users used TB7
- 1,86% of your users used TB8
- 3,94% of your users used TB9
- 81,39% of your users used TB10
- 1,40% of your users used a different application (mostly TB11)

So dropping TB2 support for you addon seems like a solution that
would only hurt a very small minority (roughly 100-125 users) of
your userbase.

--
Simon
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Kamens-4
Simon Paquet <[hidden email]> writes:
>So dropping TB2 support for you addon seems like a solution that
>would only hurt a very small minority (roughly 100-125 users) of
>your userbase.

I am loathe to make a non-functional change to the add-on's
code base that would prevent >100 people from using it.

And as noted elsewhere, I can't use the suggested
functionality anyway since it requires a string bundle URL,
which I don't have, since I'm using a core Thunderbird string
bundle, not one that's included iwth my add-on.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Philip Chee
On Wed, 14 Mar 2012 23:44:18 +0000 (UTC), Jonathan Kamens wrote:

> Simon Paquet <[hidden email]> writes:
>>So dropping TB2 support for you addon seems like a solution that
>>would only hurt a very small minority (roughly 100-125 users) of
>>your userbase.
>
> I am loathe to make a non-functional change to the add-on's
> code base that would prevent >100 people from using it.
>
> And as noted elsewhere, I can't use the suggested
> functionality anyway since it requires a string bundle URL,
> which I don't have, since I'm using a core Thunderbird string

Sure, you do. Thunderbird is open source. Use the Source, Luke.

> bundle, not one that's included iwth my add-on.

Phil

--
Philip Chee <[hidden email]>, <[hidden email]>
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Kamens-4
Philip Chee <[hidden email]> writes:
>> And as noted elsewhere, I can't use the suggested
>> functionality anyway since it requires a string bundle URL,
>> which I don't have, since I'm using a core Thunderbird string
>
>Sure, you do. Thunderbird is open source. Use the Source, Luke.

I'm familiar with the Thunderbird source code, having
submitted several patches which have been accepted.

I'm also familiar with the somewhat dizzying pace with which
changes are made to the source code, which makes it only a
matter of time before someone moves the string bundle to
another URL and my add-on breaks.

Also, why should I waste memory loading a string bundle
directly from a file which is already loaded into the DOM?

In short, if I'm using a core Thunderbird string bundle that's
already in the DOM, there's no good reason, and several bad
reasons, for me to load it myself directly from its URL.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jim-267
On 03/15/2012 10:08 PM, Jonathan Kamens wrote:
> I'm also familiar with the somewhat dizzying pace with which
> changes are made to the source code, which makes it only a
> matter of time before someone moves the string bundle to
> another URL and my add-on breaks.

You're far, *far* more likely to experience breakage because we changed
a string's name than because we moved a file (which almost never happens).

> In short, if I'm using a core Thunderbird string bundle that's
> already in the DOM, there's no good reason, and several bad
> reasons, for me to load it myself directly from its URL.

Here's a good reason: your current method doesn't work right. If you
can't get things to work by grabbing the DOM node, then you've got two
choices: 1) use a less-than-perfect solution, or 2) release a broken add-on.

- Jim
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Weird incompatibility between two TB add-ons; JavaScript issue?

Jonathan Kamens-4
Jim <[hidden email]> writes:
>Here's a good reason: your current method doesn't work right. If you
>can't get things to work by grabbing the DOM node, then you've got two
>choices: 1) use a less-than-perfect solution, or 2) release a broken add-on.

Actually, it does. The problem was exactly what was diagnosed
here, and actually had nothing to do with the string bundle
per se. I fixed it as advised by people here to fix it, and
now everything works just fine. I already explained this four
days ago, in <jjofej$7j1$[hidden email]>.
Which makes me wonder why you and others are telling me to
change something to fix a problem that I already fixed four
days ago.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird