B2G/gecko/testing/marionette/marionette-elements.js
/**
   * Convert values to primitives that can be transported over the Marionette
   * JSON protocol.
   * 
   * @param object val
   *        object to be wrapped
   *
   * @return object
   *        Returns a JSON primitive or Object
   */
Convert values to primitives that can be transported over the Marionette
JSON protocol.

@param object val
object to be wrapped

@return object
Returns a JSON primitive or Object
Convert values to primitives that can be transported over the Marionette JSON protocol . @param object val object to be wrapped @return object Returns a JSON primitive or Object
function EM_wrapValue(val) {
    let result;
    switch(typeof(val)) {
      case "undefined":
        result = null;
        break;
      case "string":
      case "number":
      case "boolean":
        result = val;
        break;
      case "object":
        if (Object.prototype.toString.call(val) == '[object Array]') {
          result = [];
          for (let i in val) {
            result.push(this.wrapValue(val[i]));
          }
        }
        else if (val == null) {
          result = null;
        }
        else if (val.nodeType == 1) {
          result = {'ELEMENT': this.addToKnownElements(val)};
        }
        else {
          result = {};
          for (let prop in val) {
            result[prop] = this.wrapValue(val[prop]);
          }
        }
        break;
    }
    return result;
  }
function EM_wrapValue ( val ) { let result ; switch ( typeof ( val ) ) { case "undefined" : result = null ; break ; case "string" : case "number" : case "boolean" : result = val ; break ; case "object" : if ( Object . prototype . toString . call ( val ) == '[object Array]' ) { result = [ ] ; for ( let i in val ) { result . push ( this . wrapValue ( val [ i ] ) ) ; } } else if ( val == null ) { result = null ; } else if ( val . nodeType == 1 ) { result = { 'ELEMENT' : this . addToKnownElements ( val ) } ; } else { result = { } ; for ( let prop in val ) { result [ prop ] = this . wrapValue ( val [ prop ] ) ; } } break ; } return result ; }
Convert values to primitives that can be transported over the Marionette
 JSON protocol.
Convert values to primitives that can be transported over the Marionette JSON protocol .