->add_listener

my $l = $driver->add_listener(
    'Page.domContentEventFired',
    sub {
        warn "The DOMContent event was fired";
    },
);

# ...

undef $l; # stop listening

Adds a callback for the given event name. The callback will be removed once the return value goes out of scope.

->remove_listener

$driver->remove_listener($l);

Explicitly remove a listener.