Title: [191669] trunk
Revision
191669
Author
calva...@igalia.com
Date
2015-10-28 08:14:39 -0700 (Wed, 28 Oct 2015)

Log Message

[Streams API] Add write method to writable stream
https://bugs.webkit.org/show_bug.cgi?id=150589

Reviewed by Darin Adler.

Source/WebCore:

Write method implemented on writable streams according to the spec.

Current test set suffices. Expectations are updated accordingly.

* Modules/streams/WritableStream.js:
(write):

LayoutTests:

Updated expectations.

* streams/reference-implementation/bad-strategies-expected.txt:
* streams/reference-implementation/bad-underlying-sinks-expected.txt:
* streams/reference-implementation/brand-checks-expected.txt:
* streams/reference-implementation/byte-length-queuing-strategy-expected.txt:
* streams/reference-implementation/count-queuing-strategy-expected.txt:
* streams/reference-implementation/pipe-to-expected.txt:
* streams/reference-implementation/writable-stream-abort-expected.txt:
* streams/reference-implementation/writable-stream-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191668 => 191669)


--- trunk/LayoutTests/ChangeLog	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/ChangeLog	2015-10-28 15:14:39 UTC (rev 191669)
@@ -1,3 +1,21 @@
+2015-10-28  Xabier Rodriguez Calvar  <calva...@igalia.com>
+
+        [Streams API] Add write method to writable stream
+        https://bugs.webkit.org/show_bug.cgi?id=150589
+
+        Reviewed by Darin Adler.
+
+        Updated expectations.
+
+        * streams/reference-implementation/bad-strategies-expected.txt:
+        * streams/reference-implementation/bad-underlying-sinks-expected.txt:
+        * streams/reference-implementation/brand-checks-expected.txt:
+        * streams/reference-implementation/byte-length-queuing-strategy-expected.txt:
+        * streams/reference-implementation/count-queuing-strategy-expected.txt:
+        * streams/reference-implementation/pipe-to-expected.txt:
+        * streams/reference-implementation/writable-stream-abort-expected.txt:
+        * streams/reference-implementation/writable-stream-expected.txt:
+
 2015-10-28  Hunseop Jeong  <hs85.je...@samsung.com>
 
         Unreviewed. EFL gardening: rebaseline tests after r191623.

Modified: trunk/LayoutTests/streams/reference-implementation/bad-strategies-expected.txt (191668 => 191669)


--- trunk/LayoutTests/streams/reference-implementation/bad-strategies-expected.txt	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/streams/reference-implementation/bad-strategies-expected.txt	2015-10-28 15:14:39 UTC (rev 191669)
@@ -5,8 +5,8 @@
 PASS Readable stream: invalid strategy.highWaterMark 
 PASS Readable stream: invalid strategy.size return value 
 PASS Writable stream: throwing strategy.size getter 
-FAIL Writable stream: throwing strategy.size method write not implemented
-FAIL Writable stream: invalid strategy.size return value write not implemented
+PASS Writable stream: throwing strategy.size method 
+PASS Writable stream: invalid strategy.size return value 
 PASS Writable stream: throwing strategy.highWaterMark getter 
 PASS Writable stream: invalid strategy.highWaterMark 
 

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


--- trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt	2015-10-28 15:14:39 UTC (rev 191669)
@@ -1,8 +1,8 @@
 
 PASS Underlying sink: throwing start getter 
 PASS Underlying sink: throwing start method 
-FAIL Underlying sink: throwing write getter write not implemented
-FAIL Underlying sink: throwing write method write not implemented
+PASS Underlying sink: throwing write getter 
+PASS Underlying sink: throwing write method 
 PASS Underlying sink: throwing abort getter 
 PASS Underlying sink: throwing abort method 
 PASS Underlying sink: throwing close getter 

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


--- trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt	2015-10-28 15:14:39 UTC (rev 191669)
@@ -21,7 +21,7 @@
 PASS WritableStream.prototype.ready enforces a brand check 
 PASS WritableStream.prototype.state enforces a brand check 
 PASS WritableStream.prototype.abort enforces a brand check 
-FAIL WritableStream.prototype.write enforces a brand check write not implemented
+PASS WritableStream.prototype.write enforces a brand check 
 PASS WritableStream.prototype.close enforces a brand check 
 PASS ByteLengthQueuingStrategy.prototype.size should work generically on its this and its arguments 
 PASS CountQueuingStrategy.prototype.size should work generically on its this and its arguments 

Modified: trunk/LayoutTests/streams/reference-implementation/byte-length-queuing-strategy-expected.txt (191668 => 191669)


