Bug 1502355 - Make |WritableStreamDefaultWriterWrite| return a narrower |PromiseObject*| type for more clarity. r=arai

Differential Revision: https://phabricator.services.mozilla.com/D71115
This commit is contained in:
Jeff Walden 2020-04-16 07:43:25 +00:00
Родитель 90b380e4ae
Коммит 69ce41f4d6
3 изменённых файлов: 7 добавлений и 4 удалений

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

@ -42,6 +42,7 @@ using JS::Value;
using js::ClassSpec; using js::ClassSpec;
using js::GetErrorMessage; using js::GetErrorMessage;
using js::PromiseObject;
using js::ReturnPromiseRejectedWithPendingError; using js::ReturnPromiseRejectedWithPendingError;
using js::UnwrapAndTypeCheckArgument; using js::UnwrapAndTypeCheckArgument;
using js::UnwrapAndTypeCheckThis; using js::UnwrapAndTypeCheckThis;
@ -502,7 +503,7 @@ static MOZ_MUST_USE bool WritableStreamDefaultWriter_write(JSContext* cx,
} }
// Step 3: Return this.[[readyPromise]]. // Step 3: Return this.[[readyPromise]].
JSObject* promise = PromiseObject* promise =
WritableStreamDefaultWriterWrite(cx, unwrappedWriter, args.get(0)); WritableStreamDefaultWriterWrite(cx, unwrappedWriter, args.get(0));
if (!promise) { if (!promise) {
return false; return false;

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

@ -312,7 +312,7 @@ bool js::WritableStreamDefaultWriterRelease(
* Streams spec, 4.6.9. * Streams spec, 4.6.9.
* WritableStreamDefaultWriterWrite ( writer, chunk ) * WritableStreamDefaultWriterWrite ( writer, chunk )
*/ */
JSObject* js::WritableStreamDefaultWriterWrite( PromiseObject* js::WritableStreamDefaultWriterWrite(
JSContext* cx, Handle<WritableStreamDefaultWriter*> unwrappedWriter, JSContext* cx, Handle<WritableStreamDefaultWriter*> unwrappedWriter,
Handle<Value> chunk) { Handle<Value> chunk) {
cx->check(chunk); cx->check(chunk);
@ -351,7 +351,8 @@ JSObject* js::WritableStreamDefaultWriterWrite(
} }
auto RejectWithStoredError = auto RejectWithStoredError =
[](JSContext* cx, Handle<WritableStream*> unwrappedStream) -> JSObject* { [](JSContext* cx,
Handle<WritableStream*> unwrappedStream) -> PromiseObject* {
Rooted<Value> storedError(cx, unwrappedStream->storedError()); Rooted<Value> storedError(cx, unwrappedStream->storedError());
if (!cx->compartment()->wrap(cx, &storedError)) { if (!cx->compartment()->wrap(cx, &storedError)) {
return nullptr; return nullptr;

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

@ -19,6 +19,7 @@ class JS_PUBLIC_API JSObject;
namespace js { namespace js {
class PromiseObject;
class WritableStreamDefaultWriter; class WritableStreamDefaultWriter;
extern JSObject* WritableStreamDefaultWriterAbort( extern JSObject* WritableStreamDefaultWriterAbort(
@ -43,7 +44,7 @@ extern MOZ_MUST_USE bool WritableStreamDefaultWriterGetDesiredSize(
extern MOZ_MUST_USE bool WritableStreamDefaultWriterRelease( extern MOZ_MUST_USE bool WritableStreamDefaultWriterRelease(
JSContext* cx, JS::Handle<WritableStreamDefaultWriter*> unwrappedWriter); JSContext* cx, JS::Handle<WritableStreamDefaultWriter*> unwrappedWriter);
extern JSObject* WritableStreamDefaultWriterWrite( extern PromiseObject* WritableStreamDefaultWriterWrite(
JSContext* cx, JS::Handle<WritableStreamDefaultWriter*> unwrappedWriter, JSContext* cx, JS::Handle<WritableStreamDefaultWriter*> unwrappedWriter,
JS::Handle<JS::Value> chunk); JS::Handle<JS::Value> chunk);