Bug 1748888 - Add ErrorResult parameter to PromiseNativeHandler callbacks r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D136423
This commit is contained in:
Matthew Gaudet 2022-01-20 19:11:39 +00:00
Родитель 66ac5d98fc
Коммит bc10b96605
51 изменённых файлов: 337 добавлений и 268 удалений

Просмотреть файл

@ -400,7 +400,8 @@ class FileCreationHandler final : public PromiseNativeHandler {
aPromise->AppendNativeHandler(handler); aPromise->AppendNativeHandler(handler);
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
AssertIsOnMainThread(); AssertIsOnMainThread();
if (NS_WARN_IF(!aValue.isObject())) { if (NS_WARN_IF(!aValue.isObject())) {
@ -417,7 +418,8 @@ class FileCreationHandler final : public PromiseNativeHandler {
mConsumer->OnBlobResult(blob->Impl(), mWorkerRef); mConsumer->OnBlobResult(blob->Impl(), mWorkerRef);
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
AssertIsOnMainThread(); AssertIsOnMainThread();
mConsumer->OnBlobResult(nullptr, mWorkerRef); mConsumer->OnBlobResult(nullptr, mWorkerRef);

Просмотреть файл

@ -13564,13 +13564,15 @@ class UnblockParsingPromiseHandler final : public PromiseNativeHandler {
} }
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
MaybeUnblockParser(); MaybeUnblockParser();
mPromise->MaybeResolve(aValue); mPromise->MaybeResolve(aValue);
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
MaybeUnblockParser(); MaybeUnblockParser();
mPromise->MaybeReject(aValue); mPromise->MaybeReject(aValue);

8
dom/cache/Cache.cpp поставляемый
Просмотреть файл

@ -114,8 +114,8 @@ class Cache::FetchHandler final : public PromiseNativeHandler {
MOZ_DIAGNOSTIC_ASSERT(mPromise); MOZ_DIAGNOSTIC_ASSERT(mPromise);
} }
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
NS_ASSERT_OWNINGTHREAD(FetchHandler); NS_ASSERT_OWNINGTHREAD(FetchHandler);
// Stop holding the worker alive when we leave this method. // Stop holding the worker alive when we leave this method.
@ -190,8 +190,8 @@ class Cache::FetchHandler final : public PromiseNativeHandler {
mPromise->MaybeResolve(put); mPromise->MaybeResolve(put);
} }
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
NS_ASSERT_OWNINGTHREAD(FetchHandler); NS_ASSERT_OWNINGTHREAD(FetchHandler);
Fail(); Fail();
} }

Просмотреть файл

@ -187,7 +187,8 @@ class BlobTextHandler final : public PromiseNativeHandler {
mHolder.Reject(rv, __func__); mHolder.Reject(rv, __func__);
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
AssertIsOnMainThread(); AssertIsOnMainThread();
nsString text; nsString text;
@ -203,7 +204,8 @@ class BlobTextHandler final : public PromiseNativeHandler {
mHolder.Resolve(std::move(native), __func__); mHolder.Resolve(std::move(native), __func__);
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
Reject(); Reject();
} }

Просмотреть файл

@ -320,7 +320,8 @@ FetchStreamReader::OnOutputStreamReady(nsIAsyncOutputStream* aStream) {
} }
void FetchStreamReader::ResolvedCallback(JSContext* aCx, void FetchStreamReader::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (mStreamClosed) { if (mStreamClosed) {
return; return;
} }
@ -418,7 +419,8 @@ nsresult FetchStreamReader::WriteBuffer() {
} }
void FetchStreamReader::RejectedCallback(JSContext* aCx, void FetchStreamReader::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
ReportErrorToConsole(aCx, aValue); ReportErrorToConsole(aCx, aValue);
CloseAndRelease(aCx, NS_ERROR_FAILURE); CloseAndRelease(aCx, NS_ERROR_FAILURE);
} }

Просмотреть файл

@ -36,9 +36,11 @@ class FetchStreamReader final : public nsIOutputStreamCallback,
FetchStreamReader** aStreamReader, FetchStreamReader** aStreamReader,
nsIInputStream** aInputStream); nsIInputStream** aInputStream);
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
// Idempotently close the output stream and null out all state. If aCx is // Idempotently close the output stream and null out all state. If aCx is
// provided, the reader will also be canceled. aStatus must be a DOM error // provided, the reader will also be canceled. aStatus must be a DOM error

Просмотреть файл

@ -160,7 +160,8 @@ void GetEntryHelper::Run() {
} }
void GetEntryHelper::ResolvedCallback(JSContext* aCx, void GetEntryHelper::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (NS_WARN_IF(!aValue.isObject())) { if (NS_WARN_IF(!aValue.isObject())) {
return; return;
} }
@ -225,7 +226,8 @@ void GetEntryHelper::ContinueRunning(JSObject* aObj) {
} }
void GetEntryHelper::RejectedCallback(JSContext* aCx, void GetEntryHelper::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
Error(NS_ERROR_DOM_NOT_FOUND_ERR); Error(NS_ERROR_DOM_NOT_FOUND_ERR);
} }

Просмотреть файл

