bool add_pending_promise(JSContext *cx, HandleObject self, HandleObject promise) {
  MOZ_ASSERT(is_instance(self));
  MOZ_ASSERT(JS::IsPromiseObject(promise));
  RootedObject handler(cx);
  handler = &JS::GetReservedSlot(self, Slots::DecPendingPromiseCountFunc).toObject();
  if (!JS::AddPromiseReactions(cx, promise, handler, handler))
    return false;

  inc_pending_promise_count(self);
  return true;
}
bool add_pending_promise(JSContext *cx, HandleObject self, HandleObject promise) {
  MOZ_ASSERT(is_instance(self));
  MOZ_ASSERT(JS::IsPromiseObject(promise));
  RootedObject handler(cx);
  handler = &JS::GetReservedSlot(self, Slots::DecPendingPromiseCountFunc).toObject();
  if (!JS::AddPromiseReactions(cx, promise, handler, handler))
    return false;

  inc_pending_promise_count(self);
  return true;
}