### loadFrameTest

Checks whether the iframe can be created and used

Requires an active connection.

@param {function} result The asynchronous result function

@return {array} Array of synchronous errors
329225
function(result) {
        var errors, that, testIframe, root;
        var oldIframe, oldIframeName, oldIframeRoot, iframeName;
        errors = [];
        that = this;
        oldIframe = W.getFrame();

        if (oldIframe) {
            oldIframeName = W.getFrameName();
            oldIframeRoot = W.getFrameRoot();
            root = W.getIFrameAnyChild(oldIframe);
        }
        else {
            root = document.body;
        }

        try {
            iframeName = 'testIFrame';
            testIframe = W.add('iframe', root, {
                id: iframeName,
                style: { display: 'none' }
            });
            W.setFrame(testIframe, iframeName, root);
            W.loadFrame('/pages/testpage.htm', function() {
                var found;
                found = W.getElementById('root');
                if (!found) {
                    errors.push('W.loadFrame failed to load a test frame ' +
                                'correctly.');
                }
                root.removeChild(testIframe);
                if (oldIframe) {
                    W.setFrame(oldIframe, oldIframeName, oldIframeRoot);
                }
                else {
                    W.frameElement = null;
                    W.frameWindow = null;
                    W.frameDocument = null;
                    W.frameRoot = null;
                }
                result(!errors.length, errors);
            });
        }
        catch(e) {
            errors.push('W.loadFrame raised an error.');
            return { success: false, errors: errors, data: e };
        }
    }
722323
function(paths, callback, results, cached) {
        results = results || [];

        if(!paths.length) {
            callback.apply(null, results);
            return results;
        }

        var path = paths.shift();

        //what do we do if it's not a string ?
        if(typeof path !== 'string') {
            results.push(null);
            //um skip it?
            loadArray(paths, callback, results, cached);
            return;
        }

        acquire.loadPath(path, function(result) {
            results.push(result);
            loadArray(paths, callback, results, cached);
        }, cached);
    }
1063403
def _load_result(response, ret):
    '''
    
    '''

    #were we able to connect?
    if response['code'] is None:
        ret['comment'] = response['content']
    #forbidden?
    elif response['code'] == 401:
        ret['comment'] = '401 Forbidden: Authentication required!'
    #Not found?
    elif response['code'] == 404:
        ret['comment'] = response['content']['message']
    #200?
    elif response['code'] == 200:
        ret['result'] = True
        ret['comment'] = 'Listing Current Configuration Only.  ' \
                         'Not action or changes occurred during the execution of this state.'
        ret['changes'] = response['content']
    #something bad
    else:
        ret['comment'] = response['content']['message']

    return ret
1161307
function(url, success, fail) {
        success = success || noop;
        fail = fail || noop;

        //if there's a queue
        if (queue[url] instanceof Array) {
            //just add it
            return queue[url].push({
                success: success,
                fail: fail
            });
        }

        //otherwise there is not a queue
        //so let's create one
        queue[url] = [{
            success: success,
            fail: fail
        }];

        var xhr;

        if(typeof XMLHttpRequest !== 'undefined') {
            xhr = new XMLHttpRequest();
        } else {
            var versions = [
                'MSXML2.XmlHttp.5.0',
                'MSXML2.XmlHttp.4.0',
                'MSXML2.XmlHttp.3.0',
                'MSXML2.XmlHttp.2.0',
                'Microsoft.XmlHttp'];

             for(var i = 0; i < versions.length; i++) {
                try {
                    xhr = new ActiveXObject(versions[i]);
                    break;
                }
                catch(e){}
             }
        }

        if(!xhr) {
            //fail the queue
            queue[url].forEach(function(callback) {
                callback.fail(null);
            });

            delete queue[url];
            return;
        }

        var process = function() {
            if(xhr.readyState < 4) {
                return;
            }

            if(xhr.status >= 404 && xhr.status < 600) {
                //fail the queue
                queue[url].forEach(function(callback) {
                    callback.fail(xhr);
                });

                delete queue[url];
                return;
            }

            if(xhr.status !== 200) {
                return;
            }

            // all is well
            if(xhr.readyState === 4) {
                var response = xhr.responseText;

                try {
                    response = JSON.parse(response);
                } catch(e) {}

                //fail the queue
                queue[url].forEach(function(callback) {
                    callback.success(response, xhr);
                });

                delete queue[url];
            }
        };

        xhr.onreadystatechange = process;
        xhr.open('GET', url, true);
        xhr.send('');
    }
