Diff
Modified: trunk/LayoutTests/ChangeLog (208381 => 208382)
--- trunk/LayoutTests/ChangeLog 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/LayoutTests/ChangeLog 2016-11-04 10:39:09 UTC (rev 208382)
@@ -1,3 +1,15 @@
+2016-11-04 Romain Bellessort <[email protected]>
+
+ [Readable Streams API] Implement ByteStreamController error()
+ https://bugs.webkit.org/show_bug.cgi?id=164319
+
+ Reviewed by Youenn Fablet.
+
+ Updated test expectation for error() test (previously FAIL, now PASS).
+ Added IDL-related tests for ReadableByteStreamController.
+
+ * streams/readable-byte-stream-controller-expected.txt:
+
2016-11-04 Per Arne Vollan <[email protected]>
[Win] Page visibility tests are timing out.
Modified: trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt (208381 => 208382)
--- trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/LayoutTests/streams/readable-byte-stream-controller-expected.txt 2016-11-04 10:39:09 UTC (rev 208382)
@@ -1,10 +1,14 @@
PASS Creating a ReadableStream with an underlyingSource with type property set to 'bytes' should succeed
-FAIL Calling read() on a reader associated to a controller that has been errored should be rejected ReadableByteStreamController error() is not implemented
+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
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
-FAIL Calling read() on a reader associated to a controller that has been errored should be rejected ReadableByteStreamController error() is not implemented
+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
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 (208381 => 208382)
--- trunk/LayoutTests/streams/readable-byte-stream-controller.js 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/LayoutTests/streams/readable-byte-stream-controller.js 2016-11-04 10:39:09 UTC (rev 208382)
@@ -10,6 +10,59 @@
});
}, "Creating a ReadableStream with an underlyingSource with type property set to 'bytes' should succeed");
+test(() => {
+ const methods = ['close', 'constructor', 'enqueue', 'error'];
+ // FIXME: Add byobRequest when implemented.
+ const properties = methods.concat(['desiredSize']).sort();
+
+ let controller;
+
+ const rs = new ReadableStream({
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ const proto = Object.getPrototypeOf(controller);
+
+ assert_array_equals(Object.getOwnPropertyNames(proto).sort(), properties);
+
+ for (const m of methods) {
+ const propDesc = Object.getOwnPropertyDescriptor(proto, m);
+ assert_equals(propDesc.enumerable, false, 'method should be non-enumerable');
+ assert_equals(propDesc.configurable, true, 'method should be configurable');
+ assert_equals(propDesc.writable, true, 'method should be writable');
+ assert_equals(typeof controller[m], 'function', 'should have be a method');
+ }
+
+ const desiredSizePropDesc = Object.getOwnPropertyDescriptor(proto, 'desiredSize');
+ assert_equals(desiredSizePropDesc.enumerable, false, 'desiredSize should be non-enumerable');
+ assert_equals(desiredSizePropDesc.configurable, true, 'desiredSize should be configurable');
+ assert_not_equals(desiredSizePropDesc.get, undefined, 'desiredSize should have a getter');
+ assert_equals(desiredSizePropDesc.set, undefined, 'desiredSize should not have a setter');
+
+ assert_equals(controller.close.length, 0, 'close has 0 parameter');
+ assert_equals(controller.constructor.length, 3, 'constructor has 3 parameters');
+ assert_equals(controller.enqueue.length, 1, 'enqueue has 1 parameter');
+ assert_equals(controller.error.length, 1, 'error has 1 parameter');
+
+}, 'ReadableByteStreamController instances should have the correct list of properties');
+
+test(function() {
+ let controller;
+
+ const rs = new ReadableStream({
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ 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");
+
const test2 = async_test("Calling read() on a reader associated to a controller that has been errored should be rejected");
test2.step(function() {
let controller;
Modified: trunk/Source/WebCore/ChangeLog (208381 => 208382)
--- trunk/Source/WebCore/ChangeLog 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/Source/WebCore/ChangeLog 2016-11-04 10:39:09 UTC (rev 208382)
@@ -1,3 +1,27 @@
+2016-11-04 Romain Bellessort <[email protected]>
+
+ [Readable Streams API] Implement ByteStreamController error()
+ https://bugs.webkit.org/show_bug.cgi?id=164319
+
+ Reviewed by Youenn Fablet.
+
+ Implemented error() method of ReadableByteStreamController.
+
+ Updated test expectations for error() and added IDL-related tests.
+
+ * Modules/streams/ReadableByteStreamController.js:
+ (error): Implemented.
+ * Modules/streams/ReadableByteStreamInternals.js:
+ (privateInitializeReadableByteStreamController):
+ (isReadableByteStreamController): Added.
+ (readableByteStreamControllerError): Added.
+ (readableByteStreamControllerClearPendingPullIntos): Added.
+ * Modules/streams/ReadableStream.js:
+ (initializeReadableStream): More detailed error message.
+ * Modules/streams/ReadableStreamDefaultController.js:
+ (error): Removed unnecessary variable declaration.
+ * bindings/js/WebCoreBuiltinNames.h: Added totalQueuedBytes.
+
2016-11-03 Brady Eidson <[email protected]>
IndexedDB 2.0: Handle IDBIndex rename behavior properly when version change transaction aborts.
Modified: trunk/Source/WebCore/Modules/streams/ReadableByteStreamController.js (208381 => 208382)
--- trunk/Source/WebCore/Modules/streams/ReadableByteStreamController.js 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/Source/WebCore/Modules/streams/ReadableByteStreamController.js 2016-11-04 10:39:09 UTC (rev 208382)
@@ -37,8 +37,13 @@
{
"use strict";
- //FIXME: Implement appropriate behavior.
- @throwTypeError("ReadableByteStreamController error() is not implemented");
+ if (!@isReadableByteStreamController(this))
+ throw @makeThisTypeError("ReadableByteStreamController", "error");
+
+ if (this.@controlledReadableStream.@state !== @streamReadable)
+ @throwTypeError("ReadableStream is not readable");
+
+ @readableByteStreamControllerError(this, error);
}
function close()
Modified: trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js (208381 => 208382)
--- trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js 2016-11-04 10:39:09 UTC (rev 208382)
@@ -39,11 +39,13 @@
this.@controlledReadableStream = stream;
this.@underlyingByteSource = underlyingByteSource;
+ this.@pullAgain = false;
+ this.@pulling = false;
+ @readableByteStreamControllerClearPendingPullIntos(this);
this.@queue = @newQueue();
+ this.@totalQueuedBytes = 0;
this.@started = false;
this.@closeRequested = false;
- this.@pullAgain = false;
- this.@pulling = false;
let hwm = @Number(highWaterMark);
if (@isNaN(hwm) || hwm < 0)
@@ -50,8 +52,6 @@
@throwRangeError("highWaterMark value is negative or not a number");
this.@strategyHWM = hwm;
- // FIXME: Implement readableByteStreamControllerClearPendingPullIntos.
-
let autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
if (autoAllocateChunkSize !== @undefined) {
autoAllocateChunkSize = @Number(autoAllocateChunkSize);
@@ -75,3 +75,29 @@
return this;
}
+
+function isReadableByteStreamController(controller)
+{
+ "use strict";
+
+ // Same test mechanism as in isReadableStreamDefaultController (ReadableStreamInternals.js).
+ // See corresponding function for explanations.
+ return @isObject(controller) && !!controller.@underlyingByteSource;
+}
+
+function readableByteStreamControllerError(controller, e)
+{
+ "use strict";
+
+ @assert(controller.@controlledReadableStream.@state === @streamReadable);
+ @readableByteStreamControllerClearPendingPullIntos(controller);
+ controller.@queue = @newQueue();
+ @readableStreamError(controller.@controlledReadableStream, e);
+}
+
+function readableByteStreamControllerClearPendingPullIntos(controller)
+{
+ "use strict";
+
+ // FIXME: To be implemented in conjunction with ReadableStreamBYOBRequest.
+}
Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.js (208381 => 208382)
--- trunk/Source/WebCore/Modules/streams/ReadableStream.js 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.js 2016-11-04 10:39:09 UTC (rev 208382)
@@ -58,10 +58,11 @@
// Constructor is not necessarily available if the byteStream part of Readeable Stream API is not activated. Therefore, a
// specific handling of error is done.
try {
- this.@readableStreamController = new @ReadableByteStreamController(this, underlyingSource, strategy.highWaterMark);
+ let readableByteStreamControllerConstructor = @ReadableByteStreamController;
} catch (e) {
- @throwTypeError("ReadableByteStreamController could not be created");
+ @throwTypeError("ReadableByteStreamController is not implemented");
}
+ this.@readableStreamController = new @ReadableByteStreamController(this, underlyingSource, strategy.highWaterMark);
} else if (type === @undefined) {
if (strategy.highWaterMark === @undefined)
strategy.highWaterMark = 1;
Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js (208381 => 208382)
--- trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js 2016-11-04 10:39:09 UTC (rev 208382)
@@ -48,8 +48,7 @@
if (!@isReadableStreamDefaultController(this))
throw @makeThisTypeError("ReadableStreamDefaultController", "error");
- const stream = this.@controlledReadableStream;
- if (stream.@state !== @streamReadable)
+ if (this.@controlledReadableStream.@state !== @streamReadable)
@throwTypeError("ReadableStream is not readable");
@readableStreamDefaultControllerError(this, error);
Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (208381 => 208382)
--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2016-11-04 09:35:36 UTC (rev 208381)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2016-11-04 10:39:09 UTC (rev 208382)
@@ -97,6 +97,7 @@
macro(streamWritable) \
macro(structuredCloneArrayBuffer) \
macro(structuredCloneArrayBufferView) \
+ macro(totalQueuedBytes) \
macro(underlyingByteSource) \
macro(underlyingSink) \
macro(underlyingSource) \