Title: [191584] trunk
Revision
191584
Author
[email protected]
Date
2015-10-26 08:09:16 -0700 (Mon, 26 Oct 2015)

Log Message

[Streams API] Implement abort method on writable streams
https://bugs.webkit.org/show_bug.cgi?id=150444

Reviewed by Darin Adler.

Source/WebCore:

Abort method on writable streams implemented according to the spec.

Current test set suffices. Expectations are updated accordingly.

* Modules/streams/StreamInternals.js:
(promiseInvokeOrFallbackOrNoop): Implemented according to the spec.
* Modules/streams/WritableStream.js:
(abort): Implemented according to the spec.

LayoutTests:

Test expectations updated.

* streams/reference-implementation/bad-underlying-sinks-expected.txt:
* streams/reference-implementation/brand-checks-expected.txt:
* streams/reference-implementation/pipe-to-expected.txt:
* streams/reference-implementation/writable-stream-abort-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191583 => 191584)


--- trunk/LayoutTests/ChangeLog	2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/ChangeLog	2015-10-26 15:09:16 UTC (rev 191584)
@@ -1,3 +1,17 @@
+2015-10-26  Xabier Rodriguez Calvar  <[email protected]>
+
+        [Streams API] Implement abort method on writable streams
+        https://bugs.webkit.org/show_bug.cgi?id=150444
+
+        Reviewed by Darin Adler.
+
+        Test expectations updated.
+
+        * streams/reference-implementation/bad-underlying-sinks-expected.txt:
+        * streams/reference-implementation/brand-checks-expected.txt:
+        * streams/reference-implementation/pipe-to-expected.txt:
+        * streams/reference-implementation/writable-stream-abort-expected.txt:
+
 2015-10-25  Sun-woo Nam  <[email protected]>
 
         [EFL] Unreviewed gardening. some test expectations for media should be Failure.

Modified: trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt (191583 => 191584)


--- trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt	2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt	2015-10-26 15:09:16 UTC (rev 191584)
@@ -3,8 +3,8 @@
 PASS Underlying sink: throwing start method 
 FAIL Underlying sink: throwing write getter write not implemented
 FAIL Underlying sink: throwing write method write not implemented
-FAIL Underlying sink: throwing abort getter abort not implemented
-FAIL Underlying sink: throwing abort method abort not implemented
+PASS Underlying sink: throwing abort getter 
+PASS Underlying sink: throwing abort method 
 FAIL Underlying sink: throwing close getter close not implemented
 FAIL Underlying sink: throwing close method close not implemented
 

Modified: trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt (191583 => 191584)


--- trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt	2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt	2015-10-26 15:09:16 UTC (rev 191584)
@@ -20,7 +20,7 @@
 PASS WritableStream.prototype.closed enforces a brand check 
 PASS WritableStream.prototype.ready enforces a brand check 
 PASS WritableStream.prototype.state enforces a brand check 
-FAIL WritableStream.prototype.abort enforces a brand check abort not implemented
+PASS WritableStream.prototype.abort enforces a brand check 
 FAIL WritableStream.prototype.write enforces a brand check write not implemented
 FAIL WritableStream.prototype.close enforces a brand check close not implemented
 PASS ByteLengthQueuingStrategy.prototype.size should work generically on its this and its arguments 

Modified: trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt (191583 => 191584)


--- trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt	2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt	2015-10-26 15:09:16 UTC (rev 191584)
@@ -15,7 +15,7 @@
 FAIL Piping from an empty ReadableStream which becomes closed after a pipeTo call to a WritableStream in the waiting state whose writes never complete write not implemented
 FAIL Piping from an empty ReadableStream which becomes errored after a pipeTo call to a WritableStream in the waiting state write not implemented
 FAIL Piping to a duck-typed asynchronous "writable stream" works pipeTo is not implemented
-FAIL Piping to a stream that has been aborted passes through the error as the cancellation reason abort not implemented
+FAIL Piping to a stream that has been aborted passes through the error as the cancellation reason pipeTo is not implemented
 FAIL Piping to a stream and then aborting it passes through the error as the cancellation reason pipeTo is not implemented
 FAIL Piping to a stream that has been closed propagates a TypeError cancellation reason backward close not implemented
 FAIL Piping to a stream and then closing it propagates a TypeError cancellation reason backward pipeTo is not implemented

Modified: trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt (191583 => 191584)


--- trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt	2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt	2015-10-26 15:09:16 UTC (rev 191584)
@@ -1,14 +1,14 @@
 
