code: function notifyAll(newState, newValue) {
      if (newState === webdriver.promise.Deferred.State_.REJECTED &&
          // We cannot check instanceof Error since the object may have been
          // created in a different JS context.
          goog.isObject(newValue) && goog.isString(newValue.message)) {
        newValue = flow.annotateError(/** @type {!Error} */(newValue));
      }
  
      state = newState;
      value = newValue;
      while (listeners.length) {
        notify(listeners.shift());
      }
  
      if (!handled && state == webdriver.promise.Deferred.State_.REJECTED) {
        pendingRejectionKey = propagateError(value);
      }
    }
docs: Notifies all of the listeners registered with this Deferred that its state
  has changed.
  @param {!webdriver.promise.Deferred.State_} newState The deferred's new
  state.
  @param {*} newValue The deferred's new value.