       // popstate doesn't bubble, as such use capturing phase
          popstate: { capture: true, mozSystemGroup: true },

          click: {},
          dblclick: {},
          unload: { capture: true, createActor: false },
        },
      },

      allFrames: true,
      includeChrome: true,
    });

    eventsActorRegistered = true;
  } catch (e) {
    if (e.name === "NotSupportedError") {
      lazy.logger.warn(`MarionetteEvents actor is already registered!`);
    } else {
      throw e;
    }
  }
}

/**
 * Enable MarionetteEvents actors to start forwarding page load events from the
 * child actor to the parent actor. Register the MarionetteEvents actor if necessary.
 */
export function enableEventsActor() {
  // sharedData is replicated across processes and will be checked by
  // MarionetteEventsChild before forward events to the parent actor.
  Services.ppmm.sharedData.set("MARIONETTE_EVENTS_ENABLED", true);
  // Request to immediately flush the data to the content processes to avoid races.
  Services.ppmm.sharedData.flush();

  registerEventsActor();
}

/**
 * Disable MarionetteEvents actors to stop forwarding page load events from the
 * child actor to the parent actor.
 */
export function disableEventsActor() {
  Services.ppmm.sharedData.set("MARIONETTE_EVENTS_ENABLED", false);
  Services.ppmm.sharedData.flush();
}
PK