<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[215043] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/215043">215043</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-04-06 10:25:10 -0700 (Thu, 06 Apr 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Readable Streams API] Implement ReadableStreamBYOBRequest respondWithNewView()
https://bugs.webkit.org/show_bug.cgi?id=170339
Patch by Romain Bellessort <romain.bellessort@crf.canon.fr> on 2017-04-06
Reviewed by Youenn Fablet.
Source/WebCore:
Implemented ReadableStreamBYOBRequest respondWithNewView().
Added new tests to check respondWithNewView() behaviour.
* Modules/streams/ReadableByteStreamInternals.js:
(readableByteStreamControllerRespondWithNewView): Added.
* Modules/streams/ReadableStreamBYOBRequest.js:
(respondWithNewView): Updated.
LayoutTests:
Added new tests addressing respondWithNewView() behaviour.
* streams/readable-stream-byob-request-expected.txt: Updated.
* streams/readable-stream-byob-request.js: Added new tests.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsstreamsreadablestreambyobrequestexpectedtxt">trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreadablestreambyobrequestjs">trunk/LayoutTests/streams/readable-stream-byob-request.js</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableByteStreamInternalsjs">trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamBYOBRequestjs">trunk/Source/WebCore/Modules/streams/ReadableStreamBYOBRequest.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (215042 => 215043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-04-06 17:20:28 UTC (rev 215042)
+++ trunk/LayoutTests/ChangeLog        2017-04-06 17:25:10 UTC (rev 215043)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2017-04-06 Romain Bellessort <romain.bellessort@crf.canon.fr>
+
+ [Readable Streams API] Implement ReadableStreamBYOBRequest respondWithNewView()
+ https://bugs.webkit.org/show_bug.cgi?id=170339
+
+ Reviewed by Youenn Fablet.
+
+ Added new tests addressing respondWithNewView() behaviour.
+
+ * streams/readable-stream-byob-request-expected.txt: Updated.
+ * streams/readable-stream-byob-request.js: Added new tests.
+
</ins><span class="cx"> 2017-04-06 Dave Hyatt <hyatt@apple.com>
</span><span class="cx">
</span><span class="cx"> Rendering flexbox children across columns
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreadablestreambyobrequestexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt (215042 => 215043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt        2017-04-06 17:20:28 UTC (rev 215042)
+++ trunk/LayoutTests/streams/readable-stream-byob-request-expected.txt        2017-04-06 17:25:10 UTC (rev 215043)
</span><span class="lines">@@ -10,6 +10,12 @@
</span><span class="cx"> PASS Calling respond() with a bytesWritten value of 0 when stream is closed should succeed
</span><span class="cx"> PASS Calling respond() with a bytesWritten value greater than autoAllocateChunkSize should fail
</span><span class="cx"> PASS Calling respond() with a bytesWritten value lower than autoAllocateChunkSize should succeed
</span><ins>+PASS Calling respondWithNewView() with a this object different from ReadableStreamBYOBRequest should throw a TypeError
+PASS Calling respondWithNewView() with an argument that is not an object should throw a TypeError
+PASS Calling respondWithNewView() with an argument that is not an ArrayBufferView should throw a TypeError
+PASS When using autoAllocateChunkSize, calling respondWithNewView() should succeed if view.byteLength is equal to autoAllocateChunkSize
+PASS When using autoAllocateChunkSize, calling respondWithNewView() should throw a RangeError if view.byteOffset is different from 0
+PASS When using autoAllocateChunkSize, calling respondWithNewView() should throw a RangeError if view.byteLength is different from autoAllocateChunkSize
</ins><span class="cx"> PASS ReadableStreamBYOBRequest instances should have the correct list of properties
</span><span class="cx"> PASS By default, byobRequest should be undefined
</span><span class="cx"> PASS byobRequest.view length should be equal to autoAllocateChunkSize
</span><span class="lines">@@ -21,4 +27,10 @@
</span><span class="cx"> PASS Calling respond() with a bytesWritten value of 0 when stream is closed should succeed
</span><span class="cx"> PASS Calling respond() with a bytesWritten value greater than autoAllocateChunkSize should fail
</span><span class="cx"> PASS Calling respond() with a bytesWritten value lower than autoAllocateChunkSize should succeed
</span><ins>+PASS Calling respondWithNewView() with a this object different from ReadableStreamBYOBRequest should throw a TypeError
+PASS Calling respondWithNewView() with an argument that is not an object should throw a TypeError
+PASS Calling respondWithNewView() with an argument that is not an ArrayBufferView should throw a TypeError
+PASS When using autoAllocateChunkSize, calling respondWithNewView() should succeed if view.byteLength is equal to autoAllocateChunkSize
+PASS When using autoAllocateChunkSize, calling respondWithNewView() should throw a RangeError if view.byteOffset is different from 0
+PASS When using autoAllocateChunkSize, calling respondWithNewView() should throw a RangeError if view.byteLength is different from autoAllocateChunkSize
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreadablestreambyobrequestjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/readable-stream-byob-request.js (215042 => 215043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/readable-stream-byob-request.js        2017-04-06 17:20:28 UTC (rev 215042)
+++ trunk/LayoutTests/streams/readable-stream-byob-request.js        2017-04-06 17:25:10 UTC (rev 215043)
</span><span class="lines">@@ -241,4 +241,117 @@
</span><span class="cx"> // FIXME: when ReadableStreamBYOBReader is implemented, add tests with elementSize different from 1
</span><span class="cx"> // so that more code can be covered.
</span><span class="cx">
</span><ins>+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.respondWithNewView on instances of ReadableStreamBYOBRequest"),
+ function() { byobReq.respondWithNewView.apply(rs, new Uint8Array(1)); });
+
+}, "Calling respondWithNewView() 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 TypeError("Provided view is not an object"),
+ function() { byobReq.respondWithNewView(function() {}); });
+
+}, "Calling respondWithNewView() with an argument that is not an object 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 TypeError("Provided view is not an ArrayBufferView"),
+ function() { byobReq.respondWithNewView({}); });
+
+}, "Calling respondWithNewView() with an argument that is not an ArrayBufferView should throw a TypeError");
+
+promise_test(function() {
+
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 2,
+ pull: function(controller) {
+ const newView = new Uint8Array([3, 6]);
+ const br = controller.byobRequest;
+ br.respondWithNewView(newView);
+ },
+ type: "bytes"
+ });
+
+ return rs.getReader().read().then(result => {
+ assert_equals(result.value.byteLength, 2);
+ assert_equals(result.value.byteOffset, 0);
+ assert_equals(result.value.buffer.byteLength, 2);
+ assert_equals(result.value[0], 3);
+ assert_equals(result.value[1], 6);
+ });
+}, "When using autoAllocateChunkSize, calling respondWithNewView() should succeed if view.byteLength is equal to autoAllocateChunkSize");
+
+promise_test(function(test) {
+
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 16,
+ pull: function(controller) {
+ const newView = new Uint8Array([3, 6]);
+ const br = controller.byobRequest;
+ br.respondWithNewView(newView);
+ },
+ type: "bytes"
+ });
+
+ const error = new RangeError("Invalid value for view.byteLength");
+
+ return promise_rejects(test, error, rs.getReader().read());
+}, "When using autoAllocateChunkSize, calling respondWithNewView() should throw a RangeError if view.byteOffset is different from 0");
+
+promise_test(function(test) {
+
+ const rs = new ReadableStream({
+ autoAllocateChunkSize: 16,
+ pull: function(controller) {
+ const buffer = new ArrayBuffer(3);
+ const newView = new Uint8Array(buffer, 1); // byteOffset of 1
+ const br = controller.byobRequest;
+ br.respondWithNewView(newView);
+ },
+ type: "bytes"
+ });
+
+ const error = new RangeError("Invalid value for view.byteOffset");
+
+ return promise_rejects(test, error, rs.getReader().read());
+}, "When using autoAllocateChunkSize, calling respondWithNewView() should throw a RangeError if view.byteLength is different from autoAllocateChunkSize");
+
</ins><span class="cx"> done();
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (215042 => 215043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-04-06 17:20:28 UTC (rev 215042)
+++ trunk/Source/WebCore/ChangeLog        2017-04-06 17:25:10 UTC (rev 215043)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-04-06 Romain Bellessort <romain.bellessort@crf.canon.fr>
+
+ [Readable Streams API] Implement ReadableStreamBYOBRequest respondWithNewView()
+ https://bugs.webkit.org/show_bug.cgi?id=170339
+
+ Reviewed by Youenn Fablet.
+
+ Implemented ReadableStreamBYOBRequest respondWithNewView().
+
+ Added new tests to check respondWithNewView() behaviour.
+
+ * Modules/streams/ReadableByteStreamInternals.js:
+ (readableByteStreamControllerRespondWithNewView): Added.
+ * Modules/streams/ReadableStreamBYOBRequest.js:
+ (respondWithNewView): Updated.
+
</ins><span class="cx"> 2017-04-06 Eric Carlson <eric.carlson@apple.com>
</span><span class="cx">
</span><span class="cx"> [MediaStream] Host application should be able to mute and unmute media streams
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableByteStreamInternalsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js (215042 => 215043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js        2017-04-06 17:20:28 UTC (rev 215042)
+++ trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js        2017-04-06 17:25:10 UTC (rev 215043)
</span><span class="lines">@@ -347,6 +347,24 @@
</span><span class="cx"> controller.@totalQueuedBytes += byteLength;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+function readableByteStreamControllerRespondWithNewView(controller, view)
+{
+ "use strict";
+
+ @assert(controller.@pendingPullIntos.length > 0);
+
+ let firstDescriptor = controller.@pendingPullIntos[0];
+
+ if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset)
+ @throwRangeError("Invalid value for view.byteOffset");
+
+ if (firstDescriptor.byteLength !== view.byteLength)
+ @throwRangeError("Invalid value for view.byteLength");
+
+ firstDescriptor.buffer = view.buffer;
+ @readableByteStreamControllerRespondInternal(controller, view.byteLength);
+}
+
</ins><span class="cx"> function readableByteStreamControllerRespond(controller, bytesWritten)
</span><span class="cx"> {
</span><span class="cx"> "use strict";
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamBYOBRequestjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamBYOBRequest.js (215042 => 215043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamBYOBRequest.js        2017-04-06 17:20:28 UTC (rev 215042)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamBYOBRequest.js        2017-04-06 17:25:10 UTC (rev 215043)
</span><span class="lines">@@ -42,8 +42,19 @@
</span><span class="cx"> {
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><del>- // FIXME: Implement appropriate behavior.
- @throwTypeError("ReadableStreamBYOBRequest respondWithNewView() is not implemented");
</del><ins>+ if (!@isReadableStreamBYOBRequest(this))
+ throw @makeThisTypeError("ReadableStreamBYOBRequest", "respond");
+
+ if (this.@associatedReadableByteStreamController === @undefined)
+ @throwTypeError("ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined");
+
+ if (!@isObject(view))
+ @throwTypeError("Provided view is not an object");
+
+ if (!@ArrayBuffer.@isView(view))
+ @throwTypeError("Provided view is not an ArrayBufferView");
+
+ return @readableByteStreamControllerRespondWithNewView(this.@associatedReadableByteStreamController, view);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function view()
</span></span></pre>
</div>
</div>
</body>
</html>