code: function executePromiseTask (promise, fn) {
      // Promise Resolution Procedure:
      // https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
      try {
          fn(value => {
              if (promise._state !== null) return; // Already settled
              if (value === promise) throw new TypeError('A promise cannot be resolved with itself.');
              var shouldExecuteTick = promise._lib && beginMicroTickScope();
              if (value && typeof value.then === 'function') {
                  executePromiseTask(promise, (resolve, reject) => {
                      value instanceof Promise ?
                          value._then(resolve, reject) :
                          value.then(resolve, reject);
                  });
              } else {
                  promise._state = true;
                  promise._value = value;
                  propagateAllListeners(promise);
              }
              if (shouldExecuteTick) endMicroTickScope();
          }, handleRejection.bind(null, promise)); // If Function.bind is not supported. Exception is handled in catch below
      } catch (ex) {
          handleRejection(promise, ex);
      }
  }
docs: Take a potentially misbehaving resolver function and make sure
  onFulfilled and onRejected are only called once.
  
  Makes no guarantees about asynchrony.