lib/webdriver/promise.js
function resolve(newState, newValue) {
    if (webdriver.promise.Deferred.State_.PENDING !== state) {
      return;
    }

    if (newValue === self) {
      // See promise a+, 2.3.1
      // http://promises-aplus.github.io/promises-spec/#point-48
      throw TypeError('A promise may not resolve to itself');
    }

    state = webdriver.promise.Deferred.State_.BLOCKED;

    if (webdriver.promise.isPromise(newValue)) {
      var onFulfill = goog.partial(notifyAll, newState);
      var onReject = goog.partial(
          notifyAll, webdriver.promise.Deferred.State_.REJECTED);
      if (newValue instanceof webdriver.promise.Deferred) {
        newValue.then(onFulfill, onReject);
      } else {
        webdriver.promise.asap(newValue, onFulfill, onReject);
      }

    } else {
      notifyAll(newState, newValue);
    }
  }
function resolve(newState, newValue) {
    if (webdriver.promise.Deferred.State_.PENDING !== state) {
      return;
    }

    if (newValue === self) {
      // See promise a+, 2.3.1
      // http://promises-aplus.github.io/promises-spec/#point-48
      throw TypeError('A promise may not resolve to itself');
    }

    state = webdriver.promise.Deferred.State_.BLOCKED;

    if (webdriver.promise.isPromise(newValue)) {
      var onFulfill = goog.partial(notifyAll, newState);
      var onReject = goog.partial(
          notifyAll, webdriver.promise.Deferred.State_.REJECTED);
      if (newValue instanceof webdriver.promise.Deferred) {
        newValue.then(onFulfill, onReject);
      } else {
        webdriver.promise.asap(newValue, onFulfill, onReject);
      }

    } else {
      notifyAll(newState, newValue);
    }
  }
function resolve ( newState , newValue ) { if ( webdriver . promise . Deferred . State_ . PENDING !== state ) { return ; } if ( newValue === self ) { // See promise a+, 2.3.1 // http://promises-aplus.github.io/promises-spec/#point-48 throw TypeError ( 'A promise may not resolve to itself' ) ; } state = webdriver . promise . Deferred . State_ . BLOCKED ; if ( webdriver . promise . isPromise ( newValue ) ) { var onFulfill = goog . partial ( notifyAll , newState ) ; var onReject = goog . partial ( notifyAll , webdriver . promise . Deferred . State_ . REJECTED ) ; if ( newValue instanceof webdriver . promise . Deferred ) { newValue . then ( onFulfill , onReject ) ; } else { webdriver . promise . asap ( newValue , onFulfill , onReject ) ; } } else { notifyAll ( newState , newValue ) ; } }
Resolves this deferred. If the new value is a promise, this function will
wait for it to be resolved before notifying the registered listeners.
@param {!webdriver.promise.Deferred.State_} newState The deferred's new
state.
@param {*} newValue The deferred's new value.
Resolves this deferred . If the new value is a promise this function will wait for it to be resolved before notifying the registered listeners .