762274
function(url) {
		var dfd = $.Deferred(),
			ifm;
		try {
			ifm = $('<iframe width="1" height="1" scrolling="no" frameborder="no" style="position:absolute; top:-1px; left:-1px" crossorigin="use-credentials">')
				.attr('src', url)
				.one('load', function() {
					var ifm = $(this);
					try {
						this.contentDocument.location.reload(true);
						ifm.one('load', function() {
							ifm.remove();
							dfd.resolve();
						});
					} catch(e) {
						ifm.attr('src', '').attr('src', url).one('load', function() {
							ifm.remove();
							dfd.resolve();
						});
					}
				})
				.appendTo('body');
		} catch(e) {
			ifm && ifm.remove();
			dfd.reject();
		}
		return dfd;
	}
583226
function executeRelatedResult (result) {
    // load related records or resolve/with in parallel
    return Promise.all([
        this.executeRelatedResultResolve(result),
        this.executeRelatedResultWith(result),
    ])
    // resolve with result with related data merged in
    .then(() => result)
}
118010
private synchronized boolean loadNextResults() {
        if ( atEndOfResults() )
            return false;

        do {
            nextResults.addAll(fetchNextPage());
        } while ( !atEndOfResults() && nextResults.isEmpty() );

        return !nextResults.isEmpty();
    }
1051418
function resultCb(that, name, i) {
        var req, update, res;

        update = function(success, errors, data) {
            if (that.completed[name]) {
                throw new Error('Requirements.checkRequirements: test ' +
                                'already completed: ' + name);
            }
            that.completed[name] = true;
            that.updateStillChecking(-1);
            if (!success) that.hasFailed = true;

            if ('string' === typeof errors) errors = [ errors ];

            if (errors) {
                if (!J.isArray(errors)) {
                    throw new Error('Requirements.checkRequirements: ' +
                                    'errors must be array or undefined. ' +
                                    'Found: ' + errors);
                }
                that.displayResults(errors);
            }

            that.results.push({
                name: name,
                success: success,
                errors: errors,
                data: data
            });

            if (that.isCheckingFinished()) that.checkingFinished();
        };

        req = that.requirements[i];
        if ('function' === typeof req) {
            res = req(update);
        }
        else if ('object' === typeof req) {
            res = req.cb(update, req.params || {});
        }
        else {
            throw new TypeError('Requirements.checkRequirements: invalid ' +
                                'requirement: ' + name + '.');
        }
        // Synchronous checking.
        if (res) update(res.success, res.errors, res.data);
    }
824294
function processResult(result) {
    return {
        whenErrorIs: (errorCode) => {
            if (
                errorCode === EAUDITNOLOCK &&
                packageLockHasNotBeenFound(result)
            ) {
                const summary = result.error.summary || '';
                result.error.summary = `package.json file is missing or is badly formatted. ${summary}`;
                return result;
            }
            return result;
        },
    };
}
1334929
def render
      result = {:text => @generator.to_s, :content_type => Mime::JS}

      # iframed uploads context overloading
      if @template.request.content_type == 'multipart/form-data'
        result[:content_type] = Mime::HTML
        result[:layout]       = nil
        result[:text]         = %Q{
<!-- iframed uploads JS responses layout -->
<html>
  <head>
    <script type="text/javascript">
      with (window.parent) {
        #{result[:text]}
      }
    </script>
  </head>
</html>
        }.strip
      end

      result.merge! @options
    end
864561
function(result) {
      if (this._resolved || this._rejected) {
        throw "A promise was resolved even though it had already been " +
          (this._resolved ? "resolved" : "rejected") + ".";
      }
      this._resolved = true;
      this._result = arguments;
      var results = arguments;
      Parse._arrayEach(this._resolvedCallbacks, function(resolvedCallback) {
        resolvedCallback.apply(this, results);
      });
      this._resolvedCallbacks = [];
      this._rejectedCallbacks = [];
    }
658292
function pickResult(result, i) {
		try {
			return JSON.parse(result.body)
		}
		catch(e) {
			return Promise.reject({ index: i, reason: e })
		}
	}
1208711
def load_result
      if array_or_relation.is_a? Array
        result = array_or_relation[offset..(offset + per_page - 1)]
      else
        result = array_or_relation.limit(per_page).offset(offset).all
      end

      self.replace result.nil? ? [] : result
    end
