onJsonMessage_(jsonMessage) {
    let message = JSON.parse(jsonMessage);
    if (message.hasOwnProperty('id')) {
      if (!this.pendingCommands_.has(message.id))
        throw new Error('Unrecognized id:' + jsonMessage);
      if (message.hasOwnProperty('error'))
        this.pendingCommands_.get(message.id).reject(message.error);
      else
        this.pendingCommands_.get(message.id).resolve(message.result);
      this.pendingCommands_.delete(message.id);
    } else {
      if (!message.hasOwnProperty('method') ||
          !message.hasOwnProperty('params')) {
        throw new Error('Bad message:' + jsonMessage);
      }
      const method = message['method'];
      const params = message['params'];
      this.allEventsListeners_.forEach(function(listener) {
        listener({method, params});
      });
      if (this.eventListeners_.has(method)) {
        this.eventListeners_.get(method).forEach(function(listener) {
          listener(params);
        });
      }
    }
  }
/**
   * @param {string} jsonMessage A string containing a JSON DevTools protocol
   *     message.
   * @private
   */
@param {string} jsonMessage A string containing a JSON DevTools protocol
message.
@private
@param { string } jsonMessage A string containing a JSON DevTools protocol message . @private
onJsonMessage_(jsonMessage) {
    let message = JSON.parse(jsonMessage);
    if (message.hasOwnProperty('id')) {
      if (!this.pendingCommands_.has(message.id))
        throw new Error('Unrecognized id:' + jsonMessage);
      if (message.hasOwnProperty('error'))
        this.pendingCommands_.get(message.id).reject(message.error);
      else
        this.pendingCommands_.get(message.id).resolve(message.result);
      this.pendingCommands_.delete(message.id);
    } else {
      if (!message.hasOwnProperty('method') ||
          !message.hasOwnProperty('params')) {
        throw new Error('Bad message:' + jsonMessage);
      }
      const method = message['method'];
      const params = message['params'];
      this.allEventsListeners_.forEach(function(listener) {
        listener({method, params});
      });
      if (this.eventListeners_.has(method)) {
        this.eventListeners_.get(method).forEach(function(listener) {
          listener(params);
        });
      }
    }
  }
onJsonMessage_ ( jsonMessage ) { let message = JSON . parse ( jsonMessage ) ; if ( message . hasOwnProperty ( 'id' ) ) { if ( ! this . pendingCommands_ . has ( message . id ) ) throw new Error ( 'Unrecognized id:' + jsonMessage ) ; if ( message . hasOwnProperty ( 'error' ) ) this . pendingCommands_ . get ( message . id ) . reject ( message . error ) ; else this . pendingCommands_ . get ( message . id ) . resolve ( message . result ) ; this . pendingCommands_ . delete ( message . id ) ; } else { if ( ! message . hasOwnProperty ( 'method' ) || ! message . hasOwnProperty ( 'params' ) ) { throw new Error ( 'Bad message:' + jsonMessage ) ; } const method = message [ 'method' ] ; const params = message [ 'params' ] ; this . allEventsListeners_ . forEach ( function ( listener ) { listener ( { method , params } ) ; } ) ; if ( this . eventListeners_ . has ( method ) ) { this . eventListeners_ . get ( method ) . forEach ( function ( listener ) { listener ( params ) ; } ) ; } } }
@param {string} jsonMessage A string containing a JSON DevTools protocol
     message.
@param { string } jsonMessage A string containing a JSON DevTools protocol message .