B2G/gecko/testing/marionette/marionette-elements.js
/**
   * Convert any ELEMENT references in 'args' to the actual elements
   *
   * @param object args
   *        Arguments passed in by client
   * @param nsIDOMWindow win
   *        The window that contains the elements
   *
   * @returns object
   *        Returns the objects passed in by the client, with the
   *        reference IDs replaced by the actual elements.
   */
Convert any ELEMENT references in 'args' to the actual elements
@param object args
Arguments passed in by client
@param nsIDOMWindow win
The window that contains the elements

@returns object
Returns the objects passed in by the client, with the
reference IDs replaced by the actual elements.
Convert any ELEMENT references in ' args ' to the actual elements @param object args Arguments passed in by client @param nsIDOMWindow win The window that contains the elements @returns object Returns the objects passed in by the client with the reference IDs replaced by the actual elements .
function EM_convertWrappedArguments(args, win) {
    let converted;
    switch (typeof(args)) {
      case 'number':
      case 'string':
      case 'boolean':
        converted = args;
        break;
      case 'object':
        if (args == null) {
          converted = null;
        }
        else if (Object.prototype.toString.call(args) == '[object Array]') {
          converted = [];
          for (let i in args) {
            converted.push(this.convertWrappedArguments(args[i], win));
          }
        }
        else if (typeof(args['ELEMENT'] === 'string') &&
                 args.hasOwnProperty('ELEMENT')) {
          converted = this.getKnownElement(args['ELEMENT'],  win);
          if (converted == null)
            throw new ElementException("Unknown element: " + args['ELEMENT'], 500, null);
        }
        else {
          converted = {};
          for (let prop in args) {
            converted[prop] = this.convertWrappedArguments(args[prop], win);
          }
        }
        break;
    }
    return converted;
  }
function EM_convertWrappedArguments ( args , win ) { let converted ; switch ( typeof ( args ) ) { case 'number' : case 'string' : case 'boolean' : converted = args ; break ; case 'object' : if ( args == null ) { converted = null ; } else if ( Object . prototype . toString . call ( args ) == '[object Array]' ) { converted = [ ] ; for ( let i in args ) { converted . push ( this . convertWrappedArguments ( args [ i ] , win ) ) ; } } else if ( typeof ( args [ 'ELEMENT' ] === 'string' ) && args . hasOwnProperty ( 'ELEMENT' ) ) { converted = this . getKnownElement ( args [ 'ELEMENT' ] , win ) ; if ( converted == null ) throw new ElementException ( "Unknown element: " + args [ 'ELEMENT' ] , 500 , null ) ; } else { converted = { } ; for ( let prop in args ) { converted [ prop ] = this . convertWrappedArguments ( args [ prop ] , win ) ; } } break ; } return converted ; }
Convert any ELEMENT references in 'args' to the actual elements
 @param object args
        Arguments passed in by client
 @param nsIDOMWindow win
        The window that contains the elements
Convert any ELEMENT references in ' args ' to the actual elements @param object args Arguments passed in by client @param nsIDOMWindow win The window that contains the elements