Bug 1582348 - Make WritableStream.prototype.abort return a promise rejected with a TypeError if passed an improper |this|, not throw that TypeError. r=arai
authorJeff Walden <jwalden@mit.edu>
Thu, 07 Nov 2019 00:19:28 +0000
changeset 501032 9e620f21ea4ff9cbfd1219ca02785749aa0e292a
parent 501031 979d77ef56928092343868192f4d632ea074a892
child 501033 3ba2ca38372d8e90caf3bc186ebdf0408931aa87
push id99940
push userjwalden@mit.edu
push dateThu, 07 Nov 2019 00:41:19 +0000
treeherderautoland@8caeb3eb603c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1582348
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1582348 - Make WritableStream.prototype.abort return a promise rejected with a TypeError if passed an improper |this|, not throw that TypeError. r=arai Differential Revision: https://phabricator.services.mozilla.com/D51967
js/src/builtin/streams/WritableStream.cpp
--- a/js/src/builtin/streams/WritableStream.cpp
+++ b/js/src/builtin/streams/WritableStream.cpp
@@ -175,21 +175,22 @@ static bool WritableStream_locked(JSCont
 }
 
 /**
  * Streams spec, 4.2.5.2. abort(reason)
  */
 static bool WritableStream_abort(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
 
-  // Step 1: If ! WritableStream(this) is false, throw a TypeError exception.
+  // Step 1: If ! IsWritableStream(this) is false, return a promise rejected
+  //         with a TypeError exception.
   Rooted<WritableStream*> unwrappedStream(
       cx, UnwrapAndTypeCheckThis<WritableStream>(cx, args, "abort"));
   if (!unwrappedStream) {
-    return false;
+    return ReturnPromiseRejectedWithPendingError(cx, args);
   }
 
   // Step 2: If ! IsWritableStreamLocked(this) is true, return a promise
   //         rejected with a TypeError exception.
   if (unwrappedStream->isLocked()) {
     JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
                               JSMSG_CANT_USE_LOCKED_WRITABLESTREAM, "abort");
     return ReturnPromiseRejectedWithPendingError(cx, args);