Bug 1276272 part 1 - add Promise::MaybeRejectWithVode() utility method; r=ehsan draft
authorKaku Kuo <tkuo@mozilla.com>
Thu, 09 Jun 2016 20:26:47 +0100
changeset 377970 865b8c0c4ea1aba631c0329317535215efea15fa
parent 377951 ddb6b30149221f00eb5dd180530e9033093d4c2b
child 377971 affa6086916de27498a1d62ac313b688e529e65b
push id20909
push usertkuo@mozilla.com
push dateTue, 14 Jun 2016 11:35:47 +0000
reviewersehsan
bugs1276272
milestone50.0a1
Bug 1276272 part 1 - add Promise::MaybeRejectWithVode() utility method; r=ehsan MozReview-Commit-ID: 4bBGsUNKbQS
dom/promise/Promise.cpp
dom/promise/Promise.h
--- 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::MaybeRejectWithUndefined()
+{
+  NS_ASSERT_OWNINGTHREAD(Promise);
+
+  MaybeSomething(JS::UndefinedHandleValue, &Promise::MaybeReject);
+}
+
 
 #ifdef SPIDERMONKEY_PROMISE
 void
 Promise::ReportRejectedPromise(JSContext* aCx, JS::HandleObject aPromise)
 {
   MOZ_ASSERT(!js::IsWrapper(aPromise));
 
   MOZ_ASSERT(JS::GetPromiseState(aPromise) == JS::PromiseState::Rejected);
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -148,16 +148,18 @@ public:
     MOZ_ASSERT(aArg.Failed());
     MaybeSomething(aArg, &Promise::MaybeReject);
   }
 
   void MaybeReject(const RefPtr<MediaStreamError>& aArg);
 
   void MaybeRejectWithNull();
 
+  void MaybeRejectWithUndefined();
+
   // 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>