<!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>[192466] 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/192466">192466</a></dd>
<dt>Author</dt> <dd>calvaris@igalia.com</dd>
<dt>Date</dt> <dd>2015-11-16 02:21:37 -0800 (Mon, 16 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Streams API] Update the implementation up to spec of Nov 11 2015
https://bugs.webkit.org/show_bug.cgi?id=151195

Reviewed by Youenn Fablet.

Source/WebCore:

Updated the implementation of Readable and Writable Streams to the latest changes in the spec. Main changes are
the removal of the error and the state from the reader, readers are not automatically released and then minor or
style changes.

Implementation is up to date with version
https://github.com/whatwg/streams/commit/48c8a3c30ea7e76c5e4eb9f157a438dd755bcc8e.

Tests: streams/reference-implementation/readable-stream-templated.html
       streams/reference-implementation/readable-stream-reader.html

* Modules/streams/ReadableStream.js:
(getReader): Removed check for locked stream.
* Modules/streams/ReadableStreamInternals.js:
(privateInitializeReadableStreamReader): Removed setting @error and @state and initialized owner and owner's
reader as per spec.
(teeReadableStreamPullFunction): Added assertions.
(isReadableStreamReader): Added comment about resetting the reader owner to null instead of undefined as a means
to distinguish between not having the slot and having it unset.
(finishClosingReadableStream): Inline @closeReadableStreamReader as it is used only here now.
(readFromReadableStreamReader): Reworked the state and error to use the stream one and changed the conditions to
pull again as per spec.
(errorReadableStream): Not releasing the reader and removed the reader error and state management.
(releaseReadableStreamReader): Deleted.
(closeReadableStreamReader): Deleted.
* Modules/streams/ReadableStreamReader.js:
(cancel): Removed some checks and assertions as per spec.
(read): Added check for owner.
(releaseLock): No closing the reader and rejecting close promise and unlinking reader and owner instead.
* Modules/streams/WritableStream.js:
(abort): Style change.
* Modules/streams/WritableStreamInternals.js:
(writableStreamAdvanceQueue):
(closeWritableStream): Used @call instead of @apply.

LayoutTests:

Updated expectations.

