on(event: string, runOnPhantom: boolean = false, listener: Function, ...args: any[]) {
    let mustRunOnPhantom;
    let callback;
    let params;

    if (typeof runOnPhantom === 'function') {
      mustRunOnPhantom = false;
      params = [listener, ...args];
      callback = runOnPhantom.bind(this);
    } else {
      params = args;
      mustRunOnPhantom = runOnPhantom;
      callback = mustRunOnPhantom ? listener : listener.bind(this);
    }

    return this.$phantom.on(event, this.target, mustRunOnPhantom, callback, params);
  }
Add an event listener to the page on phantom

@param event The name of the event (Ej. onResourceLoaded)
@param [runOnPhantom=false] Indicate if the event must run on the phantom runtime or not
@param listener The event listener. When runOnPhantom=true, this listener code would be
run on phantom, and thus, all the closure info wont work
@returns {*}