-FAIL Aborting a WritableStream immediately prevents future writes abort not implemented
+FAIL Aborting a WritableStream immediately prevents future writes write not implemented
 FAIL Aborting a WritableStream prevents further writes after any that are in progress write not implemented
-FAIL Fulfillment value of ws.abort() call must be undefined even if the underlying sink returns a non-undefined value abort not implemented
-FAIL WritableStream if sink's abort throws, the promise returned by ws.abort() rejects abort not implemented
-FAIL Aborting a WritableStream passes through the given reason abort not implemented
-FAIL Aborting a WritableStream puts it in an errored state, with stored error equal to the abort reason abort not implemented
+PASS Fulfillment value of ws.abort() call must be undefined even if the underlying sink returns a non-undefined value 
+PASS WritableStream if sink's abort throws, the promise returned by ws.abort() rejects 
+PASS Aborting a WritableStream passes through the given reason 
+FAIL Aborting a WritableStream puts it in an errored state, with stored error equal to the abort reason write not implemented
 FAIL Aborting a WritableStream causes any outstanding ready promises to be fulfilled immediately write not implemented
 FAIL Aborting a WritableStream causes any outstanding write() promises to be rejected with the abort reason write not implemented
 FAIL Closing but then immediately aborting a WritableStream causes the stream to error close not implemented
 FAIL Closing a WritableStream and aborting it while it closes causes the stream to error close not implemented
 FAIL Aborting a WritableStream after it is closed is a no-op close not implemented
-FAIL WritableStream should call underlying sink's close if no abort is supplied abort not implemented
+PASS WritableStream should call underlying sink's close if no abort is supplied 
 

Modified: trunk/Source/WebCore/ChangeLog (191583 => 191584)


--- trunk/Source/WebCore/ChangeLog	2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/Source/WebCore/ChangeLog	2015-10-26 15:09:16 UTC (rev 191584)
@@ -1,3 +1,19 @@
+2015-10-26  Xabier Rodriguez Calvar  <[email protected]>
+
+        [Streams API] Implement abort method on writable streams
+        https://bugs.webkit.org/show_bug.cgi?id=150444
+
+        Reviewed by Darin Adler.
+
+        Abort method on writable streams implemented according to the spec.
+
+        Current test set suffices. Expectations are updated accordingly.
+
+        * Modules/streams/StreamInternals.js:
+        (promiseInvokeOrFallbackOrNoop): Implemented according to the spec.
+        * Modules/streams/WritableStream.js:
+        (abort): Implemented according to the spec.
+
 2015-10-25  Hunseop Jeong  <[email protected]>
 
         Use modern for-loops in WebCore/editing.

Modified: trunk/Source/WebCore/Modules/streams/StreamInternals.js (191583 => 191584)


--- trunk/Source/WebCore/Modules/streams/StreamInternals.js	2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/Source/WebCore/Modules/streams/StreamInternals.js	2015-10-26 15:09:16 UTC (rev 191584)
@@ -54,6 +54,22 @@
 
 }
 
+function promiseInvokeOrFallbackOrNoop(object, key1, args1, key2, args2)
+{
+    "use strict";
+
+    try {
+        const method = object[key1];
+        if (typeof method === "undefined")
+            return @promiseInvokeOrNoop(object, key2, args2);
+        const result = method.@apply(object, args1);
+        return Promise.resolve(result);
+    }
+    catch(error) {
+        return Promise.reject(error);
+    }
+}
+
 function validateAndNormalizeQueuingStrategy(size, highWaterMark)
 {
     "use strict";

Modified: trunk/Source/WebCore/Modules/streams/WritableStream.js (191583 => 191584)


--- trunk/Source/WebCore/Modules/streams/WritableStream.js	2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/Source/WebCore/Modules/streams/WritableStream.js	2015-10-26 15:09:16 UTC (rev 191584)
@@ -68,7 +68,20 @@
 {
     "use strict";
 
-    throw new EvalError("abort not implemented");
+    if (!@isWritableStream(this))
+        return Promise.reject(new @TypeError("The WritableStream.abort method can only be used on instances of WritableStream"));
+
+    if (this.@state === "closed")
+        return Promise.resolve(undefined);
+
+    if (this.@state === "errored")
+        return Promise.reject(this.@storedError);
+
+    @errorWritableStream.@apply(this, [reason]);
+
+    const sinkAbortPromise = @promiseInvokeOrFallbackOrNoop(this.@underlyingSink, "abort", [reason], "close", []);
+
+    return sinkAbortPromise.then(function() { return undefined; });
 }
 
 function close()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to