Diff
Modified: trunk/LayoutTests/ChangeLog (208789 => 208790)
--- trunk/LayoutTests/ChangeLog 2016-11-16 12:00:03 UTC (rev 208789)
+++ trunk/LayoutTests/ChangeLog 2016-11-16 14:00:37 UTC (rev 208790)
@@ -1,3 +1,15 @@
+2016-11-16 Romain Bellessort <[email protected]>
+
+ [Readable Streams API] Implement ReadableByteStreamController close()
+ https://bugs.webkit.org/show_bug.cgi?id=164413
+
+ Reviewed by Darin Adler.
+
+ Updated test expectations for close() tests and added tests
+ to ensure errors are thrown in various cases defined by spec.
+
+ * streams/readable-byte-stream-controller.js: Updated.
+
2016-11-16 Yusuke Suzuki <[email protected]>
[ES6] Integrate ES6 Modules into WebCore
Modified: trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt (208789 => 208790)
--- trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt 2016-11-16 12:00:03 UTC (rev 208789)
+++ trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt 2016-11-16 14:00:37 UTC (rev 208790)
@@ -1,14 +1,24 @@
PASS Creating a ReadableStream with an underlyingSource with type property set to 'bytes' should succeed
PASS ReadableByteStreamController instances should have the correct list of properties
-PASS Calling error() with a this object different from ReadableByteStreamController should fail
-PASS Calling read() on a reader associated to a controller that has been errored should be rejected
-FAIL Calling read() on a reader associated to a controller that has been closed should not be rejected ReadableByteStreamController close() is not implemented
+PASS Calling error() with a this object different from ReadableByteStreamController should throw a TypeError
+PASS Calling close() with a this object different from ReadableByteStreamController should throw a TypeError
+PASS Calling error() after calling close() should throw a TypeError
+PASS Calling error() after calling error() should throw a TypeError
+PASS Calling close() after calling close() should throw a TypeError
+PASS Calling close() after calling error() should throw a TypeError
+PASS Calling read() on a reader associated to a controller that has been errored should fail with provided error
+PASS Calling read() on a reader associated to a controller that has been closed should not be rejected
FAIL Calling read() after a chunk has been enqueued should result in obtaining said chunk ReadableByteStreamController enqueue() is not implemented
PASS Creating a ReadableStream with an underlyingSource with type property set to 'bytes' should succeed
PASS ReadableByteStreamController instances should have the correct list of properties
-PASS Calling error() with a this object different from ReadableByteStreamController should fail
-PASS Calling read() on a reader associated to a controller that has been errored should be rejected
-FAIL Calling read() on a reader associated to a controller that has been closed should not be rejected ReadableByteStreamController close() is not implemented
+PASS Calling error() with a this object different from ReadableByteStreamController should throw a TypeError
+PASS Calling close() with a this object different from ReadableByteStreamController should throw a TypeError
+PASS Calling error() after calling close() should throw a TypeError
+PASS Calling error() after calling error() should throw a TypeError
+PASS Calling close() after calling close() should throw a TypeError
+PASS Calling close() after calling error() should throw a TypeError
+PASS Calling read() on a reader associated to a controller that has been errored should fail with provided error
+PASS Calling read() on a reader associated to a controller that has been closed should not be rejected
FAIL Calling read() after a chunk has been enqueued should result in obtaining said chunk ReadableByteStreamController enqueue() is not implemented
Modified: trunk/LayoutTests/streams/readable-byte-stream-controller.js (208789 => 208790)
--- trunk/LayoutTests/streams/readable-byte-stream-controller.js 2016-11-16 12:00:03 UTC (rev 208789)
+++ trunk/LayoutTests/streams/readable-byte-stream-controller.js 2016-11-16 14:00:37 UTC (rev 208790)
@@ -61,9 +61,91 @@
assert_throws(new TypeError("Can only call ReadableByteStreamController.error on instances of ReadableByteStreamController"),
function() { controller.error.apply(rs); });
-}, "Calling error() with a this object different from ReadableByteStreamController should fail");
+}, "Calling error() with a this object different from ReadableByteStreamController should throw a TypeError");
-const test2 = async_test("Calling read() on a reader associated to a controller that has been errored should be rejected");
+test(function() {
+ let controller;
+
+ const rs = new ReadableStream({
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ assert_throws(new TypeError("Can only call ReadableByteStreamController.close on instances of ReadableByteStreamController"),
+ function() { controller.close.apply(rs); });
+}, "Calling close() with a this object different from ReadableByteStreamController should throw a TypeError");
+
+test(function() {
+ let controller;
+
+ const rs = new ReadableStream({
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ assert_throws(new TypeError("ReadableStream is not readable"),
+ function() {
+ controller.close();
+ controller.error();
+ });
+}, "Calling error() after calling close() should throw a TypeError");
+
+test(function() {
+ let controller;
+
+ const rs = new ReadableStream({
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ assert_throws(new TypeError("ReadableStream is not readable"),
+ function() {
+ controller.error();
+ controller.error();
+ });
+}, "Calling error() after calling error() should throw a TypeError");
+
+test(function() {
+ let controller;
+
+ const rs = new ReadableStream({
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ assert_throws(new TypeError("Close has already been requested"),
+ function() {
+ controller.close();
+ controller.close();
+ });
+}, "Calling close() after calling close() should throw a TypeError");
+
+test(function() {
+ let controller;
+
+ const rs = new ReadableStream({
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ assert_throws(new TypeError("ReadableStream is not readable"),
+ function() {
+ controller.error();
+ controller.close();
+ });
+}, "Calling close() after calling error() should throw a TypeError");
+
+const test2 = async_test("Calling read() on a reader associated to a controller that has been errored should fail with provided error");
test2.step(function() {
let controller;
Modified: trunk/Source/WebCore/ChangeLog (208789 => 208790)
--- trunk/Source/WebCore/ChangeLog 2016-11-16 12:00:03 UTC (rev 208789)
+++ trunk/Source/WebCore/ChangeLog 2016-11-16 14:00:37 UTC (rev 208790)
@@ -1,3 +1,21 @@
+2016-11-16 Romain Bellessort <[email protected]>
+
+ [Readable Streams API] Implement ReadableByteStreamController close()
+ https://bugs.webkit.org/show_bug.cgi?id=164413
+
+ Reviewed by Darin Adler.
+
+ Implemented close() method of ReadableByteStreamController.
+
+ Updated test expectations for close() tests and added tests
+ to ensure errors are thrown in various cases defined by spec.
+
+ * Modules/streams/ReadableByteStreamController.js:
+ (close): Added.
+ * Modules/streams/ReadableByteStreamInternals.js:
+ (readableByteStreamControllerClose): Added.
+ * bindings/js/WebCoreBuiltinNames.h: Added bytesFilled.
+
2016-11-16 Philippe Normand <[email protected]>
[GStreamer][GL] build broken when using gst-plugins-bad from git
Modified: trunk/Source/WebCore/Modules/streams/ReadableByteStreamController.js (208789 => 208790)
--- trunk/Source/WebCore/Modules/streams/ReadableByteStreamController.js 2016-11-16 12:00:03 UTC (rev 208789)
+++ trunk/Source/WebCore/Modules/streams/ReadableByteStreamController.js 2016-11-16 14:00:37 UTC (rev 208790)
@@ -50,8 +50,16 @@
{
"use strict";
- //FIXME: Implement appropriate behavior.
- @throwTypeError("ReadableByteStreamController close() is not implemented");
+ if (!@isReadableByteStreamController(this))
+ throw @makeThisTypeError("ReadableByteStreamController", "close");
+
+ if (this.@closeRequested)
+ @throwTypeError("Close has already been requested");
+
+ if (this.@controlledReadableStream.@state !== @streamReadable)
+ @throwTypeError("ReadableStream is not readable");
+
+ @readableByteStreamControllerClose(this);
}
function byobRequest()
Modified: trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js (208789 => 208790)
--- trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js 2016-11-16 12:00:03 UTC (rev 208789)
+++ trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js 2016-11-16 14:00:37 UTC (rev 208790)
@@ -95,6 +95,30 @@
@readableStreamError(controller.@controlledReadableStream, e);
}
+function readableByteStreamControllerClose(controller)
+{
+ "use strict";
+
+ @assert(!controller.@closeRequested);
+ @assert(controller.@controlledReadableStream.@state === @streamReadable);
+
+ if (controller.@totalQueuedBytes > 0) {
+ controller.@closeRequested = true;
+ return;
+ }
+
+ if ([email protected] > 0) {
+ const firstPendingPullInto = @dequeueValue(controller.@pendingPullIntos);
+ if (firstPendingPullInto.@bytesFilled > 0) {
+ const e = new @TypeError("Close requested while there remain pending bytes");
+ @readableByteStreamControllerError(controller, e);
+ throw e;
+ }
+ }
+
+ @readableStreamClose(controller.@controlledReadableStream);
+}
+
function readableByteStreamControllerClearPendingPullIntos(controller)
{
"use strict";
Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (208789 => 208790)
--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2016-11-16 12:00:03 UTC (rev 208789)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2016-11-16 14:00:37 UTC (rev 208790)
@@ -35,6 +35,7 @@
macro(appendFromJS) \
macro(autoAllocateChunkSize) \
macro(body) \
+ macro(bytesFilled) \
macro(cancel) \
macro(cloneForJS) \
macro(closeRequested) \