Bug 1276272 part 1 - add Promise::MaybeRejectWithVode() utility method; r?ehsan
MozReview-Commit-ID: 4bBGsUNKbQS
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -935,16 +935,24 @@ Promise::MaybeReject(const RefPtr<MediaS
void
Promise::MaybeRejectWithNull()
{
NS_ASSERT_OWNINGTHREAD(Promise);
MaybeSomething(JS::NullHandleValue, &Promise::MaybeReject);
}
+void
+Promise::MaybeRejectWithVoid()
+{
+ NS_ASSERT_OWNINGTHREAD(Promise);
+
+ MaybeSomething(JS::UndefinedHandleValue, &Promise::MaybeReject);
+}
+
bool
Promise::PerformMicroTaskCheckpoint()
{
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
// On the main thread, we always use the main promise micro task queue.
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -145,16 +145,18 @@ public:
MOZ_ASSERT(aArg.Failed());
MaybeSomething(aArg, &Promise::MaybeReject);
}
void MaybeReject(const RefPtr<MediaStreamError>& aArg);
void MaybeRejectWithNull();
+ void MaybeRejectWithVoid();
+
// DO NOT USE MaybeRejectBrokenly with in new code. Promises should be
// rejected with Error instances.
// Note: MaybeRejectBrokenly is a template so we can use it with DOMError
// without instantiating the DOMError specialization of MaybeSomething in
// every translation unit that includes this header, because that would
// require use to include DOMError.h either here or in all those translation
// units.
template<typename T>