--- trunk/LayoutTests/streams/reference-implementation/byte-length-queuing-strategy-expected.txt	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/streams/reference-implementation/byte-length-queuing-strategy-expected.txt	2015-10-28 15:14:39 UTC (rev 191669)
@@ -4,5 +4,5 @@
 PASS ByteLengthQueuingStrategy constructor behaves as expected with wrong arguments 
 PASS ByteLengthQueuingStrategy size behaves as expected with wrong arguments 
 PASS ByteLengthQueuingStrategy instances have the correct properties 
-FAIL Closing a writable stream with in-flight writes below the high water mark delays the close call properly write not implemented
+PASS Closing a writable stream with in-flight writes below the high water mark delays the close call properly 
 

Modified: trunk/LayoutTests/streams/reference-implementation/count-queuing-strategy-expected.txt (191668 => 191669)


--- trunk/LayoutTests/streams/reference-implementation/count-queuing-strategy-expected.txt	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/streams/reference-implementation/count-queuing-strategy-expected.txt	2015-10-28 15:14:39 UTC (rev 191669)
@@ -9,6 +9,6 @@
 PASS Correctly governs a ReadableStreamController's desiredSize property (HWM = 1) 
 PASS Correctly governs a ReadableStreamController's desiredSize property (HWM = 4) 
 PASS Can construct a writable stream with a valid CountQueuingStrategy 
-FAIL Correctly governs the value of a WritableStream's state property (HWM = 0) write not implemented
-FAIL Correctly governs the value of a WritableStream's state property (HWM = 4) write not implemented
+PASS Correctly governs the value of a WritableStream's state property (HWM = 0) 
+PASS Correctly governs the value of a WritableStream's state property (HWM = 4) 
 

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


--- trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt	2015-10-28 15:14:39 UTC (rev 191669)
@@ -1,19 +1,19 @@
 
 FAIL Piping from a ReadableStream from which lots of data are readable synchronously pipeTo is not implemented
 FAIL Piping from a ReadableStream in readable state to a WritableStream in closing state pipeTo is not implemented
-FAIL Piping from a ReadableStream in readable state to a WritableStream in errored state write not implemented
+FAIL Piping from a ReadableStream in readable state to a WritableStream in errored state pipeTo is not implemented
 FAIL Piping from a ReadableStream in the readable state which becomes closed after pipeTo call to a WritableStream in the writable state pipeTo is not implemented
 FAIL Piping from a ReadableStream in the readable state which becomes errored after pipeTo call to a WritableStream in the writable state pipeTo is not implemented
 FAIL Piping from an empty ReadableStream which becomes non-empty after pipeTo call to a WritableStream in the writable state pipeTo is not implemented
 FAIL Piping from an empty ReadableStream which becomes errored after pipeTo call to a WritableStream in the writable state pipeTo is not implemented
 FAIL Piping from an empty ReadableStream to a WritableStream in the writable state which becomes errored after a pipeTo call pipeTo is not implemented
-FAIL Piping from a non-empty ReadableStream to a WritableStream in the waiting state which becomes writable after a pipeTo call write not implemented
-FAIL Piping from a non-empty ReadableStream to a WritableStream in waiting state which becomes errored after a pipeTo call write not implemented
-FAIL Piping from a non-empty ReadableStream which becomes errored after pipeTo call to a WritableStream in the waiting state write not implemented
-FAIL Piping from a non-empty ReadableStream to a WritableStream in the waiting state where both become ready after a pipeTo write not implemented
-FAIL Piping from an empty ReadableStream to a WritableStream in the waiting state which becomes writable after a pipeTo call write not implemented
-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 from a non-empty ReadableStream to a WritableStream in the waiting state which becomes writable after a pipeTo call pipeTo is not implemented
+FAIL Piping from a non-empty ReadableStream to a WritableStream in waiting state which becomes errored after a pipeTo call pipeTo is not implemented
+FAIL Piping from a non-empty ReadableStream which becomes errored after pipeTo call to a WritableStream in the waiting state pipeTo is not implemented
+FAIL Piping from a non-empty ReadableStream to a WritableStream in the waiting state where both become ready after a pipeTo pipeTo is not implemented
+FAIL Piping from an empty ReadableStream to a WritableStream in the waiting state which becomes writable after a pipeTo call pipeTo is not implemented
+FAIL Piping from an empty ReadableStream which becomes closed after a pipeTo call to a WritableStream in the waiting state whose writes never complete pipeTo is not implemented
+FAIL Piping from an empty ReadableStream which becomes errored after a pipeTo call to a WritableStream in the waiting state pipeTo is 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 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

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


--- trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt	2015-10-28 15:14:39 UTC (rev 191669)
@@ -1,12 +1,12 @@
 