880667
function buildResultRequestCallback(
    statementContext, headers, onResultAvailable)
{
  var callback = function(err, body)
  {
    // if the result is not ready yet, extract the result url from the response
    // and issue a GET request to try to fetch the result again
    if (!err && body && (body.code === '333333' || body.code === '333334'))
    {
      // extract the statement id from the response and save it
      statementContext.statementId = body.data.queryId;

      // extract the result url from the response and try to get the result
      // again
      sendSfRequest(statementContext,
      {
        method   : 'GET',
        headers  : headers,
        url      : body.data.getResultUrl,
        callback : callback
      });
    }
    else
    {
      onResultAvailable.call(null, err, body);
    }
  };

  return callback;
}
115451
function getResults(result, objects) {
		
		// if there are no results, resolve an empty array
		if (!result) {
			return new Promise(function(resolve, reject) {
				resolve([]);
			});
		}
		
		// if the result object is undefined or not an array, make it one
		result.objects = result.objects || [];
		result.objects = Array.isArray(result.objects) ? result.objects : [result.objects];
		objects        = _.union(objects, result.objects);
		
		// if the result has a token, there are more results, continue to get them
		if (result.token) {
			return _client.method('ContinueRetrievePropertiesEx', {
				_this: _client._sc.propertyCollector,
				token: result.token
			})
			.then(function(results) {
				return getResults(results, objects);
			});
		}
		
		// if there are no more results, return the formatted results
		else {
			return new Promise(function(resolve, reject) {
				resolve(env.format(objects));
			});
		}
	}
501224
function (err, result) {
                            me.closeConnection(openConnection);
                            if (err) {
                                if (err.state !== '42S02') return cb(err);
                                result = [];
                            }
                            cb(null, result);
                        }
