Only the first listener is persisted; multiple listeners not triggered when event page awakes
Categories
(WebExtensions :: General, defect, P2)
Tracking
(firefox113 fixed)
Tracking | Status | |
---|---|---|
firefox113 | --- | fixed |
People
(Reporter: robwu, Assigned: rpl)
References
(Blocks 2 open bugs)
Details
(Keywords: dev-doc-complete, Whiteboard: [addons-jira])
Attachments
(3 files)
When an extension registers multiple listeners for the same event, only the first event listener is called when the event page wakes up in response to the event being triggered.
STR:
- Visit
about:config
and setextensions.eventPages.enabled
pref to true. - Visit
about:debugging
and load the attached extension. It registers 4 listeners. - Click "Terminate background" button to terminate the event page.
- Click the extension button twice.
- Inspect the background console.
Expected:
- 1 2 3 4 - should have been logged after the first click.
- 1 2 3 4 - should have been logged after the second click.
Actual:
- 1 - logged after the first click
- 1 2 3 4 - logged after the second click.
This happens because we key persistent listeners by the API path: https://searchfox.org/mozilla-central/rev/0a2eba79c24300ce0539f91c1bebac2e75264e58/toolkit/components/extensions/ExtensionCommon.jsm#2548,2550-2553
Consequently, later registrations are missed.
Reporter | ||
Comment 1•2 years ago
|
||
When this bug is fixed, make sure to also add test coverage for the scenario of removing a listener and/or re-adding a listener.
Comment 2•2 years ago
|
||
We might be able to address this by modifying what "keys" is.
keys = [persistentId++, uneval(args)]
Along with touchups in other places where we access keys.
Comment 3•2 years ago
|
||
In the short term, we could document that only the first listener of a type is persisted.
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 5•1 year ago
|
||
Updated•1 year ago
|
Assignee | ||
Comment 6•1 year ago
|
||
Not actually related to the change that the bug is tracking, but I did notice this an unexpected error
that was spamming the logs while I was investigating failures from one of the event pages / persistent
listeners tests as part of the rework of the persistent listeners data written in the XPIStates JSONFile.
Depends on D171769
Pushed by luca.greco@alcacoop.it: https://hg.mozilla.org/integration/autoland/rev/de0be12a7f42 Support persisting and priming more then one listener for the same event and arguments. r=robwu https://hg.mozilla.org/integration/autoland/rev/7e975ec3f0a3 Avoid logspam due to xpcshell tests without any system addon set throwing from cleanupStatingDir. r=willdurand
Comment 8•1 year ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/de0be12a7f42
https://hg.mozilla.org/mozilla-central/rev/7e975ec3f0a3
Reporter | ||
Comment 9•1 year ago
|
||
Please mention this in the "Firefox 113 for developers" MDN article.
Comment 10•1 year ago
|
||
Release notes added in #25779
Description
•