B2G/gecko/browser/devtools/webconsole/webconsole.js
/**
   * The JavaScript evaluation response handler.
   *
   * @private
   * @param nsIDOMElement [aAfterNode]
   *        Optional DOM element after which the evaluation result will be
   *        inserted.
   * @param function [aCallback]
   *        Optional function to invoke when the evaluation result is added to
   *        the output.
   * @param object aResponse
   *        The message received from the server.
   */
The JavaScript evaluation response handler.
@private
@param nsIDOMElement [aAfterNode]
Optional DOM element after which the evaluation result will be
inserted.
@param function [aCallback]
Optional function to invoke when the evaluation result is added to
the output.
@param object aResponse
The message received from the server.
The JavaScript evaluation response handler . @private @param nsIDOMElement [ aAfterNode ] Optional DOM element after which the evaluation result will be inserted . @param function [ aCallback ] Optional function to invoke when the evaluation result is added to the output . @param object aResponse The message received from the server .
function JST__executeResultCallback(aAfterNode, aCallback, aResponse)
  {
    if (!this.hud) {
      return;
    }
    let errorMessage = aResponse.errorMessage;
    let result = aResponse.result;
    let inspectable = result && typeof result == "object" && result.inspectable;
    let helperResult = aResponse.helperResult;
    let helperHasRawOutput = !!(helperResult || {}).rawOutput;
    let resultString =
      WebConsoleUtils.objectActorGripToString(result,
                                              !helperHasRawOutput);
    if (helperResult && helperResult.type) {
      switch (helperResult.type) {
        case "clearOutput":
          this.clearOutput();
          break;
        case "inspectObject":
          this.handleInspectObject(helperResult.input, helperResult.object);
          break;
        case "error":
          try {
            errorMessage = l10n.getStr(helperResult.message);
          }
          catch (ex) {
            errorMessage = helperResult.message;
          }
          break;
        case "help":
          this.hud.owner.openLink(HELP_URL);
          break;
      }
    }
    if (!errorMessage && result && typeof result == "object" &&
        result.type == "undefined" &&
        helperResult && !helperHasRawOutput) {
      aCallback && aCallback();
      return;
    }
    if (aCallback) {
      let oldFlushCallback = this.hud._flushCallback;
      this.hud._flushCallback = function() {
        aCallback();
        oldFlushCallback && oldFlushCallback();
        this.hud._flushCallback = oldFlushCallback;
      }.bind(this);
    }
    let node;
    if (errorMessage) {
      node = this.writeOutput(errorMessage, CATEGORY_OUTPUT, SEVERITY_ERROR,
                              aAfterNode, aResponse.timestamp);
    }
    else if (inspectable) {
      node = this.writeOutputJS(resultString,
                                this._evalOutputClick.bind(this, aResponse),
                                aAfterNode, aResponse.timestamp);
    }
    else {
      node = this.writeOutput(resultString, CATEGORY_OUTPUT, SEVERITY_LOG,
                              aAfterNode, aResponse.timestamp);
    }
    if (result && typeof result == "object" && result.actor) {
      node._objectActors = [result.actor];
    }
  }
function JST__executeResultCallback ( aAfterNode , aCallback , aResponse ) { if ( ! this . hud ) { return ; } let errorMessage = aResponse . errorMessage ; let result = aResponse . result ; let inspectable = result && typeof result == "object" && result . inspectable ; let helperResult = aResponse . helperResult ; let helperHasRawOutput = ! ! ( helperResult || { } ) . rawOutput ; let resultString = WebConsoleUtils . objectActorGripToString ( result , ! helperHasRawOutput ) ; if ( helperResult && helperResult . type ) { switch ( helperResult . type ) { case "clearOutput" : this . clearOutput ( ) ; break ; case "inspectObject" : this . handleInspectObject ( helperResult . input , helperResult . object ) ; break ; case "error" : try { errorMessage = l10n . getStr ( helperResult . message ) ; } catch ( ex ) { errorMessage = helperResult . message ; } break ; case "help" : this . hud . owner . openLink ( HELP_URL ) ; break ; } } if ( ! errorMessage && result && typeof result == "object" && result . type == "undefined" && helperResult && ! helperHasRawOutput ) { aCallback && aCallback ( ) ; return ; } if ( aCallback ) { let oldFlushCallback = this . hud . _flushCallback ; this . hud . _flushCallback = function ( ) { aCallback ( ) ; oldFlushCallback && oldFlushCallback ( ) ; this . hud . _flushCallback = oldFlushCallback ; } . bind ( this ) ; } let node ; if ( errorMessage ) { node = this . writeOutput ( errorMessage , CATEGORY_OUTPUT , SEVERITY_ERROR , aAfterNode , aResponse . timestamp ) ; } else if ( inspectable ) { node = this . writeOutputJS ( resultString , this . _evalOutputClick . bind ( this , aResponse ) , aAfterNode , aResponse . timestamp ) ; } else { node = this . writeOutput ( resultString , CATEGORY_OUTPUT , SEVERITY_LOG , aAfterNode , aResponse . timestamp ) ; } if ( result && typeof result == "object" && result . actor ) { node . _objectActors = [ result . actor ] ; } }
The JavaScript evaluation response handler.
The JavaScript evaluation response handler .
// Hide undefined results coming from JSTerm helper functions.