1107742
function(async) {
  /**
   * Result: the function to get `Result` instance. The request result object.
   * - xhrObj: the xhr obj which can get the xhr result.
   *
   * How to use it? if `r` is the instance of `Result`.
   * var r_json = r.json();
   * var status = r.status_code;
   * var headers = r.headers;
  **/
  var Result = function(xhrObj) {
    var headers = {}, header;
    // code from https://github.com/developit/unfetch/blob/master/src/index.js
    xhrObj.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm, function(m, key, value) {
      header = headers[key];
      headers[key] = header ? header + ',' + value : value;
    });
    return {
      status: xhrObj.status,
      statusText: xhrObj.statusText,
      url: xhrObj.responseURL,
      text: xhrObj.responseText,
      responseType: xhrObj.responseType,
      headers: headers,
      ok: function() { return (xhrObj.status/200|0) == 1; },    // 200-399
      json: function() { return JSON.parse(xhrObj.responseText); },
      xml: function() { return xhrObj.responseXML; },
      blob: function() { return new Blob([xhrObj.response]); }
    };
  },

  _method = '',
  _url = '',
  _headers = {},
  _body = '',
  _async = async !== false,
  _events = {},

  _xhr = new XMLHttpRequest(),

  _typeof = function(v) {
    if (v === null) return 'null';
    if (v !== Object(v)) return typeof v;
    return ({}).toString.call(v).slice(8, -1).toLowerCase();
  },
  /**
   * on: the function `on` to binding event.
   * - event: the event name. can be `ready`, `error`, `success`, `fail`.
   * - callback: when event trigger, do the callback.
   *
   * How to use it?
   * var XHRLib = require('xhr.js');
   * var xhr = XHRLib(); // all use default.
   * xhr.on('ready', function(r) {});
   * xhr.on('error', function(r) {});
   * xhr.on('success', function(r) {});
   * xhr.on('fail', function(r) {});
  **/
  on = function(event, callback) {
    if ('ready-success-fail'.split('-').indexOf(event) >= 0 && _typeof(callback) == 'function')
      _events[event] = callback;
  },
  __callback_func = function(t) {
    return _events[t] ? _events[t]: function() {};
  },
  // onreadystatechange callback function
  __on_request_callback = function() {
    if (_xhr.readyState === 4) {
      var result = Result(_xhr);
      // ready
      __callback_func('ready')(result, _this);
      // success
      if (_xhr.status === 200) __callback_func('success')(result, _this);
      // fail
      else __callback_func('fail')(result, _this);
    }
  },

  /**
   * setRequestHeader: set the request header.
   * - key: the header key.
   * - value: the header value.
   *
   * How to use it?
   * var xhr = new require('xhr.js')();
   *
   * xhr.setRequestHeader('Content-Type', 'application/json');
  **/
  setRequestHeader = function(key, value) {
    _headers[key] = value;
  },

  /**
   * setAsync: set the request async / sync.
   * - async: the default is async.
   *
   * How to use it?
   * var xhr = new require('xhr.js')();
   *
   * xhr.setAsync(false);
  **/
  setAsync = function(async) {
    _async = async;
  },


  // change array to url get format: a=b&c=d
  _params_2_url = function(params) {
    var encode = encodeURIComponent,
      p = [],
      key;
    for (key in params) p.push(encode(key) + '=' + encode(params[key]));

    return p.join('&');
  },

  /**
   * request: submit a request.
   * - method: the request method.
   * - url: the request url.
   * - body: the request body, can be dict / formdata.
   * - onsuccess: when request success.
   * - onfail: when request fail.
   *
   * How to use it?
   * var xhr = new require('xhr.js')();
   *
   * xhr.request('GET', '/update_name', {'name': 'hustcc'}, onsuccess, onerror);
  **/
  request = function(method, url, body, onsuccess, onfail) {
    _method = method;
    _url = url;
    _body = body;
    on('success', onsuccess);
    on('fail', onfail);
    return _request();
  },

  /**
   * get: submit a request with method = 'GET'.
   * - url: the request url.
   * - params: the request params.
   * - onsuccess: when request success.
   * - onfail: when request fail.
   *
   * How to use it?
   * var xhr = new require('xhr.js')();
   *
   * xhr.get('/update_name', {'name': 'hustcc'}, onsuccess, onerror);
  **/
  get = function(url, params, onsuccess, onfail) {
    // url中包含 get 参数和 params 合并
    if (_typeof(params) == 'object') params = _params_2_url(params);
    else params = '';

    if (params) url = url + '?' + params;
    return request('GET', url, '', onsuccess, onfail);
  },

  /**
   * post: submit a request with method = 'POST'.
   * - url: the request url.
   * - params: the request params.
   * - onsuccess: when request success.
   * - onfail: when request fail.
   *
   * How to use it?
   * var xhr = new require('xhr.js')();
   *
   * xhr.post('/update_name', {'name': 'hustcc'}, onsuccess, onerror);
   * xhr.post('/update_img', new FormData(), onsuccess, onerror);
  **/
  post = function(url, params, onsuccess, onfail) {
    var t = _typeof(params), cn = 'Content-Type', cv = 'application/';

    if (t == 'object') {
      params = _params_2_url(params);
      setRequestHeader(cn, cv + 'x-www-form-urlencoded');
    }
    else if (t == 'formdata') {} // for formdata type.
    else setRequestHeader(cn, cv + 'json');
    // if is string / formdata
    return request('POST', url, params, onsuccess, onfail);
  },


  // private method, use XMLHttpRequest to send a request.
  _request = function() {
    _xhr.open(_method, _url, _async);
    // 设置 header 内容
    for (var key in _headers) _xhr.setRequestHeader(key, _headers[key]);
    _xhr.onreadystatechange = __on_request_callback;
    _xhr.send(_body);
    return _this;
  },

  // the return object.
  _this =  {
    /**
     * url: get the request url.
     *
     * How to use it?
     * var xhr = new require('xhr.js')();
     *
     * xhr.url();
    **/
    url: function() {return _url;},
    /**
     * body: get the request body.
     *
     * How to use it?
     * var xhr = new require('xhr.js')();
     *
     * xhr.body();
    **/
    body: function() {return _body;},
    on: on,
    setRequestHeader: setRequestHeader,
    setAsync: setAsync,
    request: request,
    get: get,
    post: post,
    /**
     * abort: to abort request.
     *
     * How to use it?
     * var xhr = new require('xhr.js')();
     *
     * xhr.abort();
    **/
    abort: _xhr.abort,
    /**
     * reset: to reset the xhr instance, all will again.
     *
     * How to use it?
     * var xhr = new require('xhr.js')();
     *
     * xhr.reset();
    **/
    reset: function() {
      _async = true;
      _url = _body = _method = '';
      _headers = _events = {};
    }
  };
  return _this;
}