-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
+PASS Aborting a WritableStream immediately prevents future writes 
+PASS Aborting a WritableStream prevents further writes after any that are in progress 
 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
+PASS Aborting a WritableStream puts it in an errored state, with stored error equal to the abort reason 
+PASS Aborting a WritableStream causes any outstanding ready promises to be fulfilled immediately 
+PASS Aborting a WritableStream causes any outstanding write() promises to be rejected with the abort reason 
 PASS Closing but then immediately aborting a WritableStream causes the stream to error 
 PASS Closing a WritableStream and aborting it while it closes causes the stream to error 
 PASS Aborting a WritableStream after it is closed is a no-op 

Modified: trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt (191668 => 191669)


--- trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt	2015-10-28 15:14:39 UTC (rev 191669)
@@ -1,14 +1,14 @@
 
 PASS error argument is given to start method 
-FAIL Underlying sink's write won't be called until start finishes write not implemented
+PASS Underlying sink's write won't be called until start finishes 
 PASS Underlying sink's close won't be called until start finishes 
 PASS Fulfillment value of ws.close() call must be undefined even if the underlying sink returns a non-undefined value 
 PASS Underlying sink's write or close are never invoked if start throws 
 PASS Underlying sink's write or close are never invoked if the promise returned by start is rejected 
 PASS WritableStream can be constructed with no arguments 
 PASS WritableStream instances have the correct methods and properties 
-FAIL WritableStream with simple input, processed asynchronously write not implemented
-FAIL WritableStream with simple input, processed synchronously write not implemented
+PASS WritableStream with simple input, processed asynchronously 
+PASS WritableStream with simple input, processed synchronously 
 PASS WritableStream is writable and ready fulfills immediately if the strategy does not apply backpressure 
-FAIL Fulfillment value of ws.write() call must be undefined even if the underlying sink returns a non-undefined ovalue write not implemented
+PASS Fulfillment value of ws.write() call must be undefined even if the underlying sink returns a non-undefined ovalue 
 

Modified: trunk/Source/WebCore/ChangeLog (191668 => 191669)


--- trunk/Source/WebCore/ChangeLog	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/Source/WebCore/ChangeLog	2015-10-28 15:14:39 UTC (rev 191669)
@@ -1,3 +1,17 @@
+2015-10-28  Xabier Rodriguez Calvar  <calva...@igalia.com>
+
+        [Streams API] Add write method to writable stream
+        https://bugs.webkit.org/show_bug.cgi?id=150589
+
+        Reviewed by Darin Adler.
+
+        Write method implemented on writable streams according to the spec.
+
+        Current test set suffices. Expectations are updated accordingly.
+
+        * Modules/streams/WritableStream.js:
+        (write):
+
 2015-10-27  Hunseop Jeong  <hs85.je...@samsung.com>
 
         [Cairo] Incorrect dashed and dotted border painting after r177686.

Modified: trunk/Source/WebCore/Modules/streams/WritableStream.js (191668 => 191669)


--- trunk/Source/WebCore/Modules/streams/WritableStream.js	2015-10-28 14:36:27 UTC (rev 191668)
+++ trunk/Source/WebCore/Modules/streams/WritableStream.js	2015-10-28 15:14:39 UTC (rev 191669)
@@ -111,7 +111,40 @@
 {
     "use strict";
 
-    throw new EvalError("write not implemented");
+    if (!@isWritableStream(this))
+        return Promise.reject(new @TypeError("The WritableStream.close method can only be used on instances of WritableStream"));
+
+    if (this.@state === "closed" || this.@state === "closing")
+        return Promise.reject(new @TypeError("Cannot write on a WritableString that is closed or closing"));
+
+    if (this.@state === "errored")
+        return Promise.reject(this.@storedError);
+
+    // FIXME
+    // assert(this.@state === "writable" || this.@state === "waiting" || this.@state === undefined);
+
+    let chunkSize = 1;
+    if (th...@strategy.size !== undefined) {
+        try {
+            chunkSize = th...@strategy.size.@call(undefined, chunk);
+        } catch(e) {
+            @errorWritableStream.@call(this, e);
+            return Promise.reject(e);
+        }
+    }
+
+    const promise = @createNewStreamsPromise();
+    try {
+        @enqueueValueWithSize(this.@queue, { promise: promise, chunk: chunk }, chunkSize);
+    } catch (e) {
+        @errorWritableStream.@call(this, e);
+        return Promise.reject(e);
+    }
+
+    @syncWritableStreamStateWithQueue(this);
+    @callOrScheduleWritableStreamAdvanceQueue(this);
+
+    return promise;
 }
 
 function closed()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to