B2G/gecko/dom/browser-element/mochitest/browserElementTestHelpers.js
/**
     * Resolves associated `promise` to a given `value`, unless it's already
     * resolved or rejected. Note that resolved promise is not necessary a
     * successfully fulfilled. Promise may be resolved with a promise `value`
     * in which case `value` promise's fulfillment / rejection will propagate
     * up to a promise resolved with `value`.
     */
Resolves associated `promise` to a given `value`, unless it's already
resolved or rejected. Note that resolved promise is not necessary a
successfully fulfilled.
Resolves associated ` promise ` to a given ` value ` unless it ' s already resolved or rejected . Note that resolved promise is not necessary a successfully fulfilled .
function resolve(value) {
      if (!result) {
        result = isPromise(value) ? value : fulfilled(value);
        while (observers.length) {
          var observer = observers.shift();
          result.then(observer.resolve, observer.reject);
        }
        observers = null;
      }
    }
function resolve ( value ) { if ( ! result ) { result = isPromise ( value ) ? value : fulfilled ( value ) ; while ( observers . length ) { var observer = observers . shift ( ) ; result . then ( observer . resolve , observer . reject ) ; } observers = null ; } }
Resolves associated `promise` to a given `value`, unless it's already
 resolved or rejected.
Resolves associated ` promise ` to a given ` value ` unless it ' s already resolved or rejected .
// Store resolution `value` in a `result` as a promise, so that all // the subsequent handlers can be simply forwarded to it. Since // `result` will be a promise all the value / error propagation will // be uniformly taken care of. // Forward already registered observers to a `result` promise in the // order they were registered. Note that we intentionally dequeue // observer at a time until queue is exhausted. This makes sure that // handlers registered as side effect of observer forwarding are // queued instead of being invoked immediately, guaranteeing FIFO // order. // Once `observers` queue is exhausted we `null`-ify it, so that // new handlers are forwarded straight to the `result`.