Bug 1615022 part 2. Require an rvalue reference to reject a Promise with an ErrorResult. r=farre,kvark

The rejection process consumes the ErrorResult, so an rvalue reference is the honest thing here.

Differential Revision: https://phabricator.services.mozilla.com/D62632

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2020-02-14 15:42:30 +00:00
parent 7c42333b8a
commit 6c66fa85a4
31 changed files with 79 additions and 79 deletions

View File

@ -736,7 +736,7 @@ void BodyConsumer::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength,
error.WouldReportJSException();
if (error.Failed()) {
localPromise->MaybeReject(error);
localPromise->MaybeReject(std::move(error));
}
}

View File

@ -809,7 +809,7 @@ class PromiseDocumentFlushedResolver final {
mCallback->Call(&returnVal, error);
if (error.Failed()) {
mPromise->MaybeReject(error);
mPromise->MaybeReject(std::move(error));
} else if (guard.Mutated(0)) {
// Something within the callback mutated the DOM.
mPromise->MaybeReject(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);

View File

@ -43,7 +43,7 @@ bool ToJSValue(JSContext* aCx, nsresult aArgument,
return ToJSValue(aCx, exception, aValue);
}
bool ToJSValue(JSContext* aCx, ErrorResult& aArgument,
bool ToJSValue(JSContext* aCx, ErrorResult&& aArgument,
JS::MutableHandle<JS::Value> aValue) {
MOZ_ASSERT(aArgument.Failed());
MOZ_ASSERT(

View File

@ -303,7 +303,7 @@ MOZ_MUST_USE bool ToJSValue(JSContext* aCx, nsresult aArgument,
// 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.
MOZ_MUST_USE bool ToJSValue(JSContext* aCx, ErrorResult& aArgument,
MOZ_MUST_USE bool ToJSValue(JSContext* aCx, ErrorResult&& aArgument,
JS::MutableHandle<JS::Value> aValue);
// Accept owning WebIDL unions.

4
dom/cache/Cache.cpp vendored
View File

@ -176,7 +176,7 @@ class Cache::FetchHandler final : public PromiseNativeHandler {
if (!IsValidPutResponseStatus(*response, PutStatusPolicy::RequireOK,
errorResult)) {
// TODO: abort the fetch requests we have running (bug 1157434)
mPromise->MaybeReject(errorResult);
mPromise->MaybeReject(std::move(errorResult));
return;
}
@ -195,7 +195,7 @@ class Cache::FetchHandler final : public PromiseNativeHandler {
result.WouldReportJSException();
if (NS_WARN_IF(result.Failed())) {
// TODO: abort the fetch requests we have running (bug 1157434)
mPromise->MaybeReject(result);
mPromise->MaybeReject(std::move(result));
return;
}

View File

@ -95,7 +95,7 @@ mozilla::ipc::IPCResult CacheOpChild::Recv__delete__(
if (NS_WARN_IF(aRv.Failed())) {
MOZ_DIAGNOSTIC_ASSERT(aResult.type() == CacheOpResult::Tvoid_t);
mPromise->MaybeReject(aRv);
mPromise->MaybeReject(std::move(aRv));
mPromise = nullptr;
return IPC_OK();
}

View File

@ -551,7 +551,7 @@ void CacheStorage::RunRequest(nsAutoPtr<Entry>&& aEntry) {
ErrorResult rv;
args.Add(entry->mRequest, IgnoreBody, IgnoreInvalidScheme, rv);
if (NS_WARN_IF(rv.Failed())) {
entry->mPromise->MaybeReject(rv);
entry->mPromise->MaybeReject(std::move(rv));
return;
}
}

View File

@ -1674,7 +1674,7 @@ void CreateImageBitmapFromBlob::
imageBitmap->SetPictureRect(mCropRect.ref(), rv);
if (rv.Failed()) {
mPromise->MaybeReject(rv);
mPromise->MaybeReject(std::move(rv));
return;
}
}

View File

@ -163,9 +163,8 @@ already_AddRefed<Promise> Client::Focus(CallerType aCallerType,
},
[holder, outerPromise](const CopyableErrorResult& aResult) {
holder->Complete();
// MaybeReject needs a non-const result, so make a copy.
CopyableErrorResult result(aResult);
outerPromise->MaybeReject(result);
// MaybeReject needs a non-const-ref result, so make a copy.
outerPromise->MaybeReject(CopyableErrorResult(aResult));
})
->Track(*holder);
@ -201,8 +200,8 @@ already_AddRefed<Promise> Client::Navigate(const nsAString& aURL,
outerPromise->MaybeResolve(newClient);
},
[self, outerPromise](const CopyableErrorResult& aResult) {
CopyableErrorResult result(aResult);
outerPromise->MaybeReject(result);
// MaybeReject needs a non-const-ref result, so make a copy.
outerPromise->MaybeReject(CopyableErrorResult(aResult));
});
return outerPromise.forget();

View File

@ -189,9 +189,8 @@ already_AddRefed<Promise> Clients::MatchAll(const ClientQueryOptions& aOptions,
outerPromise->MaybeResolve(clientList);
},
[outerPromise](const CopyableErrorResult& aResult) {
// MaybeReject needs a non-const result, so make a copy.
CopyableErrorResult result(aResult);
outerPromise->MaybeReject(result);
// MaybeReject needs a non-const-ref result, so make a copy.
outerPromise->MaybeReject(CopyableErrorResult(aResult));
});
return outerPromise.forget();
@ -214,7 +213,7 @@ already_AddRefed<Promise> Clients::OpenWindow(const nsAString& aURL,
CopyableErrorResult rv;
rv.ThrowTypeError(
u"Passing \"about:blank\" to Clients.openWindow is not allowed");
outerPromise->MaybeReject(rv);
outerPromise->MaybeReject(std::move(rv));
return outerPromise.forget();
}
@ -244,9 +243,8 @@ already_AddRefed<Promise> Clients::OpenWindow(const nsAString& aURL,
outerPromise->MaybeResolve(client);
},
[outerPromise](const CopyableErrorResult& aResult) {
// MaybeReject needs a non-const result, so make a copy.
CopyableErrorResult result(aResult);
outerPromise->MaybeReject(result);
// MaybeReject needs a non-const-ref result, so make a copy.
outerPromise->MaybeReject(CopyableErrorResult(aResult));
});
return outerPromise.forget();
@ -279,9 +277,8 @@ already_AddRefed<Promise> Clients::Claim(ErrorResult& aRv) {
outerPromise->MaybeResolveWithUndefined();
},
[outerPromise](const CopyableErrorResult& aResult) {
// MaybeReject needs a non-const result, so make a copy.
CopyableErrorResult result(aResult);
outerPromise->MaybeReject(result);
// MaybeReject needs a non-const-ref result, so make a copy.
outerPromise->MaybeReject(CopyableErrorResult(aResult));
});
return outerPromise.forget();

View File

@ -336,7 +336,7 @@ void JSWindowActor::ReceiveMessageOrQuery(
promise->MaybeRejectWithTimeoutError(
"Message handler threw uncatchable exception");
} else {
promise->MaybeReject(aRv);
promise->MaybeReject(std::move(aRv));
}
} else {
promise->MaybeResolve(retval);

View File

@ -52,10 +52,10 @@ void DetailedPromise::MaybeReject(nsresult aArg, const nsACString& aReason) {
Promise::MaybeRejectWithDOMException(aArg, aReason);
}
void DetailedPromise::MaybeReject(ErrorResult& aArg,
void DetailedPromise::MaybeReject(ErrorResult&& aArg,
const nsACString& aReason) {
LogRejectionReason(aArg.ErrorCodeAsInt(), aReason);
Promise::MaybeReject(aArg);
Promise::MaybeReject(std::move(aArg));
}
/* static */

View File

@ -40,8 +40,8 @@ class DetailedPromise : public Promise {
void MaybeReject(nsresult aArg) = delete;
void MaybeReject(nsresult aArg, const nsACString& aReason);
void MaybeReject(ErrorResult& aArg) = delete;
void MaybeReject(ErrorResult& aArg, const nsACString& aReason);
void MaybeReject(ErrorResult&& aArg) = delete;
void MaybeReject(ErrorResult&& aArg, const nsACString& aReason);
// Facilities for rejecting with various spec-defined exception values.
#define DOMEXCEPTION(name, err) \
@ -64,7 +64,7 @@ class DetailedPromise : public Promise {
inline void MaybeRejectWithTypeError(const nsAString& aMessage) {
ErrorResult res;
res.ThrowTypeError(aMessage);
MaybeReject(res, NS_ConvertUTF16toUTF8(aMessage));
MaybeReject(std::move(res), NS_ConvertUTF16toUTF8(aMessage));
}
template <int N>
@ -78,7 +78,7 @@ class DetailedPromise : public Promise {
inline void MaybeRejectWithRangeError(const nsAString& aMessage) {
ErrorResult res;
res.ThrowRangeError(aMessage);
MaybeReject(res, NS_ConvertUTF16toUTF8(aMessage));
MaybeReject(std::move(res), NS_ConvertUTF16toUTF8(aMessage));
}
template <int N>

View File

@ -191,15 +191,15 @@ void MIDIAccess::MaybeCreateMIDIPort(const MIDIPortInfo& aInfo,
// received, that will be handled by the MIDIPort object itself, and it will
// request removal from MIDIAccess's maps.
void MIDIAccess::Notify(const MIDIPortList& aEvent) {
ErrorResult rv;
for (auto& port : aEvent.ports()) {
// Something went very wrong. Warn and return.
ErrorResult rv;
MaybeCreateMIDIPort(port, rv);
if (rv.Failed()) {
if (!mAccessPromise) {
return;
}
mAccessPromise->MaybeReject(rv);
mAccessPromise->MaybeReject(std::move(rv));
mAccessPromise = nullptr;
}
}

View File

@ -759,14 +759,14 @@ already_AddRefed<Promise> PaymentRequest::Show(
return promise.forget();
}
void PaymentRequest::RejectShowPayment(ErrorResult& aRejectReason) {
void PaymentRequest::RejectShowPayment(ErrorResult&& aRejectReason) {
MOZ_ASSERT(mAcceptPromise || mResponse);
MOZ_ASSERT(mState == eInteractive);
if (mResponse) {
mResponse->RejectRetry(aRejectReason);
mResponse->RejectRetry(std::move(aRejectReason));
} else {
mAcceptPromise->MaybeReject(aRejectReason);
mAcceptPromise->MaybeReject(std::move(aRejectReason));
}
mState = eClosed;
mAcceptPromise = nullptr;
@ -777,12 +777,12 @@ void PaymentRequest::RespondShowPayment(const nsAString& aMethodName,
const nsAString& aPayerName,
const nsAString& aPayerEmail,
const nsAString& aPayerPhone,
ErrorResult& aResult) {
ErrorResult&& aResult) {
MOZ_ASSERT(mAcceptPromise || mResponse);
MOZ_ASSERT(mState == eInteractive);
if (aResult.Failed()) {
RejectShowPayment(aResult);
RejectShowPayment(std::move(aResult));
return;
}
@ -859,8 +859,7 @@ void PaymentRequest::RespondAbortPayment(bool aSuccess) {
// Respond show with mUpdateError, set mUpdating to false.
mUpdating = false;
RespondShowPayment(EmptyString(), ResponseData(), EmptyString(),
EmptyString(), EmptyString(), mUpdateError);
mUpdateError.SuppressException();
EmptyString(), EmptyString(), std::move(mUpdateError));
return;
}
@ -872,7 +871,7 @@ void PaymentRequest::RespondAbortPayment(bool aSuccess) {
mAbortPromise = nullptr;
ErrorResult abortResult;
abortResult.ThrowAbortError("The PaymentRequest is aborted");
RejectShowPayment(abortResult);
RejectShowPayment(std::move(abortResult));
} else {
mAbortPromise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
mAbortPromise = nullptr;
@ -1197,7 +1196,7 @@ void PaymentRequest::NotifyOwnerDocumentActivityChanged() {
if (mResponse) {
ErrorResult rejectReason;
rejectReason.ThrowAbortError("The owner documnet is not fully active");
mResponse->RejectRetry(rejectReason);
mResponse->RejectRetry(std::move(rejectReason));
}
if (mAbortPromise) {
mAbortPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);

View File

@ -151,8 +151,8 @@ class PaymentRequest final : public DOMEventTargetHelper,
const ResponseData& aData,
const nsAString& aPayerName,
const nsAString& aPayerEmail,
const nsAString& aPayerPhone, ErrorResult& aResult);
void RejectShowPayment(ErrorResult& aRejectReason);
const nsAString& aPayerPhone, ErrorResult&& aResult);
void RejectShowPayment(ErrorResult&& aRejectReason);
void RespondComplete();
already_AddRefed<Promise> Abort(ErrorResult& aRv);

View File

@ -685,7 +685,8 @@ nsresult PaymentRequestManager::RespondPayment(
}
aRequest->RespondShowPayment(response.methodName(), responseData,
response.payerName(), response.payerEmail(),
response.payerPhone(), rejectedReason);
response.payerPhone(),
std::move(rejectedReason));
if (rejectedReason.Failed()) {
NotifyRequestDone(aRequest);
}

View File

@ -300,9 +300,9 @@ void PaymentResponse::RespondRetry(const nsAString& aMethodName,
mRetryPromise = nullptr;
}
void PaymentResponse::RejectRetry(ErrorResult& aRejectReason) {
void PaymentResponse::RejectRetry(ErrorResult&& aRejectReason) {
MOZ_ASSERT(mRetryPromise);
mRetryPromise->MaybeReject(aRejectReason);
mRetryPromise->MaybeReject(std::move(aRejectReason));
mRetryPromise = nullptr;
}

View File

@ -141,7 +141,7 @@ class PaymentResponse final : public DOMEventTargetHelper,
PaymentAddress* aShippingAddress,
const ResponseData& aDetails, const nsAString& aPayerName,
const nsAString& aPayerEmail, const nsAString& aPayerPhone);
void RejectRetry(ErrorResult& aRejectReason);
void RejectRetry(ErrorResult&& aRejectReason);
protected:
~PaymentResponse();

View File

@ -102,9 +102,11 @@ class Promise : public nsISupports, public SupportsWeakPtr<Promise> {
MaybeSomething(aArg, &Promise::MaybeReject);
}
inline void MaybeReject(ErrorResult& aArg) {
inline void MaybeReject(ErrorResult&& aArg) {
MOZ_ASSERT(aArg.Failed());
MaybeSomething(aArg, &Promise::MaybeReject);
MaybeSomething(std::move(aArg), &Promise::MaybeReject);
// That should have consumed aArg.
MOZ_ASSERT(!aArg.Failed());
}
void MaybeReject(const RefPtr<MediaStreamError>& aArg);
@ -119,7 +121,7 @@ class Promise : public nsISupports, public SupportsWeakPtr<Promise> {
inline void MaybeRejectWith##name(const nsACString& aMessage) { \
ErrorResult res; \
res.Throw##name(aMessage); \
MaybeReject(res); \
MaybeReject(std::move(res)); \
} \
template <int N> \
void MaybeRejectWith##name(const char(&aMessage)[N]) { \
@ -134,13 +136,13 @@ class Promise : public nsISupports, public SupportsWeakPtr<Promise> {
void MaybeRejectWithTypeError(Ts&&... aMessageArgs) {
ErrorResult res;
res.ThrowTypeError<errorNumber>(std::forward<Ts>(aMessageArgs)...);
MaybeReject(res);
MaybeReject(std::move(res));
}
inline void MaybeRejectWithTypeError(const nsAString& aMessage) {
ErrorResult res;
res.ThrowTypeError(aMessage);
MaybeReject(res);
MaybeReject(std::move(res));
}
template <int N>
@ -152,13 +154,13 @@ class Promise : public nsISupports, public SupportsWeakPtr<Promise> {
void MaybeRejectWithRangeError(Ts&&... aMessageArgs) {
ErrorResult res;
res.ThrowRangeError<errorNumber>(std::forward<Ts>(aMessageArgs)...);
MaybeReject(res);
MaybeReject(std::move(res));
}
inline void MaybeRejectWithRangeError(const nsAString& aMessage) {
ErrorResult res;
res.ThrowRangeError(aMessage);
MaybeReject(res);
MaybeReject(std::move(res));
}
template <int N>
@ -284,7 +286,7 @@ class Promise : public nsISupports, public SupportsWeakPtr<Promise> {
const nsACString& aMessage) {
ErrorResult res;
res.ThrowDOMException(rv, aMessage);
MaybeReject(res);
MaybeReject(std::move(res));
}
struct PromiseCapability;

View File

@ -57,7 +57,7 @@ void RemoteServiceWorkerContainerImpl::Register(
if (!mActor) {
CopyableErrorResult rv;
rv.ThrowInvalidStateError("Can't register service worker");
aFailureCB(rv);
aFailureCB(std::move(rv));
return;
}
@ -84,7 +84,7 @@ void RemoteServiceWorkerContainerImpl::Register(
// IPC layer error
CopyableErrorResult rv;
rv.ThrowInvalidStateError("Failed to register service worker");
aFailureCB(rv);
aFailureCB(std::move(rv));
});
}

View File

@ -94,7 +94,7 @@ void RemoteServiceWorkerRegistrationImpl::Unregister(
aFailureCB](Tuple<bool, CopyableErrorResult>&& aResult) {
if (Get<1>(aResult).Failed()) {
// application layer error
aFailureCB(Get<1>(aResult));
aFailureCB(std::move(Get<1>(aResult)));
return;
}
// success

View File

@ -111,7 +111,7 @@ ServiceWorker::ServiceWorker(nsIGlobalObject* aGlobal,
global->GetOrCreateServiceWorkerRegistration(aDescriptor);
self->MaybeAttachToRegistration(reg);
},
[](ErrorResult& aRv) {
[](ErrorResult&& aRv) {
// do nothing
aRv.SuppressException();
});

View File

@ -383,14 +383,14 @@ already_AddRefed<Promise> ServiceWorkerContainer::Register(
ErrorResult rv;
nsIGlobalObject* global = self->GetGlobalIfValid(rv);
if (rv.Failed()) {
outer->MaybeReject(rv);
outer->MaybeReject(std::move(rv));
return;
}
RefPtr<ServiceWorkerRegistration> reg =
global->GetOrCreateServiceWorkerRegistration(aDesc);
outer->MaybeResolve(reg);
},
[outer](ErrorResult& aRv) { outer->MaybeReject(aRv); });
[outer](ErrorResult&& aRv) { outer->MaybeReject(std::move(aRv)); });
return outer.forget();
}
@ -433,7 +433,7 @@ already_AddRefed<Promise> ServiceWorkerContainer::GetRegistrations(
ErrorResult rv;
nsIGlobalObject* global = self->GetGlobalIfValid(rv);
if (rv.Failed()) {
outer->MaybeReject(rv);
outer->MaybeReject(std::move(rv));
return;
}
nsTArray<RefPtr<ServiceWorkerRegistration>> regList;
@ -446,7 +446,7 @@ already_AddRefed<Promise> ServiceWorkerContainer::GetRegistrations(
}
outer->MaybeResolve(regList);
},
[self, outer](ErrorResult& aRv) { outer->MaybeReject(aRv); });
[self, outer](ErrorResult&& aRv) { outer->MaybeReject(std::move(aRv)); });
return outer.forget();
}
@ -508,14 +508,14 @@ already_AddRefed<Promise> ServiceWorkerContainer::GetRegistration(
ErrorResult rv;
nsIGlobalObject* global = self->GetGlobalIfValid(rv);
if (rv.Failed()) {
outer->MaybeReject(rv);
outer->MaybeReject(std::move(rv));
return;
}
RefPtr<ServiceWorkerRegistration> reg =
global->GetOrCreateServiceWorkerRegistration(aDescriptor);
outer->MaybeResolve(reg);
},
[self, outer](ErrorResult& aRv) {
[self, outer](ErrorResult&& aRv) {
if (!aRv.Failed()) {
Unused << self->GetGlobalIfValid(aRv);
if (!aRv.Failed()) {
@ -523,7 +523,7 @@ already_AddRefed<Promise> ServiceWorkerContainer::GetRegistration(
return;
}
}
outer->MaybeReject(aRv);
outer->MaybeReject(std::move(aRv));
});
return outer.forget();
@ -561,7 +561,7 @@ Promise* ServiceWorkerContainer::GetReady(ErrorResult& aRv) {
ErrorResult rv;
nsIGlobalObject* global = self->GetGlobalIfValid(rv);
if (rv.Failed()) {
outer->MaybeReject(rv);
outer->MaybeReject(std::move(rv));
return;
}
RefPtr<ServiceWorkerRegistration> reg =
@ -575,7 +575,7 @@ Promise* ServiceWorkerContainer::GetReady(ErrorResult& aRv) {
aDescriptor.Version(),
[outer, reg](bool aResult) { outer->MaybeResolve(reg); });
},
[self, outer](ErrorResult& aRv) { outer->MaybeReject(aRv); });
[self, outer](ErrorResult&& aRv) { outer->MaybeReject(std::move(aRv)); });
return mReadyPromise;
}

View File

@ -260,7 +260,7 @@ already_AddRefed<Promise> ServiceWorkerRegistration::Update(ErrorResult& aRv) {
}
outer->MaybeResolve(ref);
},
[outer, self](ErrorResult& aRv) { outer->MaybeReject(aRv); });
[outer, self](ErrorResult&& aRv) { outer->MaybeReject(std::move(aRv)); });
return outer.forget();
}
@ -284,9 +284,10 @@ already_AddRefed<Promise> ServiceWorkerRegistration::Unregister(
}
mInner->Unregister([outer](bool aSuccess) { outer->MaybeResolve(aSuccess); },
[outer](ErrorResult& aRv) {
[outer](ErrorResult&& aRv) {
// register() should be resilient and resolve false
// instead of rejecting in most cases.
aRv.SuppressException();
outer->MaybeResolve(false);
});

View File

@ -39,7 +39,7 @@ typedef std::function<void(
typedef std::function<void(bool)> ServiceWorkerBoolCallback;
typedef std::function<void(ErrorResult&)> ServiceWorkerFailureCallback;
typedef std::function<void(ErrorResult&&)> ServiceWorkerFailureCallback;
bool ServiceWorkerParentInterceptEnabled();

View File

@ -247,7 +247,7 @@ already_AddRefed<Promise> WebAuthnManager::MakeCredential(
nsCString rpId;
rv = GetOrigin(mParent, origin, rpId);
if (NS_WARN_IF(rv.Failed())) {
promise->MaybeReject(rv);
promise->MaybeReject(std::move(rv));
return promise.forget();
}
@ -466,7 +466,7 @@ already_AddRefed<Promise> WebAuthnManager::GetAssertion(
nsCString rpId;
rv = GetOrigin(mParent, origin, rpId);
if (NS_WARN_IF(rv.Failed())) {
promise->MaybeReject(rv);
promise->MaybeReject(std::move(rv));
return promise.forget();
}

View File

@ -101,7 +101,7 @@ already_AddRefed<dom::Promise> Buffer::MapReadAsync(ErrorResult& aRv) {
if (!arrayBuffer) {
ErrorResult rv;
rv.StealExceptionFromJSContext(jsapi.cx());
promise->MaybeReject(rv);
promise->MaybeReject(std::move(rv));
return;
}
JS::Rooted<JS::Value> val(jsapi.cx(), JS::ObjectValue(*arrayBuffer));

View File

@ -2171,7 +2171,7 @@ void ScriptExecutorRunnable::LogExceptionToConsole(
MOZ_ASSERT(mScriptLoader.mRv.IsJSException());
JS::Rooted<JS::Value> exn(aCx);
if (!ToJSValue(aCx, mScriptLoader.mRv, &exn)) {
if (!ToJSValue(aCx, std::move(mScriptLoader.mRv), &exn)) {
return;
}

View File

@ -130,8 +130,9 @@ class WorkletFetchHandler final : public PromiseNativeHandler,
RefPtr<Promise> fetchPromise =
FetchRequest(global, request, init, aCallerType, aRv);
if (NS_WARN_IF(aRv.Failed())) {
promise->MaybeReject(aRv);
return promise.forget();
// OK to just return null, since caller will ignore return value
// anyway if aRv is a failure.
return nullptr;
}
RefPtr<WorkletFetchHandler> handler =

View File

@ -355,7 +355,7 @@ void CrossProcessPaint::MaybeResolve() {
mPromise->MaybeResolve(bitmap);
} else {
CPP_LOG("Couldn't create ImageBitmap for SourceSurface.\n");
mPromise->MaybeReject(rv);
mPromise->MaybeReject(std::move(rv));
}
Clear();
}