Exemple #1
0
void
Promise::HandleException(JSContext* aCx)
{
  JS::Rooted<JS::Value> exn(aCx);
  if (JS_GetPendingException(aCx, &exn)) {
    JS_ClearPendingException(aCx);
    // This is only called from MaybeSomething, so it's OK to MaybeReject here.
    MaybeReject(aCx, exn);
  }
}
void
AbortablePromise::Abort()
{
  if (IsPending()) {
    return;
  }
  MaybeReject(NS_ERROR_ABORT);

  nsCOMPtr<nsIRunnable> runnable =
    NS_NewRunnableMethod(this, &AbortablePromise::DoAbort);
  Promise::DispatchToMicroTask(runnable);
}