Diff
Modified: trunk/LayoutTests/ChangeLog (185696 => 185697)
--- trunk/LayoutTests/ChangeLog 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/LayoutTests/ChangeLog 2015-06-18 08:58:18 UTC (rev 185697)
@@ -1,5 +1,16 @@
2015-06-18 Youenn Fablet <[email protected]> and Xabier Rodriguez Calvar <[email protected]>
+ [Streams API] Implement ReadableStreamReader.releaseLock
+ https://bugs.webkit.org/show_bug.cgi?id=145299
+
+ Reviewed by Darin Adler.
+
+ * streams/reference-implementation/readable-stream-expected.txt: Rebasing expectations.
+ * streams/reference-implementation/readable-stream-reader-expected.txt: Ditto.
+ * streams/reference-implementation/readable-stream-templated-expected.txt: Ditto.
+
+2015-06-18 Youenn Fablet <[email protected]> and Xabier Rodriguez Calvar <[email protected]>
+
[Streams API] Rejected start promise test does not timeout anymore
https://bugs.webkit.org/show_bug.cgi?id=146065
Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt (185696 => 185697)
--- trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt 2015-06-18 08:58:18 UTC (rev 185697)
@@ -25,7 +25,7 @@
PASS ReadableStream: enqueue should throw when the stream is readable but draining
PASS ReadableStream: enqueue should throw when the stream is closed
PASS ReadableStream: enqueue should throw the stored error when the stream is errored
-FAIL ReadableStream: should call underlying source methods as methods releaseLock is not implemented
+FAIL ReadableStream: should call underlying source methods as methods cancel is not implemented
FAIL ReadableStream strategies: the default strategy should give desiredSize of 1 to start, decreasing by 1 per enqueue assert_equals: expected (number) 1 but got (undefined) undefined
FAIL ReadableStream strategies: the default strategy should continue giving desiredSize of 1 if the chunks are read immediately assert_equals: desiredSize should start at 1 expected (number) 1 but got (undefined) undefined
PASS ReadableStream integration test: adapting a random push source
Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt (185696 => 185697)
--- trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt 2015-06-18 08:58:18 UTC (rev 185697)
@@ -12,10 +12,10 @@
PASS Reading from a reader for an empty stream will wait until a chunk is available
FAIL cancel() on a reader releases the reader before calling through cancel is not implemented
PASS closed should be fulfilled after stream is closed (.closed access before acquiring)
-FAIL closed should be fulfilled after reader releases its lock (multiple stream locks) releaseLock is not implemented
-FAIL Multiple readers can access the stream in sequence releaseLock is not implemented
-FAIL Cannot use an already-released reader to unlock a stream again releaseLock is not implemented
-FAIL cancel() on a released reader is a no-op and does not pass through releaseLock is not implemented
+PASS closed should be fulfilled after reader releases its lock (multiple stream locks)
+PASS Multiple readers can access the stream in sequence
+PASS Cannot use an already-released reader to unlock a stream again
+FAIL cancel() on a released reader is a no-op and does not pass through cancel is not implemented
PASS Getting a second reader after erroring the stream should succeed
PASS Garbage-collecting a ReadableStreamReader should not unlock its stream
Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt (185696 => 185697)
--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt 2015-06-18 08:58:18 UTC (rev 185697)
@@ -8,10 +8,10 @@
PASS two read()s should both never settle
PASS read() should return distinct promises each time
PASS getReader() again on the stream should fail
-FAIL releasing the lock with pending read requests should throw but the read requests should stay pending releaseLock is not implemented
-FAIL releasing the lock should cause further read() calls to resolve as if the stream is closed releaseLock is not implemented
-FAIL releasing the lock should cause closed to fulfill releaseLock is not implemented
-FAIL releasing the lock should cause locked to become false releaseLock is not implemented
+FAIL releasing the lock with pending read requests should throw but the read requests should stay pending Type error
+PASS releasing the lock should cause further read() calls to resolve as if the stream is closed
+PASS releasing the lock should cause closed to fulfill
+PASS releasing the lock should cause locked to become false
FAIL canceling via the reader should cause the reader to act closed cancel is not implemented
FAIL canceling via the stream should fail cancel is not implemented
PASS Running templatedRSClosed with ReadableStream (closed via call in start)
@@ -54,7 +54,7 @@
PASS third read(), without waiting, should give { value: undefined, done: true }
PASS third read, with waiting, should give { value: undefined, done: true }
PASS draining the stream via read() should cause the reader closed promise to fulfill and locked to be false
-FAIL releasing the lock after the stream is closed should do nothing releaseLock is not implemented
-FAIL releasing the lock should cause read() to act as if the stream is closed releaseLock is not implemented
-FAIL reader's closed property always returns the same promise releaseLock is not implemented
+PASS releasing the lock after the stream is closed should do nothing
+PASS releasing the lock should cause read() to act as if the stream is closed
+PASS reader's closed property always returns the same promise
Modified: trunk/Source/WebCore/ChangeLog (185696 => 185697)
--- trunk/Source/WebCore/ChangeLog 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/Source/WebCore/ChangeLog 2015-06-18 08:58:18 UTC (rev 185697)
@@ -1,3 +1,24 @@
+2015-06-18 Youenn Fablet <[email protected]> and Xabier Rodriguez Calvar <[email protected]>
+
+ [Streams API] Implement ReadableStreamReader.releaseLock
+ https://bugs.webkit.org/show_bug.cgi?id=145299
+
+ Reviewed by Darin Adler.
+
+ Covered by rebased tests.
+
+ * Modules/streams/ReadableStream.cpp:
+ (WebCore::ReadableStream::close): Moving some close code to newly added releaseReader.
+ (WebCore::ReadableStream::releaseReader): Implements reader release and callbacks finalization.
+ (WebCore::ReadableStream::changeStateToErrored): Calls releaseReader.
+ * Modules/streams/ReadableStream.h:
+ (WebCore::ReadableStream::hasReadPendingRequests): Added to enable reader.releaseLock throwing if read requests are pending.
+ * Modules/streams/ReadableStreamReader.cpp:
+ (WebCore::ReadableStreamReader::releaseLock): Implementation of releaseLock
+ * Modules/streams/ReadableStreamReader.h:
+ * Modules/streams/ReadableStreamReader.idl:
+ (WebCore::releaseLock): Deleted.
+
2015-06-18 Youenn Fablet <[email protected]>
GObject and ObjC bindings generator should not generate code for promise-based APIs
Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.cpp (185696 => 185697)
--- trunk/Source/WebCore/Modules/streams/ReadableStream.cpp 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.cpp 2015-06-18 08:58:18 UTC (rev 185697)
@@ -79,10 +79,11 @@
void ReadableStream::close()
{
m_state = State::Closed;
+ releaseReader();
+}
- if (m_reader)
- m_releasedReaders.append(WTF::move(m_reader));
-
+void ReadableStream::releaseReader()
+{
if (m_closedSuccessCallback)
m_closedSuccessCallback();
@@ -90,6 +91,8 @@
request.endCallback();
clearCallbacks();
+ if (m_reader)
+ m_releasedReaders.append(WTF::move(m_reader));
}
void ReadableStream::changeStateToErrored()
@@ -98,9 +101,6 @@
return;
m_state = State::Errored;
- if (m_reader)
- m_releasedReaders.append(WTF::move(m_reader));
-
JSC::JSValue error = this->error();
if (m_closedFailureCallback)
m_closedFailureCallback(error);
@@ -109,6 +109,8 @@
request.failureCallback(error);
clearCallbacks();
+ if (m_reader)
+ releaseReader();
}
void ReadableStream::start()
Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.h (185696 => 185697)
--- trunk/Source/WebCore/Modules/streams/ReadableStream.h 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.h 2015-06-18 08:58:18 UTC (rev 185697)
@@ -67,6 +67,9 @@
bool locked() const { return !!m_reader; }
+ void releaseReader();
+ bool hasReadPendingRequests() { return !m_readRequests.isEmpty(); }
+
bool isErrored() const { return m_state == State::Errored; }
bool isReadable() const { return m_state == State::Readable; }
bool isCloseRequested() const { return m_closeRequested; }
Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamReader.cpp (185696 => 185697)
--- trunk/Source/WebCore/Modules/streams/ReadableStreamReader.cpp 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamReader.cpp 2015-06-18 08:58:18 UTC (rev 185697)
@@ -30,6 +30,7 @@
#include "config.h"
#include "ReadableStreamReader.h"
+#include "ExceptionCode.h"
#include <runtime/JSCJSValueInlines.h>
#if ENABLE(STREAMS_API)
@@ -54,6 +55,17 @@
m_stream.read(WTF::move(successCallback), WTF::move(endCallback), WTF::move(failureCallback));
}
+void ReadableStreamReader::releaseLock(ExceptionCode& ec)
+{
+ if (m_stream.reader() != this)
+ return;
+ if (m_stream.hasReadPendingRequests()) {
+ ec = TypeError;
+ return;
+ }
+ m_stream.releaseReader();
}
+}
+
#endif
Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamReader.h (185696 => 185697)
--- trunk/Source/WebCore/Modules/streams/ReadableStreamReader.h 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamReader.h 2015-06-18 08:58:18 UTC (rev 185697)
@@ -41,6 +41,8 @@
namespace WebCore {
+typedef int ExceptionCode;
+
// ReadableStreamReader implements access to ReadableStream from _javascript_.
// It basically allows access to the ReadableStream iff the ReadableStreamReader instance is the active reader
// of the ReadableStream.
@@ -53,6 +55,7 @@
void closed(ReadableStream::ClosedSuccessCallback&&, ReadableStream::FailureCallback&&);
void read(ReadableStream::ReadSuccessCallback&&, ReadableStream::ReadEndCallback&&, ReadableStream::FailureCallback&&);
+ void releaseLock(ExceptionCode&);
void ref() { m_stream.ref(); }
void deref() { m_stream.deref(); }
Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamReader.idl (185696 => 185697)
--- trunk/Source/WebCore/Modules/streams/ReadableStreamReader.idl 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamReader.idl 2015-06-18 08:58:18 UTC (rev 185697)
@@ -36,7 +36,7 @@
// FIXME: Remove RaisesException once methods are implemented.
[Custom, RaisesException] Object read();
[Custom, RaisesException] Promise cancel(DOMString reason);
- [Custom, RaisesException] void releaseLock();
+ [RaisesException] void releaseLock();
[CustomGetter] readonly attribute Promise closed;
};
Modified: trunk/Source/WebCore/bindings/js/JSReadableStreamReaderCustom.cpp (185696 => 185697)
--- trunk/Source/WebCore/bindings/js/JSReadableStreamReaderCustom.cpp 2015-06-18 08:57:09 UTC (rev 185696)
+++ trunk/Source/WebCore/bindings/js/JSReadableStreamReaderCustom.cpp 2015-06-18 08:58:18 UTC (rev 185697)
@@ -92,12 +92,6 @@
return exec->vm().throwException(exec, error);
}
-JSValue JSReadableStreamReader::releaseLock(ExecState* exec)
-{
- JSValue error = createError(exec, ASCIILiteral("releaseLock is not implemented"));
- return exec->vm().throwException(exec, error);
-}
-
EncodedJSValue JSC_HOST_CALL constructJSReadableStreamReader(ExecState* exec)
{
if (!exec->argumentCount())