* streams/reference-implementation/readable-stream-reader-expected.txt:
* streams/reference-implementation/readable-stream-templated-expected.txt:
* streams/reference-implementation/readable-stream-templated.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationreadablestreamreaderexpectedtxt">trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationreadablestreamtemplatedexpectedtxt">trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationreadablestreamtemplatedhtml">trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamjs">trunk/Source/WebCore/Modules/streams/ReadableStream.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamInternalsjs">trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamReaderjs">trunk/Source/WebCore/Modules/streams/ReadableStreamReader.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsWritableStreamjs">trunk/Source/WebCore/Modules/streams/WritableStream.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsWritableStreamInternalsjs">trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/LayoutTests/ChangeLog        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-11-16  Xabier Rodriguez Calvar  &lt;calvaris@igalia.com&gt;
+
+        [Streams API] Update the implementation up to spec of Nov 11 2015
+        https://bugs.webkit.org/show_bug.cgi?id=151195
+
+        Reviewed by Youenn Fablet.
+
+        Updated expectations.
+
+        * streams/reference-implementation/readable-stream-reader-expected.txt:
+        * streams/reference-implementation/readable-stream-templated-expected.txt:
+        * streams/reference-implementation/readable-stream-templated.html:
+
</ins><span class="cx"> 2015-11-15  Adam Bergkvist  &lt;adam.bergkvist@ericsson.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebRTC: Update RTCPeerConnection API and introduce PeerConnectionBackend
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationreadablestreamreaderexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -10,12 +10,12 @@
</span><span class="cx"> PASS Constructing a ReadableStreamReader directly should be OK if the stream is closed 
</span><span class="cx"> PASS Constructing a ReadableStreamReader directly should be OK if the stream is errored 
</span><span class="cx"> PASS Reading from a reader for an empty stream will wait until a chunk is available 
</span><del>-FAIL cancel() on a reader does not release the reader assert_unreached: reader.cancel() should not reject Reached unreachable code
</del><ins>+PASS cancel() on a reader does not release the reader 
</ins><span class="cx"> PASS closed should be fulfilled after stream is closed (.closed access before acquiring) 
</span><del>-FAIL closed should be rejected after reader releases its lock (multiple stream locks) assert_equals: expected 2 but got 1
</del><ins>+PASS closed should be rejected after reader releases its lock (multiple stream locks) 
</ins><span class="cx"> PASS Multiple readers can access the stream in sequence 
</span><span class="cx"> PASS Cannot use an already-released reader to unlock a stream again 
</span><del>-FAIL cancel() on a released reader is a no-op and does not pass through assert_unreached: cancel promise should not fulfill Reached unreachable code
</del><ins>+PASS cancel() on a released reader is a no-op and does not pass through 
</ins><span class="cx"> PASS Getting a second reader after erroring the stream should succeed 
</span><span class="cx"> PASS Garbage-collecting a ReadableStreamReader should not unlock its stream 
</span><span class="cx"> PASS ReadableStreamReader closed promise should be rejected with undefined if that is the error 
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationreadablestreamtemplatedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -9,8 +9,8 @@
</span><span class="cx"> PASS read() should return distinct promises each time 
</span><span class="cx"> PASS getReader() again on the stream should fail 
</span><span class="cx"> PASS releasing the lock with pending read requests should throw but the read requests should stay pending 
</span><del>-TIMEOUT releasing the lock should cause further read() calls to reject with a TypeError Test timed out
-TIMEOUT releasing the lock should cause closed to reject Test timed out
</del><ins>+PASS releasing the lock should cause further read() calls to reject with a TypeError 
+PASS releasing the lock should cause closed to reject 
</ins><span class="cx"> PASS releasing the lock should cause locked to become false 
</span><span class="cx"> PASS canceling via the reader should cause the reader to act closed 
</span><span class="cx"> PASS canceling via the stream should fail 
</span><span class="lines">@@ -21,20 +21,20 @@
</span><span class="cx"> FAIL piping to a WritableStream in the writable state should close the writable stream pipeTo is not implemented
</span><span class="cx"> FAIL piping to a WritableStream in the writable state with { preventClose: true } should do nothing pipeTo is not implemented
</span><span class="cx"> PASS should be able to acquire multiple readers if they are released in succession 
</span><del>-FAIL should not be able to acquire a second reader if we don't release the first one assert_throws: getting a second reader should throw function &quot;function () { rs.getReader(); }&quot; did not throw
</del><ins>+PASS should not be able to acquire a second reader if we don't release the first one 
</ins><span class="cx"> PASS Running templatedRSClosedReader with ReadableStream reader (closed before getting reader) 
</span><span class="cx"> PASS read() should fulfill with { value: undefined, done: true } 
</span><span class="cx"> PASS read() multiple times should fulfill with { value: undefined, done: true } 
</span><span class="cx"> PASS read() should work when used within another read() fulfill callback 
</span><span class="cx"> PASS closed should fulfill with undefined 
</span><del>-FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object &quot;[object Promise]&quot;
</del><ins>+PASS releasing the lock should cause closed to reject and change identity 
</ins><span class="cx"> PASS cancel() should return a distinct fulfilled promise each time 
</span><span class="cx"> PASS Running templatedRSClosedReader with ReadableStream reader (closed after getting reader) 
</span><span class="cx"> PASS read() should fulfill with { value: undefined, done: true } 
</span><span class="cx"> PASS read() multiple times should fulfill with { value: undefined, done: true } 
</span><span class="cx"> PASS read() should work when used within another read() fulfill callback 
</span><span class="cx"> PASS closed should fulfill with undefined 
</span><del>-FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object &quot;[object Promise]&quot;
</del><ins>+PASS releasing the lock should cause closed to reject and change identity 
</ins><span class="cx"> PASS cancel() should return a distinct fulfilled promise each time 
</span><span class="cx"> PASS Running templatedRSClosed with ReadableStream (closed via cancel) 
</span><span class="cx"> PASS cancel() should return a distinct fulfilled promise each time 
</span><span class="lines">@@ -43,13 +43,13 @@
</span><span class="cx"> FAIL piping to a WritableStream in the writable state should close the writable stream pipeTo is not implemented
</span><span class="cx"> FAIL piping to a WritableStream in the writable state with { preventClose: true } should do nothing pipeTo is not implemented
</span><span class="cx"> PASS should be able to acquire multiple readers if they are released in succession 
</span><del>-FAIL should not be able to acquire a second reader if we don't release the first one assert_throws: getting a second reader should throw function &quot;function () { rs.getReader(); }&quot; did not throw
</del><ins>+PASS should not be able to acquire a second reader if we don't release the first one 
</ins><span class="cx"> PASS Running templatedRSClosedReader with ReadableStream reader (closed via cancel after getting reader) 
</span><span class="cx"> PASS read() should fulfill with { value: undefined, done: true } 
</span><span class="cx"> PASS read() multiple times should fulfill with { value: undefined, done: true } 
</span><span class="cx"> PASS read() should work when used within another read() fulfill callback 
</span><span class="cx"> PASS closed should fulfill with undefined 
</span><del>-FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object &quot;[object Promise]&quot;
</del><ins>+PASS releasing the lock should cause closed to reject and change identity 
</ins><span class="cx"> PASS cancel() should return a distinct fulfilled promise each time 
</span><span class="cx"> PASS Running templatedRSErrored with ReadableStream (errored via call in start) 
</span><span class="cx"> FAIL piping to a WritableStream in the writable state should abort the writable stream pipeTo is not implemented
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx"> PASS locked should be false 
</span><span class="cx"> PASS Running templatedRSErroredSyncOnly with ReadableStream (errored via call in start) 
</span><span class="cx"> PASS should be able to obtain a second reader, with the correct closed promise 
</span><del>-FAIL should not be able to obtain additional readers if we don't release the first lock assert_throws: getting a second reader should throw a TypeError function &quot;function () { rs.getReader(); }&quot; did not throw
</del><ins>+PASS should not be able to obtain additional readers if we don't release the first lock 
</ins><span class="cx"> PASS cancel() should return a distinct rejected promise each time 
</span><span class="cx"> PASS reader cancel() should return a distinct rejected promise each time 
</span><span class="cx"> PASS Running templatedRSErrored with ReadableStream (errored via returning a rejected promise in start) 
</span><span class="lines">@@ -72,15 +72,15 @@
</span><span class="cx"> FAIL piping with { preventAbort: true } pipeTo is not implemented
</span><span class="cx"> PASS Running templatedRSErroredReader with ReadableStream (errored via returning a rejected promise in start) reader 
</span><span class="cx"> PASS closed should reject with the error 
</span><del>-FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object &quot;[object Promise]&quot;
</del><ins>+PASS releasing the lock should cause closed to reject and change identity 
</ins><span class="cx"> PASS read() should reject with the error 
</span><span class="cx"> PASS Running templatedRSErroredReader with ReadableStream reader (errored before getting reader) 
</span><span class="cx"> PASS closed should reject with the error 
</span><del>-FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object &quot;[object Promise]&quot;
</del><ins>+PASS releasing the lock should cause closed to reject and change identity 
</ins><span class="cx"> PASS read() should reject with the error 
</span><span class="cx"> PASS Running templatedRSErroredReader with ReadableStream reader (errored after getting reader) 
</span><span class="cx"> PASS closed should reject with the error 
</span><del>-FAIL releasing the lock should cause closed to reject and change identity assert_not_equals: the closed promise should change identity got disallowed value object &quot;[object Promise]&quot;
</del><ins>+PASS releasing the lock should cause closed to reject and change identity 
</ins><span class="cx"> PASS read() should reject with the error 
</span><span class="cx"> PASS Running templatedRSTwoChunksOpenReader with ReadableStream (two chunks enqueued, still open) reader 
</span><span class="cx"> PASS calling read() twice without waiting will eventually give both chunks 
</span><span class="lines">@@ -111,8 +111,8 @@
</span><span class="cx"> PASS Running templatedRSTwoChunksClosedReader with ReadableStream (two chunks enqueued, then closed) reader 
</span><span class="cx"> PASS third read(), without waiting, should give { value: undefined, done: true } 
</span><span class="cx"> PASS third read, with waiting, should give { value: undefined, done: true } 
</span><del>-FAIL draining the stream via read() should cause the reader closed promise to fulfill, but locked stays true assert_true: stream should remain locked expected true got false
-FAIL releasing the lock after the stream is closed should cause locked to become false assert_true: the stream should start locked expected true got false
-TIMEOUT releasing the lock should cause further read() calls to reject with a TypeError Test timed out
</del><ins>+PASS draining the stream via read() should cause the reader closed promise to fulfill, but locked stays true 
+PASS releasing the lock after the stream is closed should cause locked to become false 
+PASS releasing the lock should cause further read() calls to reject with a TypeError 
</ins><span class="cx"> PASS reader's closed property always returns the same promise 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationreadablestreamtemplatedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -630,7 +630,7 @@
</span><span class="cx">         setTimeout(test3.step_func(function() { test3.done(); }), 1000);
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    var test4 = async_test('releasing the lock should cause further read() calls to reject with a TypeError', { timeout: 50 });
</del><ins>+    var test4 = async_test('releasing the lock should cause further read() calls to reject with a TypeError');
</ins><span class="cx">     test4.step(function() {
</span><span class="cx">         var promiseCalls = 0;
</span><span class="cx">         var { reader } = factory();
</span><span class="lines">@@ -648,7 +648,7 @@
</span><span class="cx">         }));
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    var test5 = async_test('releasing the lock should cause closed to reject', { timeout: 50 });
</del><ins>+    var test5 = async_test('releasing the lock should cause closed to reject');
</ins><span class="cx">     test5.step(function() {
</span><span class="cx">         var { reader } = factory();
</span><span class="cx"> 
</span><span class="lines">@@ -994,7 +994,7 @@
</span><span class="cx">         reader.read();
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    var test5 = async_test('releasing the lock should cause further read() calls to reject with a TypeError', { timeout: 50});
</del><ins>+    var test5 = async_test('releasing the lock should cause further read() calls to reject with a TypeError');
</ins><span class="cx">     test5.step(function() {
</span><span class="cx">         var promiseCalls = 0;
</span><span class="cx">         var { reader } = factory();
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/Source/WebCore/ChangeLog        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2015-11-16  Xabier Rodriguez Calvar  &lt;calvaris@igalia.com&gt;
+
+        [Streams API] Update the implementation up to spec of Nov 11 2015
+        https://bugs.webkit.org/show_bug.cgi?id=151195
+
+        Reviewed by Youenn Fablet.
+
+        Updated the implementation of Readable and Writable Streams to the latest changes in the spec. Main changes are
+        the removal of the error and the state from the reader, readers are not automatically released and then minor or
+        style changes.
+
+        Implementation is up to date with version
+        https://github.com/whatwg/streams/commit/48c8a3c30ea7e76c5e4eb9f157a438dd755bcc8e.
+
+        Tests: streams/reference-implementation/readable-stream-templated.html
+               streams/reference-implementation/readable-stream-reader.html
+
+        * Modules/streams/ReadableStream.js:
+        (getReader): Removed check for locked stream.
+        * Modules/streams/ReadableStreamInternals.js:
+        (privateInitializeReadableStreamReader): Removed setting @error and @state and initialized owner and owner's
+        reader as per spec.
+        (teeReadableStreamPullFunction): Added assertions.
+        (isReadableStreamReader): Added comment about resetting the reader owner to null instead of undefined as a means
+        to distinguish between not having the slot and having it unset.
+        (finishClosingReadableStream): Inline @closeReadableStreamReader as it is used only here now.
+        (readFromReadableStreamReader): Reworked the state and error to use the stream one and changed the conditions to
+        pull again as per spec.
+        (errorReadableStream): Not releasing the reader and removed the reader error and state management.
+        (releaseReadableStreamReader): Deleted.
+        (closeReadableStreamReader): Deleted.
+        * Modules/streams/ReadableStreamReader.js:
+        (cancel): Removed some checks and assertions as per spec.
+        (read): Added check for owner.
+        (releaseLock): No closing the reader and rejecting close promise and unlinking reader and owner instead.
+        * Modules/streams/WritableStream.js:
+        (abort): Style change.
+        * Modules/streams/WritableStreamInternals.js:
+        (writableStreamAdvanceQueue):
+        (closeWritableStream): Used @call instead of @apply.
+
</ins><span class="cx"> 2015-11-15  Adam Bergkvist  &lt;adam.bergkvist@ericsson.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebRTC: Update RTCPeerConnection API and introduce PeerConnectionBackend
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.js (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStream.js        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.js        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -87,9 +87,6 @@
</span><span class="cx">     if (!@isReadableStream(this))
</span><span class="cx">         throw new @TypeError(&quot;Function should be called on a ReadableStream&quot;);
</span><span class="cx"> 
</span><del>-    if (@isReadableStreamLocked(this))
-        throw new @TypeError(&quot;ReadableStream is locked&quot;);
-
</del><span class="cx">     return new @ReadableStreamReader(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamInternalsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -36,24 +36,18 @@
</span><span class="cx">     if (@isReadableStreamLocked(stream))
</span><span class="cx">        throw new @TypeError(&quot;ReadableStream is locked&quot;);
</span><span class="cx"> 
</span><del>-    this.@state = stream.@state;
</del><span class="cx">     this.@readRequests = [];
</span><ins>+    this.@ownerReadableStream = stream;
+    stream.@reader = this;
</ins><span class="cx">     if (stream.@state === @streamReadable) {
</span><del>-        this.@ownerReadableStream = stream;
-        this.@storedError = undefined;
-        stream.@reader = this;
</del><span class="cx">         this.@closedPromiseCapability = @newPromiseCapability(@Promise);
</span><span class="cx">         return this;
</span><span class="cx">     }
</span><span class="cx">     if (stream.@state === @streamClosed) {
</span><del>-        this.@ownerReadableStream = null;
-        this.@storedError = undefined;
</del><span class="cx">         this.@closedPromiseCapability = { @promise: @Promise.@resolve() };
</span><span class="cx">         return this;
</span><span class="cx">     }
</span><span class="cx">     @assert(stream.@state === @streamErrored);
</span><del>-    this.@ownerReadableStream = null;
-    this.@storedError = stream.@storedError;
</del><span class="cx">     this.@closedPromiseCapability = { @promise: @Promise.@reject(stream.@storedError) };
</span><span class="cx"> 
</span><span class="cx">     return this;
</span><span class="lines">@@ -123,6 +117,8 @@
</span><span class="cx"> 
</span><span class="cx">     return function() {
</span><span class="cx">         @Promise.prototype.@then.@call(reader.read(), function(result) {
</span><ins>+            @assert(@isObject(result));
+            @assert(typeof result.done === &quot;boolean&quot;);
</ins><span class="cx">             if (result.done &amp;&amp; !teeState.closedOrErrored) {
</span><span class="cx">                 @closeReadableStream(teeState.branch1);
</span><span class="cx">                 @closeReadableStream(teeState.branch2);
</span><span class="lines">@@ -185,6 +181,8 @@
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><ins>+    // To reset @ownerReadableStream it must be set to null instead of undefined because there is no way to distinguish
+    // between a non-existent slot and an slot set to undefined.
</ins><span class="cx">     return @isObject(reader) &amp;&amp; typeof reader.@ownerReadableStream !== &quot;undefined&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -213,10 +211,6 @@
</span><span class="cx">         requests[index].@reject.@call(undefined, error);
</span><span class="cx">     reader.@readRequests = [];
</span><span class="cx"> 
</span><del>-    @releaseReadableStreamReader(reader);
-    reader.@storedError = error;
-    reader.@state = @streamErrored;
-
</del><span class="cx">     reader.@closedPromiseCapability.@reject.@call(undefined, error);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -224,7 +218,7 @@
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><del>-    if (stream.@state !== @streamReadable)
</del><ins>+    if (stream.@state === @streamClosed || stream.@state === @streamErrored)
</ins><span class="cx">         return;
</span><span class="cx">     if (stream.@closeRequested)
</span><span class="cx">         return;
</span><span class="lines">@@ -257,6 +251,7 @@
</span><span class="cx"> {
</span><span class="cx">    &quot;use strict&quot;;
</span><span class="cx"> 
</span><ins>+    @assert(@isReadableStream(stream));
</ins><span class="cx">     return !!stream.@reader;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -267,14 +262,6 @@
</span><span class="cx">    return stream.@strategy.highWaterMark - stream.@queue.size;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function releaseReadableStreamReader(reader)
-{
-    &quot;use strict&quot;;
-
-    reader.@ownerReadableStream.@reader = undefined;
-    reader.@ownerReadableStream = null;
-}
-
</del><span class="cx"> function cancelReadableStream(stream, reason)
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="lines">@@ -295,8 +282,14 @@
</span><span class="cx">     @assert(stream.@state ===  @streamReadable);
</span><span class="cx">     stream.@state = @streamClosed;
</span><span class="cx">     const reader = stream.@reader;
</span><del>-    if (reader)
-        @closeReadableStreamReader(reader);
</del><ins>+    if (!reader)
+        return;
+
+    const requests = reader.@readRequests;
+    for (let index = 0, length = requests.length; index &lt; length; ++index)
+        requests[index].@resolve.@call(undefined, {value:undefined, done: true});
+    reader.@readRequests = [];
+    reader.@closedPromiseCapability.@resolve.@call();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function closeReadableStream(stream)
</span><span class="lines">@@ -312,19 +305,6 @@
</span><span class="cx">         @finishClosingReadableStream(stream);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function closeReadableStreamReader(reader)
-{
-    &quot;use strict&quot;;
-
-    const requests = reader.@readRequests;
-    for (let index = 0, length = requests.length; index &lt; length; ++index)
-        requests[index].@resolve.@call(undefined, {value:undefined, done: true});
-    reader.@readRequests = [];
-    @releaseReadableStreamReader(reader);
-    reader.@state = @streamClosed;
-    reader.@closedPromiseCapability.@resolve.@call();
-}
-
</del><span class="cx"> function enqueueInReadableStream(stream, chunk)
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="lines">@@ -358,19 +338,19 @@
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><del>-    if (reader.@state === @streamClosed)
-        return @Promise.@resolve({value: undefined, done: true});
-    if (reader.@state === @streamErrored)
-        return @Promise.@reject(reader.@storedError);
-    @assert(!!reader.@ownerReadableStream);
-    @assert(reader.@ownerReadableStream.@state === @streamReadable);
</del><span class="cx">     const stream = reader.@ownerReadableStream;
</span><ins>+    @assert(!!stream);
+    if (stream.@state === @streamClosed)
+        return @Promise.@resolve({value: undefined, done: true});
+    if (stream.@state === @streamErrored)
+        return @Promise.@reject(stream.@storedError);
+    @assert(stream.@state === @streamReadable);
</ins><span class="cx">     if (stream.@queue.content.length) {
</span><span class="cx">         const chunk = @dequeueValue(stream.@queue);
</span><del>-        if (!stream.@closeRequested)
-            @requestReadableStreamPull(stream);
-        else if (!stream.@queue.content.length)
</del><ins>+        if (stream.@closeRequested &amp;&amp; stream.@queue.content.length === 0)
</ins><span class="cx">             @finishClosingReadableStream(stream);
</span><ins>+        else
+            @requestReadableStreamPull(stream);
</ins><span class="cx">         return @Promise.@resolve({value: chunk, done: false});
</span><span class="cx">     }
</span><span class="cx">     const readPromiseCapability = @newPromiseCapability(@Promise);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamReaderjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamReader.js (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamReader.js        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamReader.js        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -32,14 +32,9 @@
</span><span class="cx">     if (!@isReadableStreamReader(this))
</span><span class="cx">         return @Promise.@reject(new @TypeError(&quot;Function should be called on a ReadableStreamReader&quot;));
</span><span class="cx"> 
</span><del>-    if (this.@state === @streamClosed)
-        return @Promise.@resolve();
</del><ins>+    if (!this.@ownerReadableStream)
+        return @Promise.@reject(new @TypeError(&quot;cancel() called on a reader owned by no readable stream&quot;));
</ins><span class="cx"> 
</span><del>-    if (this.@state === @streamErrored)
-        return @Promise.@reject(this.@storedError);
-
-    @assert(@isReadableStream(this.@ownerReadableStream));
-    @assert(this.@ownerReadableStream.@state === @streamReadable);
</del><span class="cx">     return @cancelReadableStream(this.@ownerReadableStream, reason);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -49,6 +44,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (!@isReadableStreamReader(this))
</span><span class="cx">         return @Promise.@reject(new @TypeError(&quot;Function should be called on a ReadableStreamReader&quot;));
</span><ins>+    if (!this.@ownerReadableStream)
+        return @Promise.@reject(new @TypeError(&quot;read() called on a reader owned by no readable stream&quot;));
</ins><span class="cx"> 
</span><span class="cx">     return @readFromReadableStreamReader(this);
</span><span class="cx"> }
</span><span class="lines">@@ -60,13 +57,20 @@
</span><span class="cx">     if (!@isReadableStreamReader(this))
</span><span class="cx">         throw new @TypeError(&quot;Function should be called on a ReadableStreamReader&quot;);
</span><span class="cx"> 
</span><del>-    if (!this.@ownerReadableStream)
</del><ins>+    const stream = this.@ownerReadableStream;
+    if (!stream)
</ins><span class="cx">          return;
</span><span class="cx"> 
</span><span class="cx">     if (this.@readRequests.length)
</span><span class="cx">         throw new @TypeError(&quot;There are still pending read requests, cannot release the lock&quot;);
</span><span class="cx"> 
</span><del>-    @closeReadableStreamReader(this);
</del><ins>+    if (stream.@state === @streamReadable)
+        this.@closedPromiseCapability.@reject.@call(undefined, new @TypeError(&quot;releasing lock of reader whose stream is still in readable state&quot;));
+    else
+        this.@closedPromiseCapability = { @promise: @Promise.@reject(new @TypeError(&quot;reader released lock&quot;)) };
+
+    stream.@reader = undefined;
+    this.@ownerReadableStream = null;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function closed()
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsWritableStreamjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/WritableStream.js (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/WritableStream.js        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/Source/WebCore/Modules/streams/WritableStream.js        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx"> 
</span><span class="cx">     const sinkAbortPromise = @promiseInvokeOrFallbackOrNoop(this.@underlyingSink, &quot;abort&quot;, [reason], &quot;close&quot;, []);
</span><span class="cx"> 
</span><del>-    return @Promise.prototype.@then.@call(sinkAbortPromise, function() { return undefined; });
</del><ins>+    return @Promise.prototype.@then.@call(sinkAbortPromise, function() { });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function close()
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsWritableStreamInternalsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js (192465 => 192466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js        2015-11-16 07:42:36 UTC (rev 192465)
+++ trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js        2015-11-16 10:21:37 UTC (rev 192466)
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx">             @writableStreamAdvanceQueue(stream);
</span><span class="cx">         },
</span><span class="cx">         function(r) {
</span><del>-            @errorWritableStream.@apply(stream, [r]);
</del><ins>+            @errorWritableStream.@call(stream, r);
</ins><span class="cx">         }
</span><span class="cx">     );
</span><span class="cx"> }
</span><span class="lines">@@ -129,7 +129,7 @@
</span><span class="cx">             stream.@state = @streamClosed;
</span><span class="cx">         },
</span><span class="cx">         function(r) {
</span><del>-            @errorWritableStream.@apply(stream, [r]);
</del><ins>+            @errorWritableStream.@call(stream, r);
</ins><span class="cx">         }
</span><span class="cx">     );
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>