Bug 1905505 - Remove unnecessary resetIdleOnEvent from child modules a=dmeehan

This patch updates every use of EventManager in child/ext-*.js files
that can referenced from extension contexts of envType "addon_child".

Pre patch, these could trigger "background-script-reset-idle" and
result in triggering "background-script-reset-idle" in the parent
despite the background being stopped, and consequently trigger the
reported bug. The previous patch fixes the negative consequence of this
unexpected event, this patch fixes an underlying cause by removing the
triggers.

Forcing resetIdleOnEvent to false does not have any negative impact on
these modules, because all of these events are dependencies of an
EventManager in the parent, which already activates the functionality
associated with resetIdleOnEvent=true.

To minimize the likelihood of affecting unit tests, this patch keeps the
EventManager of test.onMessage at resetIdleOnEvent=true as before, and
defers to bug 1901294 for changing it to false.

Original Revision: https://phabricator.services.mozilla.com/D215298

Differential Revision: https://phabricator.services.mozilla.com/D216987
This commit is contained in:
Rob Wu 2024-07-20 12:21:06 +00:00
parent 7c763e3cbc
commit 029d6f68c3
5 changed files with 12 additions and 0 deletions

View file

@ -274,6 +274,8 @@ this.menusInternal = class extends ExtensionAPI {
onClicked: new EventManager({
context,
name: "menus.onClicked",
// Parent event already resets idle if needed, no need to do it here.
resetIdleOnEvent: false,
register: fire => {
let listener = (info, tab) => {
withHandlingUserInput(context.contentWindow, () =>

View file

@ -13,6 +13,8 @@ this.omnibox = class extends ExtensionAPI {
onInputChanged: new EventManager({
context,
name: "omnibox.onInputChanged",
// Parent event already resets idle if needed, no need to do it here.
resetIdleOnEvent: false,
register: fire => {
let listener = (text, id) => {
fire.asyncWithoutClone(text, suggestions => {

View file

@ -142,6 +142,8 @@ this.storage = class extends ExtensionAPI {
return new EventManager({
context,
name: onChangedName,
// Parent event already resets idle if needed, no need to do it here.
resetIdleOnEvent: false,
register: fire => {
let onChanged = (data, area) => {
let changes = new context.cloneScope.Object();

View file

@ -354,6 +354,10 @@ this.test = class extends ExtensionAPI {
onMessage: new TestEventManager({
context,
name: "test.onMessage",
// TODO bug 1901294: Set resetIdleOnEvent=false. Tests should not be
// relying on test.onMessage for its side effect of resetting the test
// but set extensions.background.idle.timeout instead.
resetIdleOnEvent: true,
register: fire => {
let handler = (event, ...args) => {
fire.async(...args);

View file

@ -101,6 +101,8 @@ this.webRequest = class extends ExtensionAPI {
onAuthRequired: new EventManager({
context,
name: "webRequest.onAuthRequired",
// Parent event already resets idle if needed, no need to do it here.
resetIdleOnEvent: false,
register: (fire, filter, extra) => {
const listener = details => {
// NOTE: asyncBlocking and blocking are mutually exclusive