Diff
Modified: trunk/LayoutTests/ChangeLog (213769 => 213770)
--- trunk/LayoutTests/ChangeLog 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/LayoutTests/ChangeLog 2017-03-12 17:27:48 UTC (rev 213770)
@@ -1,3 +1,15 @@
+2017-03-12 Romain Bellessort <[email protected]>
+
+ [Readable Streams API] Implement ReadableStreamBYOBRequest respond() (closed stream state)
+ https://bugs.webkit.org/show_bug.cgi?id=168781
+
+ Reviewed by Youenn Fablet.
+
+ Added new tests related to ReadableStreamBYOBRequeset respond() method.
+
+ * streams/readable-stream-byob-request-expected.txt:
+ * streams/readable-stream-byob-request.js:
+
2017-03-11 Youenn Fablet <[email protected]>
XMLHttpRequest: make setRequestHeader() use `, ` as separator (including a space)
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (213769 => 213770)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-03-12 17:27:48 UTC (rev 213770)
@@ -1,3 +1,15 @@
+2017-03-12 Romain Bellessort <[email protected]>
+
+ [Readable Streams API] Implement ReadableStreamBYOBRequest respond() (closed stream state)
+ https://bugs.webkit.org/show_bug.cgi?id=168781
+
+ Reviewed by Youenn Fablet.
+
+ Updated WPT expectations for readable byte streams tests.
+
+ * web-platform-tests/streams/readable-byte-streams/general-expected.txt:
+ * web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt:
+
2017-03-11 Youenn Fablet <[email protected]>
XMLHttpRequest: make setRequestHeader() use `, ` as separator (including a space)
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general-expected.txt (213769 => 213770)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general-expected.txt 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general-expected.txt 2017-03-12 17:27:48 UTC (rev 213770)
@@ -14,7 +14,7 @@
PASS ReadableStream with byte source: Automatic pull() after start()
PASS ReadableStream with byte source: Automatic pull() after start() and read()
FAIL ReadableStream with byte source: autoAllocateChunkSize assert_equals: pull() must have been invoked once expected 1 but got 0
-FAIL ReadableStream with byte source: Mix of auto allocate and BYOB promise_test: Unhandled rejection with value: object "TypeError: ReadableStreamBYOBRequest respond() is not implemented"
+FAIL ReadableStream with byte source: Mix of auto allocate and BYOB promise_test: Unhandled rejection with value: object "TypeError: Readable state is not yet supported"
PASS ReadableStream with byte source: Automatic pull() after start() and read(view)
PASS ReadableStream with byte source: enqueue(), getReader(), then read()
PASS ReadableStream with byte source: Push source that doesn't understand pull signal
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt (213769 => 213770)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/readable-byte-streams/general.dedicatedworker-expected.txt 2017-03-12 17:27:48 UTC (rev 213770)
@@ -14,7 +14,7 @@
PASS ReadableStream with byte source: Automatic pull() after start()
PASS ReadableStream with byte source: Automatic pull() after start() and read()
FAIL ReadableStream with byte source: autoAllocateChunkSize assert_equals: pull() must have been invoked once expected 1 but got 0
-FAIL ReadableStream with byte source: Mix of auto allocate and BYOB promise_test: Unhandled rejection with value: object "TypeError: ReadableStreamBYOBRequest respond() is not implemented"
+FAIL ReadableStream with byte source: Mix of auto allocate and BYOB promise_test: Unhandled rejection with value: object "TypeError: Readable state is not yet supported"
PASS ReadableStream with byte source: Automatic pull() after start() and read(view)
PASS ReadableStream with byte source: enqueue(), getReader(), then read()
PASS ReadableStream with byte source: Push source that doesn't understand pull signal
Modified: trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt (213769 => 213770)
--- trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt 2017-03-12 17:27:48 UTC (rev 213770)
@@ -2,7 +2,19 @@
PASS ReadableStreamBYOBRequest instances should have the correct list of properties
PASS By default, byobRequest should be undefined
PASS byobRequest.view length should be equal to autoAllocateChunkSize
+PASS Calling respond() with a this object different from ReadableStreamBYOBRequest should throw a TypeError
+PASS Calling respond() with a negative bytesWritten value should throw a RangeError
+PASS Calling respond() with a bytesWritten value which is not a number should throw a RangeError
+PASS Calling respond() with a positive infinity bytesWritten value should throw a RangeError
+PASS Calling respond() with a bytesWritten value different from 0 when stream is closed should throw a TypeError
+PASS Calling respond() with a bytesWritten value of 0 when stream is closed should succeed
PASS ReadableStreamBYOBRequest instances should have the correct list of properties
PASS By default, byobRequest should be undefined
PASS byobRequest.view length should be equal to autoAllocateChunkSize
+PASS Calling respond() with a this object different from ReadableStreamBYOBRequest should throw a TypeError
+PASS Calling respond() with a negative bytesWritten value should throw a RangeError
+PASS Calling respond() with a bytesWritten value which is not a number should throw a RangeError
+PASS Calling respond() with a positive infinity bytesWritten value should throw a RangeError
+PASS Calling respond() with a bytesWritten value different from 0 when stream is closed should throw a TypeError
+PASS Calling respond() with a bytesWritten value of 0 when stream is closed should succeed
Modified: trunk/LayoutTests/streams/readable-stream-byob-request.js (213769 => 213770)
--- trunk/LayoutTests/streams/readable-stream-byob-request.js 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/LayoutTests/streams/readable-stream-byob-request.js 2017-03-12 17:27:48 UTC (rev 213770)
@@ -85,4 +85,117 @@
}, "byobRequest.view length should be equal to autoAllocateChunkSize")
+test(function() {
+
+ let controller;
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 16,
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ rs.getReader().read();
+ const byobReq = controller.byobRequest;
+
+ assert_throws(new TypeError("Can only call ReadableStreamBYOBRequest.respond on instances of ReadableStreamBYOBRequest"),
+ function() { byobReq.respond.apply(rs, 1); });
+
+}, "Calling respond() with a this object different from ReadableStreamBYOBRequest should throw a TypeError");
+
+test(function() {
+
+ let controller;
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 16,
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ rs.getReader().read();
+ const byobReq = controller.byobRequest;
+
+ assert_throws(new RangeError("bytesWritten has an incorrect value"),
+ function() { byobReq.respond(-1); });
+}, "Calling respond() with a negative bytesWritten value should throw a RangeError");
+
+test(function() {
+
+ let controller;
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 16,
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ rs.getReader().read();
+ const byobReq = controller.byobRequest;
+
+ assert_throws(new RangeError("bytesWritten has an incorrect value"),
+ function() { byobReq.respond("abc"); });
+}, "Calling respond() with a bytesWritten value which is not a number should throw a RangeError");
+
+test(function() {
+
+ let controller;
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 16,
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ rs.getReader().read();
+ const byobReq = controller.byobRequest;
+
+ assert_throws(new RangeError("bytesWritten has an incorrect value"),
+ function() { byobReq.respond(Number.POSITIVE_INFINITY); });
+}, "Calling respond() with a positive infinity bytesWritten value should throw a RangeError");
+
+test(function() {
+
+ let controller;
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 16,
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ rs.getReader().read();
+ const byobReq = controller.byobRequest;
+ controller.close();
+
+ assert_throws(new TypeError("bytesWritten is different from 0 even though stream is closed"),
+ function() { byobReq.respond(1); });
+}, "Calling respond() with a bytesWritten value different from 0 when stream is closed should throw a TypeError");
+
+test(function() {
+
+ let controller;
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 16,
+ start: function(c) {
+ controller = c;
+ },
+ type: "bytes"
+ });
+
+ // FIXME: When ReadableStreamBYOBReader is implemented, another test (or even several ones)
+ // based on this one should be added so that reader's readIntoRequests attribute is not empty
+ // and currently unreachable code is reached.
+ rs.getReader().read();
+ const byobReq = controller.byobRequest;
+ controller.close();
+ byobReq.respond(0);
+
+}, "Calling respond() with a bytesWritten value of 0 when stream is closed should succeed");
+
done();
Modified: trunk/Source/WebCore/ChangeLog (213769 => 213770)
--- trunk/Source/WebCore/ChangeLog 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/Source/WebCore/ChangeLog 2017-03-12 17:27:48 UTC (rev 213770)
@@ -1,3 +1,26 @@
+2017-03-12 Romain Bellessort <[email protected]>
+
+ [Readable Streams API] Implement ReadableStreamBYOBRequest respond() (closed stream state)
+ https://bugs.webkit.org/show_bug.cgi?id=168781
+
+ Reviewed by Youenn Fablet.
+
+ Implemented ReadableStreamBYOBRequest respond() method in the case of a closed stream.
+
+ Added tests related to respond() method and updated WPT imported tests expectations.
+
+ * Modules/streams/ReadableByteStreamInternals.js:
+ (readableByteStreamControllerRespond): Added.
+ (readableByteStreamControllerRespondInternal): Added.
+ (readableByteStreamControllerRespondInClosedState): Added.
+ (readableByteStreamControllerShiftPendingPullInto): Added.
+ (readableByteStreamControllerInvalidateBYOBRequest): Added.
+ (readableByteStreamControllerCommitPullIntoDescriptor): Added.
+ (readableByteStreamControllerConvertPullIntoDescriptor): Added.
+ (readableStreamFulfillReadIntoRequest): Added.
+ * Modules/streams/ReadableStreamBYOBRequest.js:
+ (respond): Implemented.
+
2017-03-11 Simon Fraser <[email protected]>
Fix memory estimate for layers supporting subpixel-antialised text
Modified: trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js (213769 => 213770)
--- trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js 2017-03-12 17:27:48 UTC (rev 213770)
@@ -345,3 +345,111 @@
});
controller.@totalQueuedBytes += byteLength;
}
+
+function readableByteStreamControllerRespond(controller, bytesWritten)
+{
+ "use strict";
+
+ bytesWritten = @Number(bytesWritten);
+
+ if (@isNaN(bytesWritten) || bytesWritten === @Number.POSITIVE_INFINITY || bytesWritten < 0 )
+ @throwRangeError("bytesWritten has an incorrect value");
+
+ @assert([email protected] > 0);
+
+ @readableByteStreamControllerRespondInternal(controller, bytesWritten);
+}
+
+function readableByteStreamControllerRespondInternal(controller, bytesWritten)
+{
+ "use strict";
+
+ let firstDescriptor = controller.@pendingPullIntos[0];
+ let stream = controller.@controlledReadableStream;
+
+ if (stream.@state === @streamClosed) {
+ if (bytesWritten !== 0)
+ @throwTypeError("bytesWritten is different from 0 even though stream is closed");
+ @readableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
+ } else {
+ // FIXME: Also implement case of readable state (distinct patch to avoid adding too many different cases
+ // in a single patch).
+ @throwTypeError("Readable state is not yet supported");
+ }
+}
+
+function readableByteStreamControllerRespondInClosedState(controller, firstDescriptor)
+{
+ "use strict";
+
+ firstDescriptor.buffer = @transferBufferToCurrentRealm(firstDescriptor.buffer);
+ @assert(firstDescriptor.bytesFilled === 0);
+
+ // FIXME: Spec does not describe below test. However, only ReadableStreamBYOBReader has a readIntoRequests
+ // property. This issue has been reported through WHATWG/streams GitHub
+ // (https://github.com/whatwg/streams/issues/686), but no solution has been provided for the moment.
+ // Therefore, below test is added as a temporary fix.
+ if (!@isReadableStreamBYOBReader(controller.@reader))
+ return;
+
+ while (controller.@[email protected] > 0) {
+ let pullIntoDescriptor = @readableByteStreamControllerShiftPendingPullInto(controller);
+ @readableByteStreamControllerCommitPullIntoDescriptor(controller.@controlledReadableStream, pullIntoDescriptor);
+ }
+}
+
+function readableByteStreamControllerShiftPendingPullInto(controller)
+{
+ "use strict";
+
+ let descriptor = controller.@pendingPullIntos.@shift();
+ @readableByteStreamControllerInvalidateBYOBRequest(controller);
+ return descriptor;
+}
+
+function readableByteStreamControllerInvalidateBYOBRequest(controller)
+{
+ "use strict";
+
+ if (controller.@byobRequest === @undefined)
+ return;
+ controller.@byobRequest.@associatedReadableByteStreamController = @undefined;
+ controller.@byobRequest.@view = @undefined;
+ controller.@byobRequest = @undefined;
+}
+
+function readableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor)
+{
+ "use strict";
+
+ @assert(stream.@state !== @streamErrored);
+ let done = false;
+ if (stream.@state === @streamClosed) {
+ @assert(!pullIntoDescriptor.bytesFilled);
+ done = true;
+ }
+ let filledView = @readableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
+ if (pullIntoDescriptor.readerType === "default")
+ @readableStreamFulfillReadRequest(stream, filledView, done);
+ else {
+ @assert(pullIntoDescriptor.readerType === "byob");
+ @readableStreamFulfillReadIntoRequest(stream, filledView, done);
+ }
+}
+
+function readableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor)
+{
+ "use strict";
+
+ @assert(pullIntoDescriptor.bytesFilled <= pullIntoDescriptor.bytesLength);
+ @assert(pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize === 0);
+
+ return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, pullIntoDescriptor.bytesFilled / pullIntoDescriptor.elementSize);
+}
+
+function readableStreamFulfillReadIntoRequest(stream, chunk, done)
+{
+ "use strict";
+
+ stream.@reader.@readIntoRequests.@shift().@resolve.@call(@undefined, {value: chunk, done: done});
+}
Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamBYOBRequest.js (213769 => 213770)
--- trunk/Source/WebCore/Modules/streams/ReadableStreamBYOBRequest.js 2017-03-12 07:54:19 UTC (rev 213769)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamBYOBRequest.js 2017-03-12 17:27:48 UTC (rev 213770)
@@ -29,8 +29,13 @@
{
"use strict";
- // FIXME: Implement appropriate behavior.
- @throwTypeError("ReadableStreamBYOBRequest respond() is not implemented");
+ if (!@isReadableStreamBYOBRequest(this))
+ throw @makeThisTypeError("ReadableStreamBYOBRequest", "respond");
+
+ if (this.@associatedReadableByteStreamController === @undefined)
+ @throwTypeError("ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined");
+
+ return @readableByteStreamControllerRespond(this.@associatedReadableByteStreamController, bytesWritten);
}
function respondWithNewView(view)