Class: WebElementEventTarget

WebElementEventTarget(messageManagerFn)

The EventTarget for web elements can be used to observe DOM events in the content document.

A caveat of the current implementation is that it is only possible to listen for top-level window global events.

It needs to be backed by a ContentEventObserverService in a content frame script.

Usage:


    let observer = new WebElementEventTarget(messageManager);
    await new Promise(resolve => {
      observer.addEventListener("visibilitychange", resolve, {once: true});
      chromeWindow.minimize();
    });

Constructor

new WebElementEventTarget(messageManagerFn)

Parameters:
Name Type Description
messageManagerFn function

Message manager to the current browser.

Source:

Methods

addEventListener(type, listener, onceopt)

Register an event handler of a specific event type from the content frame.

Parameters:
Name Type Attributes Description
type string

Event type to listen for.

listener EventListener

Object which receives a notification (a BareEvent) when an event of the specified type occurs. This must be an object implementing the EventListener interface, or a JavaScript function.

once boolean <optional>

Indicates that the listener should be invoked at most once after being added. If true, the listener would automatically be removed when invoked.

Source:

removeEventListener(type, listener)

Removes an event listener.

Parameters:
Name Type Description
type string

Type of event to cease listening for.

listener EventListener

Event handler to remove from the event target.

Source: