Bug 1582348 - Make WritableStream.prototype.abort return a promise rejected with a TypeError if passed an improper |this|, not throw that TypeError. r=arai
☠☠ backed out by 7e3a8ad78d7e ☠ ☠
authorJeff Walden <jwalden@mit.edu>
Wed, 06 Nov 2019 21:32:28 +0000
changeset 500977 bf2338a0da807be49e8790ba373d246098436431
parent 500976 a4bf67b78cde23cd48bb152ba006ff91cc3e457e
child 500978 99ed7bab2aa72caa6f7d32c07972f427fa6ee4be
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [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);