@ -73,11 +73,11 @@ class GetEntryHelper final : public PromiseNativeHandler {
void Run(); void Run();
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
private: private:
~GetEntryHelper(); ~GetEntryHelper();

Просмотреть файл

@ -40,8 +40,8 @@ class PromiseHandler final : public PromiseNativeHandler {
} }
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
if (NS_WARN_IF(!aValue.isObject())) { if (NS_WARN_IF(!aValue.isObject())) {
return; return;
} }
@ -93,8 +93,8 @@ class PromiseHandler final : public PromiseNativeHandler {
mSuccessCallback->Call(sequence); mSuccessCallback->Call(sequence);
} }
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
if (mErrorCallback) { if (mErrorCallback) {
RefPtr<ErrorCallbackRunnable> runnable = new ErrorCallbackRunnable( RefPtr<ErrorCallbackRunnable> runnable = new ErrorCallbackRunnable(
mParentEntry->GetParentObject(), mErrorCallback, mParentEntry->GetParentObject(), mErrorCallback,

Просмотреть файл

@ -627,13 +627,13 @@ class ShareHandler final : public PromiseNativeHandler {
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
public: public:
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
mResolver(NS_OK); mResolver(NS_OK);
} }
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
if (NS_WARN_IF(!aValue.isObject())) { if (NS_WARN_IF(!aValue.isObject())) {
mResolver(NS_ERROR_FAILURE); mResolver(NS_ERROR_FAILURE);
return; return;
@ -844,13 +844,15 @@ class CheckPermitUnloadRequest final : public PromiseNativeHandler,
mState = State::REPLIED; mState = State::REPLIED;
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
MOZ_ASSERT(mState == State::PROMPTING); MOZ_ASSERT(mState == State::PROMPTING);
SendReply(JS::ToBoolean(aValue)); SendReply(JS::ToBoolean(aValue));
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
MOZ_ASSERT(mState == State::PROMPTING); MOZ_ASSERT(mState == State::PROMPTING);
SendReply(false); SendReply(false);

Просмотреть файл

@ -372,7 +372,8 @@ JSActor::QueryHandler::QueryHandler(JSActor* aActor,
mQueryId(aMetadata.queryId()) {} mQueryId(aMetadata.queryId()) {}
void JSActor::QueryHandler::RejectedCallback(JSContext* aCx, void JSActor::QueryHandler::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (!mActor) { if (!mActor) {
// Make sure that this rejection is reported. See comment below. // Make sure that this rejection is reported. See comment below.
if (!JS::CallOriginalPromiseReject(aCx, aValue)) { if (!JS::CallOriginalPromiseReject(aCx, aValue)) {
@ -414,7 +415,8 @@ void JSActor::QueryHandler::RejectedCallback(JSContext* aCx,
} }
void JSActor::QueryHandler::ResolvedCallback(JSContext* aCx, void JSActor::QueryHandler::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (!mActor) { if (!mActor) {
return; return;
} }
@ -438,7 +440,7 @@ void JSActor::QueryHandler::ResolvedCallback(JSContext* aCx,
JS::Rooted<JS::Value> val(aCx); JS::Rooted<JS::Value> val(aCx);
if (ToJSValue(aCx, exc, &val)) { if (ToJSValue(aCx, exc, &val)) {
RejectedCallback(aCx, val); RejectedCallback(aCx, val, aRv);
} else { } else {
JS_ClearPendingException(aCx); JS_ClearPendingException(aCx);
} }

Просмотреть файл

@ -128,11 +128,11 @@ class JSActor : public nsISupports, public nsWrapperCache {
QueryHandler(JSActor* aActor, const JSActorMessageMeta& aMetadata, QueryHandler(JSActor* aActor, const JSActorMessageMeta& aMetadata,
Promise* aPromise); Promise* aPromise);
void RejectedCallback(JSContext* aCx, void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
void ResolvedCallback(JSContext* aCx, void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
private: private:
~QueryHandler() = default; ~QueryHandler() = default;

Просмотреть файл

@ -203,8 +203,8 @@ class ElementTranslationHandler : public PromiseNativeHandler {
mReturnValuePromise = aReturnValuePromise; mReturnValuePromise = aReturnValuePromise;
} }
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
ErrorResult rv; ErrorResult rv;
nsTArray<Nullable<L10nMessage>> l10nData; nsTArray<Nullable<L10nMessage>> l10nData;
@ -257,8 +257,8 @@ class ElementTranslationHandler : public PromiseNativeHandler {
mReturnValuePromise->MaybeResolveWithUndefined(); mReturnValuePromise->MaybeResolveWithUndefined();
} }
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
mReturnValuePromise->MaybeRejectWithClone(aCx, aValue); mReturnValuePromise->MaybeRejectWithClone(aCx, aValue);
} }
@ -377,12 +377,13 @@ class L10nRootTranslationHandler final : public PromiseNativeHandler {
explicit L10nRootTranslationHandler(Element* aRoot) : mRoot(aRoot) {} explicit L10nRootTranslationHandler(Element* aRoot) : mRoot(aRoot) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
DOMLocalization::SetRootInfo(mRoot); DOMLocalization::SetRootInfo(mRoot);
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
} ErrorResult& aRv) override {}
private: private:
~L10nRootTranslationHandler() = default; ~L10nRootTranslationHandler() = default;

Просмотреть файл

@ -69,12 +69,14 @@ class L10nReadyHandler final : public PromiseNativeHandler {
explicit L10nReadyHandler(Promise* aPromise, DocumentL10n* aDocumentL10n) explicit L10nReadyHandler(Promise* aPromise, DocumentL10n* aDocumentL10n)
: mPromise(aPromise), mDocumentL10n(aDocumentL10n) {} : mPromise(aPromise), mDocumentL10n(aDocumentL10n) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
mDocumentL10n->InitialTranslationCompleted(true); mDocumentL10n->InitialTranslationCompleted(true);
mPromise->MaybeResolveWithUndefined(); mPromise->MaybeResolveWithUndefined();
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
mDocumentL10n->InitialTranslationCompleted(false); mDocumentL10n->InitialTranslationCompleted(false);
nsTArray<nsCString> errors{ nsTArray<nsCString> errors{

Просмотреть файл

@ -165,10 +165,11 @@ class L10nMutationFinalizationHandler final : public PromiseNativeHandler {
explicit L10nMutationFinalizationHandler(nsIGlobalObject* aGlobal) explicit L10nMutationFinalizationHandler(nsIGlobalObject* aGlobal)
: mGlobal(aGlobal) {} : mGlobal(aGlobal) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
} ErrorResult& aRv) override {}
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
nsTArray<nsCString> errors{ nsTArray<nsCString> errors{
"[dom/l10n] Errors during l10n mutation frame."_ns, "[dom/l10n] Errors during l10n mutation frame."_ns,
}; };

Просмотреть файл

@ -48,7 +48,8 @@ Promise& Lock::GetWaitingPromise() {
return *mWaitingPromise; return *mWaitingPromise;
} }
void Lock::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) { void Lock::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (mLockRequestChild) { if (mLockRequestChild) {
locks::PLockRequestChild::Send__delete__(mLockRequestChild, false); locks::PLockRequestChild::Send__delete__(mLockRequestChild, false);
mLockRequestChild = nullptr; mLockRequestChild = nullptr;
@ -56,7 +57,8 @@ void Lock::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) {
mReleasedPromise->MaybeResolve(aValue); mReleasedPromise->MaybeResolve(aValue);
} }
void Lock::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) { void Lock::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (mLockRequestChild) { if (mLockRequestChild) {
locks::PLockRequestChild::Send__delete__(mLockRequestChild, false); locks::PLockRequestChild::Send__delete__(mLockRequestChild, false);
mLockRequestChild = nullptr; mLockRequestChild = nullptr;

Просмотреть файл

@ -52,10 +52,10 @@ class Lock final : public PromiseNativeHandler, public nsWrapperCache {
Promise& GetWaitingPromise(); Promise& GetWaitingPromise();
// PromiseNativeHandler // PromiseNativeHandler
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
private: private:
nsCOMPtr<nsIGlobalObject> mOwner; nsCOMPtr<nsIGlobalObject> mOwner;

Просмотреть файл

@ -110,7 +110,8 @@ class TabCapturedHandler final : public dom::PromiseNativeHandler {
aPromise->AppendNativeHandler(handler); aPromise->AppendNativeHandler(handler);
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MonitorAutoLock monitor(mEngine->mMonitor); MonitorAutoLock monitor(mEngine->mMonitor);
if (NS_WARN_IF(!aValue.isObject())) { if (NS_WARN_IF(!aValue.isObject())) {
@ -131,7 +132,8 @@ class TabCapturedHandler final : public dom::PromiseNativeHandler {
monitor.Notify(); monitor.Notify();
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MonitorAutoLock monitor(mEngine->mMonitor); MonitorAutoLock monitor(mEngine->mMonitor);
mEngine->mCapturing = false; mEngine->mCapturing = false;

Просмотреть файл

@ -87,7 +87,8 @@ MerchantValidationEvent::MerchantValidationEvent(EventTarget* aOwner)
} }
void MerchantValidationEvent::ResolvedCallback(JSContext* aCx, void MerchantValidationEvent::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(aCx); MOZ_ASSERT(aCx);
MOZ_ASSERT(mRequest); MOZ_ASSERT(mRequest);
@ -112,7 +113,8 @@ void MerchantValidationEvent::ResolvedCallback(JSContext* aCx,
} }
void MerchantValidationEvent::RejectedCallback(JSContext* aCx, void MerchantValidationEvent::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(mRequest); MOZ_ASSERT(mRequest);
if (!mWaitForUpdate) { if (!mWaitForUpdate) {
return; return;

Просмотреть файл

@ -33,10 +33,10 @@ class MerchantValidationEvent : public Event, public PromiseNativeHandler {
virtual JSObject* WrapObjectInternal( virtual JSObject* WrapObjectInternal(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
static already_AddRefed<MerchantValidationEvent> Constructor( static already_AddRefed<MerchantValidationEvent> Constructor(
EventTarget* aOwner, const nsAString& aType, EventTarget* aOwner, const nsAString& aType,

Просмотреть файл

@ -1112,7 +1112,8 @@ void PaymentRequest::SetOptions(const PaymentOptions& aOptions) {
} }
void PaymentRequest::ResolvedCallback(JSContext* aCx, void PaymentRequest::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (!InFullyActiveDocument()) { if (!InFullyActiveDocument()) {
return; return;
} }
@ -1147,7 +1148,8 @@ void PaymentRequest::ResolvedCallback(JSContext* aCx,
} }
void PaymentRequest::RejectedCallback(JSContext* aCx, void PaymentRequest::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (!InFullyActiveDocument()) { if (!InFullyActiveDocument()) {
return; return;
} }

Просмотреть файл

@ -201,8 +201,10 @@ class PaymentRequest final : public DOMEventTargetHelper,
nsresult UpdatePaymentMethod(const nsAString& aMethodName, nsresult UpdatePaymentMethod(const nsAString& aMethodName,
const ChangeDetails& aMethodDetails); const ChangeDetails& aMethodDetails);
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
bool InFullyActiveDocument(); bool InFullyActiveDocument();

Просмотреть файл

@ -50,7 +50,8 @@ PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(EventTarget* aOwner)
} }
void PaymentRequestUpdateEvent::ResolvedCallback(JSContext* aCx, void PaymentRequestUpdateEvent::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(aCx); MOZ_ASSERT(aCx);
MOZ_ASSERT(mRequest); MOZ_ASSERT(mRequest);
if (!mRequest->InFullyActiveDocument()) { if (!mRequest->InFullyActiveDocument()) {
@ -93,7 +94,8 @@ void PaymentRequestUpdateEvent::ResolvedCallback(JSContext* aCx,
} }
void PaymentRequestUpdateEvent::RejectedCallback(JSContext* aCx, void PaymentRequestUpdateEvent::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(mRequest); MOZ_ASSERT(mRequest);
if (!mRequest->InFullyActiveDocument()) { if (!mRequest->InFullyActiveDocument()) {
return; return;

Просмотреть файл

@ -30,10 +30,10 @@ class PaymentRequestUpdateEvent : public Event, public PromiseNativeHandler {
virtual JSObject* WrapObjectInternal( virtual JSObject* WrapObjectInternal(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
static already_AddRefed<PaymentRequestUpdateEvent> Constructor( static already_AddRefed<PaymentRequestUpdateEvent> Constructor(
EventTarget* aOwner, const nsAString& aType, EventTarget* aOwner, const nsAString& aType,

Просмотреть файл

@ -23,9 +23,11 @@ class PromiseNativeThenHandlerBase : public PromiseNativeHandler {
PromiseNativeThenHandlerBase(Promise& aPromise) : mPromise(&aPromise) {} PromiseNativeThenHandlerBase(Promise& aPromise) : mPromise(&aPromise) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
protected: protected:
virtual ~PromiseNativeThenHandlerBase() = default; virtual ~PromiseNativeThenHandlerBase() = default;

Просмотреть файл

@ -232,7 +232,7 @@ void Promise::Then(JSContext* aCx,
} }
void PromiseNativeThenHandlerBase::ResolvedCallback( void PromiseNativeThenHandlerBase::ResolvedCallback(
JSContext* aCx, JS::Handle<JS::Value> aValue) { JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv) {
RefPtr<Promise> promise = CallResolveCallback(aCx, aValue); RefPtr<Promise> promise = CallResolveCallback(aCx, aValue);
if (promise) { if (promise) {
mPromise->MaybeResolve(promise); mPromise->MaybeResolve(promise);
@ -242,7 +242,7 @@ void PromiseNativeThenHandlerBase::ResolvedCallback(
} }
void PromiseNativeThenHandlerBase::RejectedCallback( void PromiseNativeThenHandlerBase::RejectedCallback(
JSContext* aCx, JS::Handle<JS::Value> aValue) { JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv) {
mPromise->MaybeReject(aValue); mPromise->MaybeReject(aValue);
} }
@ -333,16 +333,17 @@ static bool NativeHandlerCallback(JSContext* aCx, unsigned aArgc,
v = js::GetFunctionNativeReserved(&args.callee(), SLOT_NATIVEHANDLER_TASK); v = js::GetFunctionNativeReserved(&args.callee(), SLOT_NATIVEHANDLER_TASK);
NativeHandlerTask task = static_cast<NativeHandlerTask>(v.toInt32()); NativeHandlerTask task = static_cast<NativeHandlerTask>(v.toInt32());
ErrorResult rv;
if (task == NativeHandlerTask::Resolve) { if (task == NativeHandlerTask::Resolve) {
// handler is kept alive by "obj" on the stack. // handler is kept alive by "obj" on the stack.
MOZ_KnownLive(handler)->ResolvedCallback(aCx, args.get(0)); MOZ_KnownLive(handler)->ResolvedCallback(aCx, args.get(0), rv);
} else { } else {
MOZ_ASSERT(task == NativeHandlerTask::Reject); MOZ_ASSERT(task == NativeHandlerTask::Reject);
// handler is kept alive by "obj" on the stack. // handler is kept alive by "obj" on the stack.
MOZ_KnownLive(handler)->RejectedCallback(aCx, args.get(0)); MOZ_KnownLive(handler)->RejectedCallback(aCx, args.get(0), rv);
} }
return true; return !rv.MaybeSetPendingException(aCx);
} }
static JSObject* CreateNativeHandlerFunction(JSContext* aCx, static JSObject* CreateNativeHandlerFunction(JSContext* aCx,
@ -380,16 +381,18 @@ class PromiseNativeHandlerShim final : public PromiseNativeHandler {
} }
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
RefPtr<PromiseNativeHandler> inner = std::move(mInner); RefPtr<PromiseNativeHandler> inner = std::move(mInner);
inner->ResolvedCallback(aCx, aValue); inner->ResolvedCallback(aCx, aValue, aRv);
MOZ_ASSERT(!mInner); MOZ_ASSERT(!mInner);
} }
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
RefPtr<PromiseNativeHandler> inner = std::move(mInner); RefPtr<PromiseNativeHandler> inner = std::move(mInner);
inner->RejectedCallback(aCx, aValue); inner->RejectedCallback(aCx, aValue, aRv);
MOZ_ASSERT(!mInner); MOZ_ASSERT(!mInner);
} }
@ -770,12 +773,14 @@ void PromiseWorkerProxy::RunCallback(JSContext* aCx,
} }
void PromiseWorkerProxy::ResolvedCallback(JSContext* aCx, void PromiseWorkerProxy::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
RunCallback(aCx, aValue, &Promise::MaybeResolve); RunCallback(aCx, aValue, &Promise::MaybeResolve);
} }
void PromiseWorkerProxy::RejectedCallback(JSContext* aCx, void PromiseWorkerProxy::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
RunCallback(aCx, aValue, &Promise::MaybeReject); RunCallback(aCx, aValue, &Promise::MaybeReject);
} }

Просмотреть файл

@ -24,7 +24,8 @@ DomPromiseListener::~DomPromiseListener() {
} }
void DomPromiseListener::ResolvedCallback(JSContext* aCx, void DomPromiseListener::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (mResolve) { if (mResolve) {
mResolve(aCx, aValue); mResolve(aCx, aValue);
} }
@ -33,7 +34,8 @@ void DomPromiseListener::ResolvedCallback(JSContext* aCx,
} }
void DomPromiseListener::RejectedCallback(JSContext* aCx, void DomPromiseListener::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
if (mReject) { if (mReject) {
nsresult errorCode; nsresult errorCode;
if (!aValue.isInt32()) { if (!aValue.isInt32()) {

Просмотреть файл

@ -10,6 +10,7 @@
#include <functional> #include <functional>
#include "js/TypeDecls.h" #include "js/TypeDecls.h"
#include "js/Value.h" #include "js/Value.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
#include "nsISupports.h" #include "nsISupports.h"
@ -27,12 +28,12 @@ class PromiseNativeHandler : public nsISupports {
public: public:
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) = 0; ErrorResult& aRv) = 0;
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) = 0; ErrorResult& aRv) = 0;
}; };
// This class is used to set C++ callbacks once a dom Promise a resolved or // This class is used to set C++ callbacks once a dom Promise a resolved or
@ -50,8 +51,10 @@ class DomPromiseListener final : public PromiseNativeHandler {
void Clear(); void Clear();
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
private: private:
~DomPromiseListener(); ~DomPromiseListener();

Просмотреть файл

@ -174,11 +174,11 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
bool* aSameProcessScopeRequired) override; bool* aSameProcessScopeRequired) override;
protected: protected:
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
private: private:
explicit PromiseWorkerProxy( explicit PromiseWorkerProxy(

Просмотреть файл

@ -39,7 +39,8 @@ class ReportFetchHandler final : public PromiseNativeHandler {
const nsTArray<ReportDeliver::ReportData>& aReportData) const nsTArray<ReportDeliver::ReportData>& aReportData)
: mReports(aReportData.Clone()) {} : mReports(aReportData.Clone()) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
if (!gReportDeliver) { if (!gReportDeliver) {
return; return;
} }
@ -76,7 +77,8 @@ class ReportFetchHandler final : public PromiseNativeHandler {
} }
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
if (gReportDeliver) { if (gReportDeliver) {
for (auto& report : mReports) { for (auto& report : mReports) {
++report.mFailures; ++report.mFailures;

Просмотреть файл

@ -432,9 +432,11 @@ class RespondWithHandler final : public PromiseNativeHandler {
mRequestWasHandled(false) { mRequestWasHandled(false) {
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
void CancelRequest(nsresult aStatus); void CancelRequest(nsresult aStatus);
@ -561,7 +563,8 @@ class MOZ_STACK_CLASS AutoCancel {
NS_IMPL_ISUPPORTS0(RespondWithHandler) NS_IMPL_ISUPPORTS0(RespondWithHandler)
void RespondWithHandler::ResolvedCallback(JSContext* aCx, void RespondWithHandler::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
AutoCancel autoCancel(this, mRequestURL); AutoCancel autoCancel(this, mRequestURL);
if (!aValue.isObject()) { if (!aValue.isObject()) {
@ -735,7 +738,8 @@ void RespondWithHandler::ResolvedCallback(JSContext* aCx,
} }
void RespondWithHandler::RejectedCallback(JSContext* aCx, void RespondWithHandler::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
nsCString sourceSpec = mRespondWithScriptSpec; nsCString sourceSpec = mRespondWithScriptSpec;
uint32_t line = mRespondWithLineNumber; uint32_t line = mRespondWithLineNumber;
uint32_t column = mRespondWithColumnNumber; uint32_t column = mRespondWithColumnNumber;
@ -879,11 +883,13 @@ class WaitUntilHandler final : public PromiseNativeHandler {
nsJSUtils::GetCallingLocation(aCx, mSourceSpec, &mLine, &mColumn); nsJSUtils::GetCallingLocation(aCx, mSourceSpec, &mLine, &mColumn);
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValu,
ErrorResult& aRve) override {
// do nothing, we are only here to report errors // do nothing, we are only here to report errors
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
mWorkerPrivate->AssertIsOnWorkerThread(); mWorkerPrivate->AssertIsOnWorkerThread();
nsString spec; nsString spec;

Просмотреть файл

@ -117,11 +117,13 @@ class ExtendableEventKeepAliveHandler final
/** /**
* PromiseNativeHandler interface * PromiseNativeHandler interface
*/ */
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
RemovePromise(Resolved); RemovePromise(Resolved);
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
RemovePromise(Rejected); RemovePromise(Rejected);
} }
@ -1344,7 +1346,8 @@ void FetchEventOp::GetRequestURL(nsAString& aOutRequestURL) {
} }
void FetchEventOp::ResolvedCallback(JSContext* aCx, void FetchEventOp::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(IsCurrentThreadRunningWorker()); MOZ_ASSERT(IsCurrentThreadRunningWorker());
MOZ_ASSERT(mRespondWithClosure); MOZ_ASSERT(mRespondWithClosure);
MOZ_ASSERT(!mRespondWithPromiseHolder.IsEmpty()); MOZ_ASSERT(!mRespondWithPromiseHolder.IsEmpty());
@ -1523,7 +1526,8 @@ void FetchEventOp::ResolvedCallback(JSContext* aCx,
} }
void FetchEventOp::RejectedCallback(JSContext* aCx, void FetchEventOp::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(IsCurrentThreadRunningWorker()); MOZ_ASSERT(IsCurrentThreadRunningWorker());
MOZ_ASSERT(mRespondWithClosure); MOZ_ASSERT(mRespondWithClosure);
MOZ_ASSERT(!mRespondWithPromiseHolder.IsEmpty()); MOZ_ASSERT(!mRespondWithPromiseHolder.IsEmpty());

Просмотреть файл

@ -136,9 +136,11 @@ class FetchEventOp final : public ExtendableEventOp,
* `{Resolved,Reject}Callback()` are use to handle the * `{Resolved,Reject}Callback()` are use to handle the
* `FetchEvent::RespondWith()` promise. * `FetchEvent::RespondWith()` promise.
*/ */
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
void MaybeFinished(); void MaybeFinished();

Просмотреть файл

@ -301,11 +301,13 @@ class KeepAliveHandler final : public ExtendableEvent::ExtensionsHandler,
return true; return true;
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
RemovePromise(Resolved); RemovePromise(Resolved);
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
RemovePromise(Rejected); RemovePromise(Rejected);
} }

Просмотреть файл

@ -210,11 +210,11 @@ class CompareCache final : public PromiseNativeHandler,
void Abort(); void Abort();
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
const nsString& Buffer() const { const nsString& Buffer() const {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -265,9 +265,11 @@ class CompareManager final : public PromiseNativeHandler {
nsresult Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, nsresult Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL,
const nsAString& aCacheName); const nsAString& aCacheName);
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
CacheStorage* CacheStorage_() { CacheStorage* CacheStorage_() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -1193,7 +1195,8 @@ CompareCache::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext,
} }
void CompareCache::ResolvedCallback(JSContext* aCx, void CompareCache::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
switch (mState) { switch (mState) {
@ -1208,7 +1211,8 @@ void CompareCache::ResolvedCallback(JSContext* aCx,
} }
void CompareCache::RejectedCallback(JSContext* aCx, void CompareCache::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (mState != Finished) { if (mState != Finished) {
@ -1344,7 +1348,8 @@ nsresult CompareManager::Initialize(nsIPrincipal* aPrincipal,
// 4. Put the value in the cache. // 4. Put the value in the cache.
// For this reason we have mState to know what callback we are handling. // For this reason we have mState to know what callback we are handling.
void CompareManager::ResolvedCallback(JSContext* aCx, void CompareManager::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mCallback); MOZ_ASSERT(mCallback);
@ -1374,7 +1379,8 @@ void CompareManager::ResolvedCallback(JSContext* aCx,
} }
void CompareManager::RejectedCallback(JSContext* aCx, void CompareManager::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
switch (mState) { switch (mState) {
case Finished: case Finished:
@ -1428,10 +1434,10 @@ class NoopPromiseHandler final : public PromiseNativeHandler {
NoopPromiseHandler() { AssertIsOnMainThread(); } NoopPromiseHandler() { AssertIsOnMainThread(); }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
} ErrorResult& aRv) override {}
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
} ErrorResult& aRv) override {}
private: private:
~NoopPromiseHandler() { AssertIsOnMainThread(); } ~NoopPromiseHandler() { AssertIsOnMainThread(); }

Просмотреть файл

@ -424,7 +424,8 @@ class ByteStreamPullIfNeededPromiseHandler final : public PromiseNativeHandler {
: PromiseNativeHandler(), mController(aController) {} : PromiseNativeHandler(), mController(aController) {}
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-call-pull-if-needed // https://streams.spec.whatwg.org/#readable-byte-stream-controller-call-pull-if-needed
// Step 7.1 // Step 7.1
mController->SetPulling(false); mController->SetPulling(false);
@ -434,19 +435,16 @@ class ByteStreamPullIfNeededPromiseHandler final : public PromiseNativeHandler {
mController->SetPullAgain(false); mController->SetPullAgain(false);
// Step 7.2.2 // Step 7.2.2
ErrorResult rv;
ReadableByteStreamControllerCallPullIfNeeded( ReadableByteStreamControllerCallPullIfNeeded(
aCx, MOZ_KnownLive(mController), rv); aCx, MOZ_KnownLive(mController), aRv);
(void)rv.MaybeSetPendingException(aCx, "PullIfNeeded Resolved Error");
} }
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-call-pull-if-needed // https://streams.spec.whatwg.org/#readable-byte-stream-controller-call-pull-if-needed
// Step 8.1 // Step 8.1
ErrorResult rv; ReadableByteStreamControllerError(mController, aValue, aRv);
ReadableByteStreamControllerError(mController, aValue, rv);
(void)rv.MaybeSetPendingException(aCx, "PullIfNeeded Rejected Error");
} }
}; };
@ -1661,7 +1659,8 @@ class ByteStreamStartPromiseNativeHandler final : public PromiseNativeHandler {
: PromiseNativeHandler(), mController(aController) {} : PromiseNativeHandler(), mController(aController) {}
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
MOZ_ASSERT(mController); MOZ_ASSERT(mController);
// https://streams.spec.whatwg.org/#set-up-readable-byte-stream-controller // https://streams.spec.whatwg.org/#set-up-readable-byte-stream-controller
@ -1676,18 +1675,16 @@ class ByteStreamStartPromiseNativeHandler final : public PromiseNativeHandler {
mController->SetPullAgain(false); mController->SetPullAgain(false);
// Step 16.4: // Step 16.4:
ErrorResult rv;
RefPtr<ReadableByteStreamController> stackController = mController; RefPtr<ReadableByteStreamController> stackController = mController;
ReadableByteStreamControllerCallPullIfNeeded(aCx, stackController, rv); ReadableByteStreamControllerCallPullIfNeeded(aCx, stackController, aRv);
(void)rv.MaybeSetPendingException(aCx, "StartPromise Resolve Error");
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#set-up-readable-byte-stream-controller // https://streams.spec.whatwg.org/#set-up-readable-byte-stream-controller
// Step 17.1 // Step 17.1
ErrorResult rv; ReadableByteStreamControllerError(mController, aValue, aRv);
ReadableByteStreamControllerError(mController, aValue, rv);
(void)rv.MaybeSetPendingException(aCx, "StartPromise Rejected Error");
} }
}; };

Просмотреть файл

@ -759,24 +759,21 @@ class ReadableStreamTeeClosePromiseHandler final : public PromiseNativeHandler {
explicit ReadableStreamTeeClosePromiseHandler(TeeState* aTeeState) explicit ReadableStreamTeeClosePromiseHandler(TeeState* aTeeState)
: mTeeState(aTeeState) {} : mTeeState(aTeeState) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
} ErrorResult& aRv) override {}
void RejectedCallback(JSContext* aCx, void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aReason,
JS::Handle<JS::Value> aReason) override { ErrorResult& aRv) override {
// Step 19.1. // Step 19.1.
ErrorResult rv;
ReadableStreamDefaultControllerError( ReadableStreamDefaultControllerError(
aCx, mTeeState->Branch1()->DefaultController(), aReason, rv); aCx, mTeeState->Branch1()->DefaultController(), aReason, aRv);
if (rv.MaybeSetPendingException( if (aRv.Failed()) {
aCx, "ReadableStreamDefaultTee Error During Promise Rejection")) {
return; return;
} }
// Step 19.2 // Step 19.2
ReadableStreamDefaultControllerError( ReadableStreamDefaultControllerError(
aCx, mTeeState->Branch2()->DefaultController(), aReason, rv); aCx, mTeeState->Branch2()->DefaultController(), aReason, aRv);
if (rv.MaybeSetPendingException( if (aRv.Failed()) {
aCx, "ReadableStreamDefaultTee Error During Promise Rejection")) {
return; return;
} }

Просмотреть файл

@ -420,8 +420,9 @@ class PullIfNeededNativePromiseHandler final : public PromiseNativeHandler {
ReadableStreamDefaultController* aController) ReadableStreamDefaultController* aController)
: PromiseNativeHandler(), mController(aController) {} : PromiseNativeHandler(), mController(aController) {}
MOZ_CAN_RUN_SCRIPT void ResolvedCallback( MOZ_CAN_RUN_SCRIPT void ResolvedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed // https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed
// Step 7.1 // Step 7.1
mController->SetPulling(false); mController->SetPulling(false);
@ -433,18 +434,15 @@ class PullIfNeededNativePromiseHandler final : public PromiseNativeHandler {
// Step 7.2.2 // Step 7.2.2
ErrorResult rv; ErrorResult rv;
ReadableStreamDefaultControllerCallPullIfNeeded( ReadableStreamDefaultControllerCallPullIfNeeded(
aCx, MOZ_KnownLive(mController), rv); aCx, MOZ_KnownLive(mController), aRv);
(void)rv.MaybeSetPendingException(aCx);
} }
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed // https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed
// Step 8.1 // Step 8.1
ErrorResult rv; ReadableStreamDefaultControllerError(aCx, mController, aValue, aRv);
ReadableStreamDefaultControllerError(aCx, mController, aValue, rv);
(void)rv.MaybeSetPendingException(aCx, "PullIfNeeded Rejected Error");
} }
}; };
@ -513,7 +511,8 @@ class StartPromiseNativeHandler final : public PromiseNativeHandler {
: PromiseNativeHandler(), mController(aController) {} : PromiseNativeHandler(), mController(aController) {}
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
MOZ_ASSERT(mController); MOZ_ASSERT(mController);
// https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller // https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller
@ -528,18 +527,16 @@ class StartPromiseNativeHandler final : public PromiseNativeHandler {
mController->SetPullAgain(false); mController->SetPullAgain(false);
// Step 11.4: // Step 11.4:
ErrorResult rv;
RefPtr<ReadableStreamDefaultController> stackController = mController; RefPtr<ReadableStreamDefaultController> stackController = mController;
ReadableStreamDefaultControllerCallPullIfNeeded(aCx, stackController, rv); ReadableStreamDefaultControllerCallPullIfNeeded(aCx, stackController, aRv);
(void)rv.MaybeSetPendingException(aCx, "StartPromise Resolved Error");
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller // https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller
// Step 12.1 // Step 12.1
ErrorResult rv; ReadableStreamDefaultControllerError(aCx, mController, aValue, aRv);
ReadableStreamDefaultControllerError(aCx, mController, aValue, rv);
(void)rv.MaybeSetPendingException(aCx, "StartPromise Rejected Error");
} }
}; };

Просмотреть файл

@ -927,12 +927,12 @@ class ForwardReaderErrorPromiseHandler final : public PromiseNativeHandler {
: mTeeState(aTeeState), mReader(aReader) {} : mTeeState(aTeeState), mReader(aReader) {}
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
} ErrorResult& aRv) override {}
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
// Step 14.1.1 // Step 14.1.1
if (mTeeState->GetReader() != mReader) { if (mTeeState->GetReader() != mReader) {
return; return;
@ -943,9 +943,8 @@ class ForwardReaderErrorPromiseHandler final : public PromiseNativeHandler {
// !ReadableByteStreamControllerError(branch1.[[controller]], r). // !ReadableByteStreamControllerError(branch1.[[controller]], r).
MOZ_ASSERT(mTeeState->Branch1()->Controller()->IsByte()); MOZ_ASSERT(mTeeState->Branch1()->Controller()->IsByte());
ReadableByteStreamControllerError( ReadableByteStreamControllerError(
mTeeState->Branch1()->Controller()->AsByte(), aValue, rv); mTeeState->Branch1()->Controller()->AsByte(), aValue, aRv);
if (rv.MaybeSetPendingException( if (aRv.Failed()) {
aCx, "ReadableByteStreamTee: Error during forwardReaderError")) {
return; return;
} }
@ -953,9 +952,8 @@ class ForwardReaderErrorPromiseHandler final : public PromiseNativeHandler {
// !ReadableByteStreamControllerError(branch2.[[controller]], r). // !ReadableByteStreamControllerError(branch2.[[controller]], r).
MOZ_ASSERT(mTeeState->Branch2()->Controller()->IsByte()); MOZ_ASSERT(mTeeState->Branch2()->Controller()->IsByte());
ReadableByteStreamControllerError( ReadableByteStreamControllerError(
mTeeState->Branch2()->Controller()->AsByte(), aValue, rv); mTeeState->Branch2()->Controller()->AsByte(), aValue, aRv);
if (rv.MaybeSetPendingException( if (aRv.Failed()) {
aCx, "ReadableByteStreamTee: Error during forwardReaderError")) {
return; return;
} }

Просмотреть файл

@ -116,7 +116,8 @@ class AbortStepsNativePromiseHandler final : public PromiseNativeHandler {
mStream(aStream), mStream(aStream),
mAbortRequestPromise(aAbortRequestPromise) {} mAbortRequestPromise(aAbortRequestPromise) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#writable-stream-finish-erroring // https://streams.spec.whatwg.org/#writable-stream-finish-erroring
// Step 13. Upon fulfillment of promise, // Step 13. Upon fulfillment of promise,
@ -128,7 +129,8 @@ class AbortStepsNativePromiseHandler final : public PromiseNativeHandler {
mStream->RejectCloseAndClosedPromiseIfNeeded(); mStream->RejectCloseAndClosedPromiseIfNeeded();
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#writable-stream-finish-erroring // https://streams.spec.whatwg.org/#writable-stream-finish-erroring
// Step 14. Upon rejection of promise with reason reason, // Step 14. Upon rejection of promise with reason reason,

Просмотреть файл

@ -139,8 +139,9 @@ class WritableStartPromiseNativeHandler final : public PromiseNativeHandler {
WritableStreamDefaultController* aController) WritableStreamDefaultController* aController)
: PromiseNativeHandler(), mController(aController) {} : PromiseNativeHandler(), mController(aController) {}
MOZ_CAN_RUN_SCRIPT void ResolvedCallback( MOZ_CAN_RUN_SCRIPT void ResolvedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#set-up-writable-stream-default-controller // https://streams.spec.whatwg.org/#set-up-writable-stream-default-controller
// Step 17. Upon fulfillment of startPromise, // Step 17. Upon fulfillment of startPromise,
// Step 17.1. Assert: stream.[[state]] is "writable" or "erroring". // Step 17.1. Assert: stream.[[state]] is "writable" or "erroring".
@ -152,16 +153,13 @@ class WritableStartPromiseNativeHandler final : public PromiseNativeHandler {
mController->SetStarted(true); mController->SetStarted(true);
// Step 17.3 Perform // Step 17.3 Perform
// ! WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller). // ! WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller).
IgnoredErrorResult rv;
WritableStreamDefaultControllerAdvanceQueueIfNeeded( WritableStreamDefaultControllerAdvanceQueueIfNeeded(
aCx, MOZ_KnownLive(mController), rv); aCx, MOZ_KnownLive(mController), aRv);
if (rv.MaybeSetPendingException(aCx)) {
return;
}
} }
MOZ_CAN_RUN_SCRIPT void RejectedCallback( MOZ_CAN_RUN_SCRIPT void RejectedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#set-up-writable-stream-default-controller // https://streams.spec.whatwg.org/#set-up-writable-stream-default-controller
RefPtr<WritableStream> stream = mController->Stream(); RefPtr<WritableStream> stream = mController->Stream();
// Step 18. Upon rejection of startPromise with reason r, // Step 18. Upon rejection of startPromise with reason r,
@ -171,11 +169,7 @@ class WritableStartPromiseNativeHandler final : public PromiseNativeHandler {
// Step 18.2. Set controller.[[started]] to true. // Step 18.2. Set controller.[[started]] to true.
mController->SetStarted(true); mController->SetStarted(true);
// Step 18.3. Perform ! WritableStreamDealWithRejection(stream, r). // Step 18.3. Perform ! WritableStreamDealWithRejection(stream, r).
IgnoredErrorResult rv; stream->DealWithRejection(aCx, aValue, aRv);
stream->DealWithRejection(aCx, aValue, rv);
if (rv.MaybeSetPendingException(aCx)) {
return;
}
} }
}; };
@ -326,7 +320,8 @@ class SinkCloseNativePromiseHandler final : public PromiseNativeHandler {
WritableStreamDefaultController* aController) WritableStreamDefaultController* aController)
: PromiseNativeHandler(), mController(aController) {} : PromiseNativeHandler(), mController(aController) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-close // https://streams.spec.whatwg.org/#writable-stream-default-controller-process-close
RefPtr<WritableStream> stream = mController->Stream(); RefPtr<WritableStream> stream = mController->Stream();
// Step 7. Upon fulfillment of sinkClosePromise, // Step 7. Upon fulfillment of sinkClosePromise,
@ -334,16 +329,16 @@ class SinkCloseNativePromiseHandler final : public PromiseNativeHandler {
stream->FinishInFlightClose(); stream->FinishInFlightClose();
} }
MOZ_CAN_RUN_SCRIPT void RejectedCallback( MOZ_CAN_RUN_SCRIPT void RejectedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-close // https://streams.spec.whatwg.org/#writable-stream-default-controller-process-close
RefPtr<WritableStream> stream = mController->Stream(); RefPtr<WritableStream> stream = mController->Stream();
// Step 8. Upon rejection of sinkClosePromise with reason reason, // Step 8. Upon rejection of sinkClosePromise with reason reason,
// Step 8.1. Perform ! WritableStreamFinishInFlightCloseWithError(stream, // Step 8.1. Perform ! WritableStreamFinishInFlightCloseWithError(stream,
// reason). // reason).
IgnoredErrorResult rv;
stream->FinishInFlightCloseWithError(aCx, aValue, rv); stream->FinishInFlightCloseWithError(aCx, aValue, aRv);
NS_WARNING_ASSERTION(!rv.Failed(), "FinishInFlightCloseWithError failed");
} }
private: private:
@ -410,8 +405,9 @@ class SinkWriteNativePromiseHandler final : public PromiseNativeHandler {
WritableStreamDefaultController* aController) WritableStreamDefaultController* aController)
: PromiseNativeHandler(), mController(aController) {} : PromiseNativeHandler(), mController(aController) {}
MOZ_CAN_RUN_SCRIPT void ResolvedCallback( MOZ_CAN_RUN_SCRIPT void ResolvedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-write // https://streams.spec.whatwg.org/#writable-stream-default-controller-process-write
RefPtr<WritableStream> stream = mController->Stream(); RefPtr<WritableStream> stream = mController->Stream();
@ -438,25 +434,21 @@ class SinkWriteNativePromiseHandler final : public PromiseNativeHandler {
bool backpressure = mController->GetBackpressure(); bool backpressure = mController->GetBackpressure();
// Step 4.5.2. Perform ! WritableStreamUpdateBackpressure(stream, // Step 4.5.2. Perform ! WritableStreamUpdateBackpressure(stream,
// backpressure). // backpressure).
IgnoredErrorResult rv; stream->UpdateBackpressure(backpressure, aRv);
stream->UpdateBackpressure(backpressure, rv); if (aRv.Failed()) {
// XXX Not Sure How To Handle Errors Inside Native Callbacks, return;
NS_WARNING_ASSERTION(!rv.Failed(), "UpdateBackpressure failed"); }
} }
// Step 4.6. Perform ! // Step 4.6. Perform !
// WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller). // WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller).
IgnoredErrorResult rv;
WritableStreamDefaultControllerAdvanceQueueIfNeeded( WritableStreamDefaultControllerAdvanceQueueIfNeeded(
aCx, MOZ_KnownLive(mController), rv); aCx, MOZ_KnownLive(mController), aRv);
// XXX Not Sure How To Handle Errors Inside Native Callbacks,
NS_WARNING_ASSERTION(
!rv.Failed(),
"WritableStreamDefaultControllerAdvanceQueueIfNeeded failed");
} }
MOZ_CAN_RUN_SCRIPT void RejectedCallback( MOZ_CAN_RUN_SCRIPT void RejectedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-write // https://streams.spec.whatwg.org/#writable-stream-default-controller-process-write
RefPtr<WritableStream> stream = mController->Stream(); RefPtr<WritableStream> stream = mController->Stream();
@ -468,10 +460,8 @@ class SinkWriteNativePromiseHandler final : public PromiseNativeHandler {
// Step 5.2. Perform ! WritableStreamFinishInFlightWriteWithError(stream, // Step 5.2. Perform ! WritableStreamFinishInFlightWriteWithError(stream,
// reason) // reason)
IgnoredErrorResult rv;
stream->FinishInFlightWriteWithError(aCx, aValue, rv); stream->FinishInFlightWriteWithError(aCx, aValue, aRv);
// XXX Not Sure How To Handle Errors Inside Native Callbacks,
NS_WARNING_ASSERTION(!rv.Failed(), "FinishInFlightWriteWithError failed");
} }
}; };

Просмотреть файл

@ -426,11 +426,11 @@ class CacheCreator final : public PromiseNativeHandler {
mLoaders.AppendElement(std::move(aLoader)); mLoaders.AppendElement(std::move(aLoader));
} }
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
// Try to load from cache with aPrincipal used for cache access. // Try to load from cache with aPrincipal used for cache access.
nsresult Load(nsIPrincipal* aPrincipal); nsresult Load(nsIPrincipal* aPrincipal);
@ -492,11 +492,11 @@ class CacheScriptLoader final : public PromiseNativeHandler,
void Load(Cache* aCache); void Load(Cache* aCache);
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
private: private:
~CacheScriptLoader() { AssertIsOnMainThread(); } ~CacheScriptLoader() { AssertIsOnMainThread(); }
@ -529,11 +529,11 @@ class CachePromiseHandler final : public PromiseNativeHandler {
MOZ_ASSERT(mRunnable); MOZ_ASSERT(mRunnable);
} }
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
private: private:
~CachePromiseHandler() { AssertIsOnMainThread(); } ~CachePromiseHandler() { AssertIsOnMainThread(); }
@ -1565,7 +1565,8 @@ LoaderListener::OnStartRequest(nsIRequest* aRequest) {
} }
void CachePromiseHandler::ResolvedCallback(JSContext* aCx, void CachePromiseHandler::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
AssertIsOnMainThread(); AssertIsOnMainThread();
// May already have been canceled by CacheScriptLoader::Fail from // May already have been canceled by CacheScriptLoader::Fail from
// CancelMainThread. // CancelMainThread.
@ -1582,7 +1583,8 @@ void CachePromiseHandler::ResolvedCallback(JSContext* aCx,
} }
void CachePromiseHandler::RejectedCallback(JSContext* aCx, void CachePromiseHandler::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
AssertIsOnMainThread(); AssertIsOnMainThread();
// May already have been canceled by CacheScriptLoader::Fail from // May already have been canceled by CacheScriptLoader::Fail from
// CancelMainThread. // CancelMainThread.
@ -1679,13 +1681,15 @@ void CacheCreator::FailLoaders(nsresult aRv) {
} }
void CacheCreator::RejectedCallback(JSContext* aCx, void CacheCreator::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
AssertIsOnMainThread(); AssertIsOnMainThread();
FailLoaders(NS_ERROR_FAILURE); FailLoaders(NS_ERROR_FAILURE);
} }
void CacheCreator::ResolvedCallback(JSContext* aCx, void CacheCreator::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
AssertIsOnMainThread(); AssertIsOnMainThread();
if (!aValue.isObject()) { if (!aValue.isObject()) {
@ -1802,14 +1806,16 @@ void CacheScriptLoader::Load(Cache* aCache) {
} }
void CacheScriptLoader::RejectedCallback(JSContext* aCx, void CacheScriptLoader::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
AssertIsOnMainThread(); AssertIsOnMainThread();
MOZ_ASSERT(mLoadInfo.mCacheStatus == ScriptLoadInfo::Uncached); MOZ_ASSERT(mLoadInfo.mCacheStatus == ScriptLoadInfo::Uncached);
Fail(NS_ERROR_FAILURE); Fail(NS_ERROR_FAILURE);
} }
void CacheScriptLoader::ResolvedCallback(JSContext* aCx, void CacheScriptLoader::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
AssertIsOnMainThread(); AssertIsOnMainThread();
// If we have already called 'Fail', we should not proceed. // If we have already called 'Fail', we should not proceed.
if (mFailed) { if (mFailed) {

Просмотреть файл

@ -164,8 +164,8 @@ class WorkletFetchHandler final : public PromiseNativeHandler,
return promise.forget(); return promise.forget();
} }
virtual void ResolvedCallback(JSContext* aCx, virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (!aValue.isObject()) { if (!aValue.isObject()) {
@ -256,8 +256,8 @@ class WorkletFetchHandler final : public PromiseNativeHandler,
return NS_OK; return NS_OK;
} }
virtual void RejectedCallback(JSContext* aCx, virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aValue) override { ErrorResult& aRv) override {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
RejectPromises(NS_ERROR_DOM_NETWORK_ERR); RejectPromises(NS_ERROR_DOM_NETWORK_ERR);
} }

Просмотреть файл

@ -1700,7 +1700,8 @@ class FileCreationHandler final : public PromiseNativeHandler {
aPromise->AppendNativeHandler(handler); aPromise->AppendNativeHandler(handler);
} }
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
if (NS_WARN_IF(!aValue.isObject())) { if (NS_WARN_IF(!aValue.isObject())) {
mXHR->LocalFileToBlobCompleted(nullptr); mXHR->LocalFileToBlobCompleted(nullptr);
return; return;
@ -1715,7 +1716,8 @@ class FileCreationHandler final : public PromiseNativeHandler {
mXHR->LocalFileToBlobCompleted(blob->Impl()); mXHR->LocalFileToBlobCompleted(blob->Impl());
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
mXHR->LocalFileToBlobCompleted(nullptr); mXHR->LocalFileToBlobCompleted(nullptr);
} }

Просмотреть файл

@ -458,8 +458,10 @@ class PromiseResolver final : public PromiseNativeHandler {
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
explicit PromiseResolver(Promise* aPromise); explicit PromiseResolver(Promise* aPromise);
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
protected: protected:
virtual ~PromiseResolver(); virtual ~PromiseResolver();
@ -477,12 +479,14 @@ NS_IMPL_RELEASE(PromiseResolver)
PromiseResolver::PromiseResolver(Promise* aPromise) { mPromise = aPromise; } PromiseResolver::PromiseResolver(Promise* aPromise) { mPromise = aPromise; }
void PromiseResolver::ResolvedCallback(JSContext* aCx, void PromiseResolver::ResolvedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
mPromise->MaybeResolveWithClone(aCx, aValue); mPromise->MaybeResolveWithClone(aCx, aValue);
} }
void PromiseResolver::RejectedCallback(JSContext* aCx, void PromiseResolver::RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
mPromise->MaybeRejectWithClone(aCx, aValue); mPromise->MaybeRejectWithClone(aCx, aValue);
} }

Просмотреть файл

@ -43,15 +43,17 @@ void ChromeCompatCallbackHandler::Create(
aPromise->AppendNativeHandler(handler); aPromise->AppendNativeHandler(handler);
} }
void ChromeCompatCallbackHandler::ResolvedCallback( void ChromeCompatCallbackHandler::ResolvedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
JS::RootedValue retval(aCx); JS::RootedValue retval(aCx);
IgnoredErrorResult rv; IgnoredErrorResult rv;
MOZ_KnownLive(mCallback)->Call({aValue}, &retval, rv); MOZ_KnownLive(mCallback)->Call({aValue}, &retval, rv);
} }
void ChromeCompatCallbackHandler::RejectedCallback( void ChromeCompatCallbackHandler::RejectedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) {
JS::RootedValue retval(aCx); JS::RootedValue retval(aCx);
IgnoredErrorResult rv; IgnoredErrorResult rv;
// Call the chrome-compatible callback without any parameter, the errors // Call the chrome-compatible callback without any parameter, the errors

Просмотреть файл

@ -139,10 +139,12 @@ class ChromeCompatCallbackHandler final : public dom::PromiseNativeHandler {
dom::Promise* aPromise, dom::Promise* aPromise,
const RefPtr<dom::Function>& aCallback); const RefPtr<dom::Function>& aCallback);
MOZ_CAN_RUN_SCRIPT void ResolvedCallback( MOZ_CAN_RUN_SCRIPT void ResolvedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override; JS::Handle<JS::Value> aValue,
MOZ_CAN_RUN_SCRIPT void RejectedCallback( ErrorResult& aRv) override;
JSContext* aCx, JS::Handle<JS::Value> aValue) override; MOZ_CAN_RUN_SCRIPT void RejectedCallback(JSContext* aCx,
JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
private: private:
ChromeCompatCallbackHandler(ExtensionBrowser* aExtensionBrowser, ChromeCompatCallbackHandler(ExtensionBrowser* aExtensionBrowser,

Просмотреть файл

@ -678,12 +678,12 @@ void ExtensionListenerCallPromiseResultHandler::WorkerRunCallback(
} }
void ExtensionListenerCallPromiseResultHandler::ResolvedCallback( void ExtensionListenerCallPromiseResultHandler::ResolvedCallback(
JSContext* aCx, JS::Handle<JS::Value> aValue) { JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv) {
WorkerRunCallback(aCx, aValue, PromiseCallbackType::Resolve); WorkerRunCallback(aCx, aValue, PromiseCallbackType::Resolve);
} }
void ExtensionListenerCallPromiseResultHandler::RejectedCallback( void ExtensionListenerCallPromiseResultHandler::RejectedCallback(
JSContext* aCx, JS::Handle<JS::Value> aValue) { JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv) {
WorkerRunCallback(aCx, aValue, PromiseCallbackType::Reject); WorkerRunCallback(aCx, aValue, PromiseCallbackType::Reject);
} }

Просмотреть файл

@ -200,8 +200,10 @@ class ExtensionListenerCallPromiseResultHandler
dom::ThreadSafeWorkerRef* aWorkerRef); dom::ThreadSafeWorkerRef* aWorkerRef);
// PromiseNativeHandler // PromiseNativeHandler
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override; ErrorResult& aRv) override;
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override;
enum class PromiseCallbackType { Resolve, Reject }; enum class PromiseCallbackType { Resolve, Reject };

Просмотреть файл

@ -359,8 +359,9 @@ class AssertRejectsHandler final : public dom::PromiseNativeHandler {
aPromise->AppendNativeHandler(handler); aPromise->AppendNativeHandler(handler);
} }
MOZ_CAN_RUN_SCRIPT void ResolvedCallback( MOZ_CAN_RUN_SCRIPT void ResolvedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
nsAutoJSString expectedErrorSource; nsAutoJSString expectedErrorSource;
JS::Rooted<JS::Value> rootedExpectedMatchValue(aCx, mExpectedMatchValue); JS::Rooted<JS::Value> rootedExpectedMatchValue(aCx, mExpectedMatchValue);
JS::Rooted<JSString*> expectedErrorToSource( JS::Rooted<JSString*> expectedErrorToSource(
@ -402,8 +403,9 @@ class AssertRejectsHandler final : public dom::PromiseNativeHandler {
mOutPromise->MaybeResolve(JS::UndefinedValue()); mOutPromise->MaybeResolve(JS::UndefinedValue());
} }
MOZ_CAN_RUN_SCRIPT void RejectedCallback( MOZ_CAN_RUN_SCRIPT void RejectedCallback(JSContext* aCx,
JSContext* aCx, JS::Handle<JS::Value> aValue) override { JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
JS::Rooted<JS::Value> expectedMatchRooted(aCx, mExpectedMatchValue); JS::Rooted<JS::Value> expectedMatchRooted(aCx, mExpectedMatchValue);
ErrorResult erv; ErrorResult erv;

Просмотреть файл

@ -3057,11 +3057,13 @@ class L10nReadyPromiseHandler final : public dom::PromiseNativeHandler {
L10nReadyPromiseHandler(Document* aDoc, nsIWidget* aParentWindow) L10nReadyPromiseHandler(Document* aDoc, nsIWidget* aParentWindow)
: mDocument(aDoc), mWindow(aParentWindow) {} : mDocument(aDoc), mWindow(aParentWindow) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
LoadNativeMenus(mDocument, mWindow); LoadNativeMenus(mDocument, mWindow);
} }
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override { void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
ErrorResult& aRv) override {
// Again, this shouldn't happen, but fallback to loading the menus as is. // Again, this shouldn't happen, but fallback to loading the menus as is.
NS_WARNING( NS_WARNING(
"L10nReadyPromiseHandler rejected - loading fallback native " "L10nReadyPromiseHandler rejected - loading fallback native "