<!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>[191584] 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/191584">191584</a></dd>
<dt>Author</dt> <dd>calvaris@igalia.com</dd>
<dt>Date</dt> <dd>2015-10-26 08:09:16 -0700 (Mon, 26 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Streams API] Implement abort method on writable streams
https://bugs.webkit.org/show_bug.cgi?id=150444

Reviewed by Darin Adler.

Source/WebCore:

Abort method on writable streams implemented according to the spec.

Current test set suffices. Expectations are updated accordingly.

* Modules/streams/StreamInternals.js:
(promiseInvokeOrFallbackOrNoop): Implemented according to the spec.
* Modules/streams/WritableStream.js:
(abort): Implemented according to the spec.

LayoutTests:

Test expectations updated.

* streams/reference-implementation/bad-underlying-sinks-expected.txt:
* streams/reference-implementation/brand-checks-expected.txt:
* streams/reference-implementation/pipe-to-expected.txt:
* streams/reference-implementation/writable-stream-abort-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationbadunderlyingsinksexpectedtxt">trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationbrandchecksexpectedtxt">trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationpipetoexpectedtxt">trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationwritablestreamabortexpectedtxt">trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsStreamInternalsjs">trunk/Source/WebCore/Modules/streams/StreamInternals.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsWritableStreamjs">trunk/Source/WebCore/Modules/streams/WritableStream.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (191583 => 191584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/ChangeLog        2015-10-26 15:09:16 UTC (rev 191584)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-10-26  Xabier Rodriguez Calvar  &lt;calvaris@igalia.com&gt;
+
+        [Streams API] Implement abort method on writable streams
+        https://bugs.webkit.org/show_bug.cgi?id=150444
+
+        Reviewed by Darin Adler.
+
+        Test expectations updated.
+
+        * streams/reference-implementation/bad-underlying-sinks-expected.txt:
+        * streams/reference-implementation/brand-checks-expected.txt:
+        * streams/reference-implementation/pipe-to-expected.txt:
+        * streams/reference-implementation/writable-stream-abort-expected.txt:
+
</ins><span class="cx"> 2015-10-25  Sun-woo Nam  &lt;sunny.nam@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Unreviewed gardening. some test expectations for media should be Failure.
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationbadunderlyingsinksexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt (191583 => 191584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt        2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/streams/reference-implementation/bad-underlying-sinks-expected.txt        2015-10-26 15:09:16 UTC (rev 191584)
</span><span class="lines">@@ -3,8 +3,8 @@
</span><span class="cx"> PASS Underlying sink: throwing start method 
</span><span class="cx"> FAIL Underlying sink: throwing write getter write not implemented
</span><span class="cx"> FAIL Underlying sink: throwing write method write not implemented
</span><del>-FAIL Underlying sink: throwing abort getter abort not implemented
-FAIL Underlying sink: throwing abort method abort not implemented
</del><ins>+PASS Underlying sink: throwing abort getter 
+PASS Underlying sink: throwing abort method 
</ins><span class="cx"> FAIL Underlying sink: throwing close getter close not implemented
</span><span class="cx"> FAIL Underlying sink: throwing close method close not implemented
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationbrandchecksexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt (191583 => 191584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt        2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/streams/reference-implementation/brand-checks-expected.txt        2015-10-26 15:09:16 UTC (rev 191584)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> PASS WritableStream.prototype.closed enforces a brand check 
</span><span class="cx"> PASS WritableStream.prototype.ready enforces a brand check 
</span><span class="cx"> PASS WritableStream.prototype.state enforces a brand check 
</span><del>-FAIL WritableStream.prototype.abort enforces a brand check abort not implemented
</del><ins>+PASS WritableStream.prototype.abort enforces a brand check 
</ins><span class="cx"> FAIL WritableStream.prototype.write enforces a brand check write not implemented
</span><span class="cx"> FAIL WritableStream.prototype.close enforces a brand check close not implemented
</span><span class="cx"> PASS ByteLengthQueuingStrategy.prototype.size should work generically on its this and its arguments 
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationpipetoexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt (191583 => 191584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt        2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/streams/reference-implementation/pipe-to-expected.txt        2015-10-26 15:09:16 UTC (rev 191584)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx"> FAIL Piping from an empty ReadableStream which becomes closed after a pipeTo call to a WritableStream in the waiting state whose writes never complete write not implemented
</span><span class="cx"> FAIL Piping from an empty ReadableStream which becomes errored after a pipeTo call to a WritableStream in the waiting state write not implemented
</span><span class="cx"> FAIL Piping to a duck-typed asynchronous &quot;writable stream&quot; works pipeTo is not implemented
</span><del>-FAIL Piping to a stream that has been aborted passes through the error as the cancellation reason abort not implemented
</del><ins>+FAIL Piping to a stream that has been aborted passes through the error as the cancellation reason pipeTo is not implemented
</ins><span class="cx"> FAIL Piping to a stream and then aborting it passes through the error as the cancellation reason pipeTo is not implemented
</span><span class="cx"> FAIL Piping to a stream that has been closed propagates a TypeError cancellation reason backward close not implemented
</span><span class="cx"> FAIL Piping to a stream and then closing it propagates a TypeError cancellation reason backward pipeTo is not implemented
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationwritablestreamabortexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt (191583 => 191584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt        2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt        2015-10-26 15:09:16 UTC (rev 191584)
</span><span class="lines">@@ -1,14 +1,14 @@
</span><span class="cx"> 
</span><del>-FAIL Aborting a WritableStream immediately prevents future writes abort not implemented
</del><ins>+FAIL Aborting a WritableStream immediately prevents future writes write not implemented
</ins><span class="cx"> FAIL Aborting a WritableStream prevents further writes after any that are in progress write not implemented
</span><del>-FAIL Fulfillment value of ws.abort() call must be undefined even if the underlying sink returns a non-undefined value abort not implemented
-FAIL WritableStream if sink's abort throws, the promise returned by ws.abort() rejects abort not implemented
-FAIL Aborting a WritableStream passes through the given reason abort not implemented
-FAIL Aborting a WritableStream puts it in an errored state, with stored error equal to the abort reason abort not implemented
</del><ins>+PASS Fulfillment value of ws.abort() call must be undefined even if the underlying sink returns a non-undefined value 
+PASS WritableStream if sink's abort throws, the promise returned by ws.abort() rejects 
+PASS Aborting a WritableStream passes through the given reason 
+FAIL Aborting a WritableStream puts it in an errored state, with stored error equal to the abort reason write not implemented
</ins><span class="cx"> FAIL Aborting a WritableStream causes any outstanding ready promises to be fulfilled immediately write not implemented
</span><span class="cx"> FAIL Aborting a WritableStream causes any outstanding write() promises to be rejected with the abort reason write not implemented
</span><span class="cx"> FAIL Closing but then immediately aborting a WritableStream causes the stream to error close not implemented
</span><span class="cx"> FAIL Closing a WritableStream and aborting it while it closes causes the stream to error close not implemented
</span><span class="cx"> FAIL Aborting a WritableStream after it is closed is a no-op close not implemented
</span><del>-FAIL WritableStream should call underlying sink's close if no abort is supplied abort not implemented
</del><ins>+PASS WritableStream should call underlying sink's close if no abort is supplied 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191583 => 191584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/Source/WebCore/ChangeLog        2015-10-26 15:09:16 UTC (rev 191584)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-10-26  Xabier Rodriguez Calvar  &lt;calvaris@igalia.com&gt;
+
+        [Streams API] Implement abort method on writable streams
+        https://bugs.webkit.org/show_bug.cgi?id=150444
+
+        Reviewed by Darin Adler.
+
+        Abort method on writable streams implemented according to the spec.
+
+        Current test set suffices. Expectations are updated accordingly.
+
+        * Modules/streams/StreamInternals.js:
+        (promiseInvokeOrFallbackOrNoop): Implemented according to the spec.
+        * Modules/streams/WritableStream.js:
+        (abort): Implemented according to the spec.
+
</ins><span class="cx"> 2015-10-25  Hunseop Jeong  &lt;hs85.jeong@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Use modern for-loops in WebCore/editing.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsStreamInternalsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/StreamInternals.js (191583 => 191584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/StreamInternals.js        2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/Source/WebCore/Modules/streams/StreamInternals.js        2015-10-26 15:09:16 UTC (rev 191584)
</span><span class="lines">@@ -54,6 +54,22 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function promiseInvokeOrFallbackOrNoop(object, key1, args1, key2, args2)
+{
+    &quot;use strict&quot;;
+
+    try {
+        const method = object[key1];
+        if (typeof method === &quot;undefined&quot;)
+            return @promiseInvokeOrNoop(object, key2, args2);
+        const result = method.@apply(object, args1);
+        return Promise.resolve(result);
+    }
+    catch(error) {
+        return Promise.reject(error);
+    }
+}
+
</ins><span class="cx"> function validateAndNormalizeQueuingStrategy(size, highWaterMark)
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsWritableStreamjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/WritableStream.js (191583 => 191584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/WritableStream.js        2015-10-26 12:04:05 UTC (rev 191583)
+++ trunk/Source/WebCore/Modules/streams/WritableStream.js        2015-10-26 15:09:16 UTC (rev 191584)
</span><span class="lines">@@ -68,7 +68,20 @@
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><del>-    throw new EvalError(&quot;abort not implemented&quot;);
</del><ins>+    if (!@isWritableStream(this))
+        return Promise.reject(new @TypeError(&quot;The WritableStream.abort method can only be used on instances of WritableStream&quot;));
+
+    if (this.@state === &quot;closed&quot;)
+        return Promise.resolve(undefined);
+
+    if (this.@state === &quot;errored&quot;)
+        return Promise.reject(this.@storedError);
+
+    @errorWritableStream.@apply(this, [reason]);
+
+    const sinkAbortPromise = @promiseInvokeOrFallbackOrNoop(this.@underlyingSink, &quot;abort&quot;, [reason], &quot;close&quot;, []);
+
+    return sinkAbortPromise.then(function() { return undefined; });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function close()
</span></span></pre>
</div>
</div>

</body>
</html>