Closed Bug 1834185 Opened 2 years ago Closed 2 years ago

messenger.messageDisplayScripts.register does not seem to have an effect

Categories

(Thunderbird :: Add-Ons: Extensions API, defect, P1)

Thunderbird 102

Tracking

(Not tracked)

RESOLVED MOVED

People

(Reporter: fun.note8540, Unassigned)

Details

Steps to reproduce:

With TB 102.11.0, I was following the "Hello World" Thunderbird extension example at:

https://developer.thunderbird.net/add-ons/hello-world-add-on/using-content-scripts

and also tried the very similar example from

https://github.com/thundernest/sample-extensions/tree/master/manifest_v2/messageDisplayScript

and it seems that that registering scripts via messenger.messageDisplayScripts.register does not work at all.

Actual results:

The call to messenger.messageDisplayScripts.register succeeds, returning an object with an unregister method as expected, but the registered script is never called, it seems, when opening a message.

Expected results:

The registered script should be called when opening a message.

Component: Untriaged → Add-Ons: Extensions API

Thanks for your report. Indeed, that does look bad.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P1

Again, thanks for finding this. Our example was broken and I fixed it here:
https://github.com/thundernest/sample-extensions/commit/732068006fa3a65d9d5eebc7f0e342adb3a5568f

The function which registered the script was never executed.

The hello world example (https://github.com/thundernest/sample-extensions/tree/master/hello-world) seems to be fine.

The registered script is not executed for already loaded messages, but only for the next message being displayed. Could that be the reason why you did not see the messageDisplay script being executed?

Thanks for taking care of this issue!

I can confirm that the sample-extension https://github.com/thundernest/sample-extensions/tree/master/manifest_v2/messageDisplayScript works fine now, great!

For the hello-world example, I in fact made a mistake: I registered a non-existent CSS file. What confused me was that the promise returned from

messenger.messageDisplayScripts.register({
    js: [{ file: "messageDisplay/message-content-script.js" }],
    css: [{ file: "messageDisplay/i-dont-exist.css" }],
});

did succeed, but still the script was not registered. Not sure if this is as intended.

Quoting the return value for registerScript from mdn:

A Promise that will be fulfilled with a contentScripts.RegisteredContentScript object that you can use to unregister the content scripts.

It does not seem to check if the specified files exist, but only sets up the hooks to load the specified files when a matching page is loaded (in this case: a new message being displayed). That second step will fail, if one or more files do not exist.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → MOVED
You need to log in before you can comment on or make changes to this bug.