diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /dom/streams/UnderlyingSinkCallbackHelpers.cpp | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/streams/UnderlyingSinkCallbackHelpers.cpp')
-rw-r--r-- | dom/streams/UnderlyingSinkCallbackHelpers.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/dom/streams/UnderlyingSinkCallbackHelpers.cpp b/dom/streams/UnderlyingSinkCallbackHelpers.cpp index 91562a2db3..6277fd26e0 100644 --- a/dom/streams/UnderlyingSinkCallbackHelpers.cpp +++ b/dom/streams/UnderlyingSinkCallbackHelpers.cpp @@ -111,6 +111,24 @@ already_AddRefed<Promise> UnderlyingSinkAlgorithms::AbortCallback( } // https://streams.spec.whatwg.org/#writable-set-up +// This one is not covered by the above section as the spec expects any spec +// implementation to explicitly return a promise for this callback. It's still +// useful for Gecko as error handling is very frequently done with +// ErrorResult instead of a rejected promise. See also +// https://github.com/whatwg/streams/issues/1253. +already_AddRefed<Promise> UnderlyingSinkAlgorithmsWrapper::WriteCallback( + JSContext* aCx, JS::Handle<JS::Value> aChunk, + WritableStreamDefaultController& aController, ErrorResult& aRv) { + nsCOMPtr<nsIGlobalObject> global = xpc::CurrentNativeGlobal(aCx); + return PromisifyAlgorithm( + global, + [&](ErrorResult& aRv) { + return WriteCallbackImpl(aCx, aChunk, aController, aRv); + }, + aRv); +} + +// https://streams.spec.whatwg.org/#writable-set-up // Step 2.1: Let closeAlgorithmWrapper be an algorithm that runs these steps: already_AddRefed<Promise> UnderlyingSinkAlgorithmsWrapper::CloseCallback( JSContext* aCx, ErrorResult& aRv) { @@ -182,19 +200,20 @@ WritableStreamToOutput::OnOutputStreamReady(nsIAsyncOutputStream* aStream) { return NS_OK; } -already_AddRefed<Promise> WritableStreamToOutput::WriteCallback( +already_AddRefed<Promise> WritableStreamToOutput::WriteCallbackImpl( JSContext* aCx, JS::Handle<JS::Value> aChunk, - WritableStreamDefaultController& aController, ErrorResult& aError) { + WritableStreamDefaultController& aController, ErrorResult& aRv) { ArrayBufferViewOrArrayBuffer data; if (!data.Init(aCx, aChunk)) { - aError.StealExceptionFromJSContext(aCx); + aRv.MightThrowJSException(); + aRv.StealExceptionFromJSContext(aCx); return nullptr; } // buffer/bufferView MOZ_ASSERT(data.IsArrayBuffer() || data.IsArrayBufferView()); - RefPtr<Promise> promise = Promise::Create(mParent, aError); - if (NS_WARN_IF(aError.Failed())) { + RefPtr<Promise> promise = Promise::Create(mParent, aRv); + if (NS_WARN_IF(aRv.Failed())) { return nullptr; } |