mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1091091: Support ErrorResult in Promise::MaybeReject(). r=bz
This commit is contained in:
parent
97197969ad
commit
600ab9bfb9
@ -60,5 +60,19 @@ ToJSValue(JSContext* aCx,
|
||||
return ToJSValue(aCx, exception, aValue);
|
||||
}
|
||||
|
||||
bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
ErrorResult& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
MOZ_ASSERT(aArgument.Failed());
|
||||
ThrowMethodFailedWithDetails(aCx, aArgument, "", "");
|
||||
if (!JS_GetPendingException(aCx, aValue)) {
|
||||
return false;
|
||||
}
|
||||
JS_ClearPendingException(aCx);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -261,6 +261,14 @@ ToJSValue(JSContext* aCx,
|
||||
nsresult aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
|
||||
// Accept ErrorResult, for use in rejections, and create an exception
|
||||
// representing the failure. Note, the ErrorResult must indicate a failure
|
||||
// with aArgument.Failure() returning true.
|
||||
bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
ErrorResult& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
|
||||
// Accept pointers to other things we accept
|
||||
template <typename T>
|
||||
typename EnableIf<IsPointer<T>::value, bool>::Type
|
||||
|
@ -101,6 +101,11 @@ public:
|
||||
MaybeSomething(aArg, &Promise::MaybeReject);
|
||||
}
|
||||
|
||||
inline void MaybeReject(ErrorResult& aArg) {
|
||||
MOZ_ASSERT(aArg.Failed());
|
||||
MaybeSomething(aArg, &Promise::MaybeReject);
|
||||
}
|
||||
|
||||
void MaybeReject(const nsRefPtr<MediaStreamError>& aArg);
|
||||
|
||||
// DO NOT USE MaybeRejectBrokenly with in new code. Promises should be
|
||||
|
Loading…
x
Reference in New Issue
Block a user