Diff
Modified: trunk/LayoutTests/ChangeLog (191621 => 191622)
--- trunk/LayoutTests/ChangeLog 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/LayoutTests/ChangeLog 2015-10-27 11:36:56 UTC (rev 191622)
@@ -1,3 +1,22 @@
+2015-10-27 Xabier Rodriguez Calvar <calva...@igalia.com>
+
+ [Streams API] Add close method to writable stream
+ https://bugs.webkit.org/show_bug.cgi?id=150560
+
+ Reviewed by Darin Adler.
+
+ New expectations after adding close method to writable stream.
+
+ Two tests were also flagged because of bug 147933 that prevents them from running properly in certain
+ conditions. So far this only happened in Mac, hence they were flagged only for it.
+
+ * platform/mac/TestExpectations:
+ * 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:
+ * streams/reference-implementation/writable-stream-expected.txt:
+
2015-10-26 Ryan Haddad <ryanhad...@apple.com>
Removing duplicated test expectations and removing debug flag from flaky fast/canvas/webgl tests
Modified: trunk/LayoutTests/platform/mac/TestExpectations (191621 => 191622)
--- trunk/LayoutTests/platform/mac/TestExpectations 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2015-10-27 11:36:56 UTC (rev 191622)
@@ -1348,3 +1348,7 @@
# Imported Blink tests which have not been investigated.
imported/blink/compositing/video/video-controls-layer-creation-squashing.html [ Pass ImageOnlyFailure ]
+
+# Promises callbacks issues create problems in the writable stream tests
+webkit.org/b/147933 streams/reference-implementation/count-queuing-strategy.html [ Pass Failure ]
+webkit.org/b/147933 streams/reference-implementation/writable-stream-abort.html [ Pass Failure ]
Modified: trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt (191621 => 191622)
--- trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt 2015-10-27 11:36:56 UTC (rev 191622)
@@ -5,6 +5,6 @@
FAIL Underlying sink: throwing write method write 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
+PASS Underlying sink: throwing close getter
+PASS Underlying sink: throwing close method
Modified: trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt (191621 => 191622)
--- trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt 2015-10-27 11:36:56 UTC (rev 191622)
@@ -22,7 +22,7 @@
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
-FAIL WritableStream.prototype.close enforces a brand check close not implemented
+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/pipe-to-expected.txt (191621 => 191622)
--- trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt 2015-10-27 11:36:56 UTC (rev 191622)
@@ -1,6 +1,6 @@
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 close 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 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
@@ -17,7 +17,7 @@
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
-FAIL Piping to a stream that has been closed propagates a TypeError cancellation reason backward close not implemented
+FAIL Piping to a stream that has been closed propagates a TypeError cancellation reason backward pipeTo is not implemented
FAIL Piping to a stream and then closing it propagates a TypeError cancellation reason backward pipeTo is not implemented
FAIL Piping to a stream that errors on write should pass through the error as the cancellation reason pipeTo is not implemented
FAIL Piping to a stream that errors on write should not pass through the error if the stream is already closed pipeTo is not implemented
Modified: trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt (191621 => 191622)
--- trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt 2015-10-27 11:36:56 UTC (rev 191622)
@@ -7,8 +7,8 @@
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
+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
PASS WritableStream should call underlying sink's close if no abort is supplied
Modified: trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt (191621 => 191622)
--- trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt 2015-10-27 11:36:56 UTC (rev 191622)
@@ -1,8 +1,8 @@
PASS error argument is given to start method
FAIL Underlying sink's write won't be called until start finishes write not implemented
-FAIL Underlying sink's close won't be called until start finishes close not implemented
-FAIL Fulfillment value of ws.close() call must be undefined even if the underlying sink returns a non-undefined value close not implemented
+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
Modified: trunk/Source/WebCore/ChangeLog (191621 => 191622)
--- trunk/Source/WebCore/ChangeLog 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/Source/WebCore/ChangeLog 2015-10-27 11:36:56 UTC (rev 191622)
@@ -1,3 +1,24 @@
+2015-10-27 Xabier Rodriguez Calvar <calva...@igalia.com>
+
+ [Streams API] Add close method to writable stream
+ https://bugs.webkit.org/show_bug.cgi?id=150560
+
+ Reviewed by Darin Adler.
+
+ Added the close method which requires three additional writable stream internal functions plus a queuing
+ function to retrieve a value from the queue according to the spec.
+
+ Current test set suffices. Expectations were updated accordingly.
+
+ * Modules/streams/StreamInternals.js:
+ (peekQueueValue):
+ * Modules/streams/WritableStream.js:
+ (close):
+ * Modules/streams/WritableStreamInternals.js:
+ (callOrScheduleWritableStreamAdvanceQueue):
+ (writableStreamAdvanceQueue):
+ (closeWritableStream): Added as per spec.
+
2015-10-26 Brady Eidson <beid...@apple.com>
Make IDBKeyData from a struct to a class.
Modified: trunk/Source/WebCore/Modules/streams/StreamInternals.js (191621 => 191622)
--- trunk/Source/WebCore/Modules/streams/StreamInternals.js 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/Source/WebCore/Modules/streams/StreamInternals.js 2015-10-27 11:36:56 UTC (rev 191622)
@@ -151,3 +151,11 @@
return undefined;
}
+
+function peekQueueValue(queue)
+{
+ // FIXME
+ // assert(queue.content.length > 0);
+
+ return queue.content[0].value;
+}
Modified: trunk/Source/WebCore/Modules/streams/WritableStream.js (191621 => 191622)
--- trunk/Source/WebCore/Modules/streams/WritableStream.js 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/Source/WebCore/Modules/streams/WritableStream.js 2015-10-27 11:36:56 UTC (rev 191622)
@@ -88,7 +88,23 @@
{
"use strict";
- throw new EvalError("close 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 close a WritableString that is closed or closing"));
+
+ if (this.@state === "errored")
+ return Promise.reject(this.@storedError);
+
+ if (this.@state === "waiting")
+ @resolveStreamsPromise(this.@readyPromise, undefined);
+
+ this.@state = "closing";
+ @enqueueValueWithSize(this.@queue, "close", 0);
+ @callOrScheduleWritableStreamAdvanceQueue(this);
+
+ return this.@closedPromise;
}
function write(chunk)
Modified: trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js (191621 => 191622)
--- trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js 2015-10-27 07:00:57 UTC (rev 191621)
+++ trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js 2015-10-27 11:36:56 UTC (rev 191622)
@@ -73,3 +73,69 @@
this.@state = "errored";
return undefined;
}
+
+function callOrScheduleWritableStreamAdvanceQueue(stream)
+{
+ if (!stream.@started)
+ stre...@startedpromise.then(function() { @writableStreamAdvanceQueue(stream); });
+ else
+ @writableStreamAdvanceQueue(stream);
+
+ return undefined;
+}
+
+function writableStreamAdvanceQueue(stream)
+{
+ if (stream.@queue.content.length === 0 || stream.@writing)
+ return undefined;
+
+ const writeRecord = @peekQueueValue(stream.@queue);
+ if (writeRecord === "close") {
+ // FIXME
+ // assert(stream.@state === "closing");
+ @dequeueValue(stream.@queue);
+ // FIXME
+ // assert(stream.@queue.content.length === 0);
+ @closeWritableStream(stream);
+ return undefined;
+ }
+
+ stream.@writing = true;
+ @promiseInvokeOrNoop(stream.@underlyingSink, "write", [writeRecord.chunk]).then(
+ function() {
+ if (stream.@state === "errored")
+ return;
+ stream.@writing = false;
+ @resolveStreamsPromise(writeRecord.promise, undefined);
+ @dequeueValue(stream.@queue);
+ @syncWritableStreamStateWithQueue(stream);
+ @writableStreamAdvanceQueue(stream);
+ },
+ function(r) {
+ @errorWritableStream.@apply(stream, [r]);
+ }
+ );
+
+ return undefined;
+}
+
+function closeWritableStream(stream)
+{
+ // FIXME
+ // assert(stream.@state === "closing");
+ @promiseInvokeOrNoop(stream.@underlyingSink, "close").then(
+ function() {
+ if (stream.@state === "errored")
+ return;
+ // FIXME
+ // assert(stream.@state === "closing");
+ @resolveStreamsPromise(stream.@closedPromise, undefined);
+ stream.@state = "closed";
+ },
+ function(r) {
+ @errorWritableStream.@apply(stream, [r]);
+ }
+ );
+
+ return undefined;
+}