Changeset 185197 in webkit
- Timestamp:
- Jun 4, 2015 3:19:43 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r185192 r185197 1 2015-06-04 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Streams API] Implement ReadableStreamController enqueue 4 https://bugs.webkit.org/show_bug.cgi?id=145210 5 6 Reviewed by Darin Adler. 7 8 * streams/reference-implementation/bad-underlying-sources-expected.txt: 9 * streams/reference-implementation/count-queuing-strategy-expected.txt: 10 * streams/reference-implementation/count-queuing-strategy.html: 11 * streams/reference-implementation/readable-stream-expected.txt: 12 * streams/reference-implementation/readable-stream-reader-expected.txt: 13 * streams/reference-implementation/readable-stream-reader.html: 14 * streams/reference-implementation/readable-stream-templated-expected.txt: 15 * streams/reference-implementation/readable-stream-templated.html: 16 * streams/reference-implementation/readable-stream.html: 17 1 18 2015-06-03 Zalan Bujtas <zalan@apple.com> 2 19 -
trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources-expected.txt
r185114 r185197 19 19 FAIL Underlying source: strategy.size returning +Infinity assert_unreached: enqueue didn't throw Reached unreachable code 20 20 PASS Underlying source: calling close twice on an empty stream should throw the second time 21 FAIL Underlying source: calling close twice on a non-empty stream should throw the second time assert_object_equals: read() should read the enqueued chunk property "done" expected object "[object Object]" got object "[object Object]" 21 PASS Underlying source: calling close twice on a non-empty stream should throw the second time 22 22 FAIL Underlying source: calling close on an empty canceled stream should not throw cancel is not implemented 23 23 FAIL Underlying source: calling close on a non-empty canceled stream should not throw cancel is not implemented -
trunk/LayoutTests/streams/reference-implementation/count-queuing-strategy-expected.txt
r185114 r185197 3 3 PASS Gives a RangeError when the number is negative 4 4 PASS Can construct a readable stream with a valid CountQueuingStrategy 5 TIMEOUT Correctly governs the return value of a ReadableStream's enqueue function (HWM = 0) Test timed out 6 FAIL Correctly governs the return value of a ReadableStream's enqueue function (HWM = 1) assert_equals: After 0 reads, 1st enqueue should return true (queue now contains 1 chunk) expected true but got false7 FAIL Correctly governs the return value of a ReadableStream's enqueue function (HWM = 4) assert_equals: After 0 reads, 1st enqueue should return true (queue now contains 1 chunk) expected true but got false5 FAIL Correctly governs the return value of a ReadableStream's enqueue function (HWM = 0) assert_equals: After 0 reads, 1st enqueue should return false (queue now contains 1 chunk) expected (boolean) false but got (undefined) undefined 6 FAIL Correctly governs the return value of a ReadableStream's enqueue function (HWM = 1) assert_equals: After 0 reads, 1st enqueue should return true (queue now contains 1 chunk) expected (boolean) true but got (undefined) undefined 7 FAIL Correctly governs the return value of a ReadableStream's enqueue function (HWM = 4) assert_equals: After 0 reads, 1st enqueue should return true (queue now contains 1 chunk) expected (boolean) true but got (undefined) undefined 8 8 -
trunk/LayoutTests/streams/reference-implementation/count-queuing-strategy.html
r185114 r185197 18 18 }, 'Can construct a readable stream with a valid CountQueuingStrategy'); 19 19 20 var test1 = async_test('Correctly governs the return value of a ReadableStream\'s enqueue function (HWM = 0)' , { timeout: 50 });20 var test1 = async_test('Correctly governs the return value of a ReadableStream\'s enqueue function (HWM = 0)'); 21 21 test1.step(function() { 22 22 var enqueue; -
trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt
r185114 r185197 8 8 TIMEOUT ReadableStream start should be able to return a promise Test timed out 9 9 TIMEOUT ReadableStream start should be able to return a promise and reject it Test timed out 10 FAIL ReadableStream should be able to enqueue different objects. assert_object_equals: value read should be the one enqueued property "done" expected object "[object Object]" got object "[object Object]" 10 PASS ReadableStream should be able to enqueue different objects. 11 11 PASS ReadableStream: if start throws an error, it should be re-thrown 12 12 TIMEOUT ReadableStream: if pull rejects, it should error the stream Test timed out 13 TIMEOUT ReadableStream: should not call pull until the previous pull call's promise fulfills Test timed out 13 FAIL ReadableStream: should not call pull until the previous pull call's promise fulfills assert_equals: pull should have been called once after start, but not yet have been called a second time expected 1 but got 0 14 14 PASS ReadableStream: should not call pull after start if the stream is now closed 15 15 FAIL ReadableStream: should call pull after enqueueing from inside pull (with no read requests), if strategy allows assert_equals: pull() should have been called four times expected 4 but got 0 16 16 TIMEOUT ReadableStream pull should be able to close a stream. Test timed out 17 FAIL ReadableStream: enqueue should throw when the stream is readable but draining assert_equals: the first enqueue should return true expected true but got false18 FAIL ReadableStream: enqueue should throw when the stream is closed assert_throws: enqueue after close should throw a TypeError function "function () { c.enqueue('a'); }" did not throw 19 FAIL ReadableStream: enqueue should throw the stored error when the stream is errored assert_throws: enqueue after error should throw that error function "function () { c.enqueue('a'); }" did not throw 20 TIMEOUT ReadableStream: should call underlying source methods as methods Test timed out 21 FAIL ReadableStream strategies: the default strategy should return false for all but the first enqueue call assert_equals: first enqueue should return true expected true but got false22 FAIL ReadableStream strategies: the default strategy should continue returning true from enqueue if the chunks are read immediately assert_equals: first enqueue should return true expected true but got false17 FAIL ReadableStream: enqueue should throw when the stream is readable but draining assert_equals: the first enqueue should return true expected (boolean) true but got (undefined) undefined 18 PASS ReadableStream: enqueue should throw when the stream is closed 19 PASS ReadableStream: enqueue should throw the stored error when the stream is errored 20 FAIL ReadableStream: should call underlying source methods as methods releaseLock is not implemented 21 FAIL ReadableStream strategies: the default strategy should return false for all but the first enqueue call assert_equals: first enqueue should return true expected (boolean) true but got (undefined) undefined 22 FAIL ReadableStream strategies: the default strategy should continue returning true from enqueue if the chunks are read immediately assert_equals: first enqueue should return true expected (boolean) true but got (undefined) undefined 23 23 TIMEOUT ReadableStream integration test: adapting a random push source Test timed out 24 24 TIMEOUT ReadableStream integration test: adapting a sync pull source Test timed out -
trunk/LayoutTests/streams/reference-implementation/readable-stream-reader-expected.txt
r185114 r185197 10 10 PASS Constructing a ReadableStreamReader directly should be OK if the stream is closed 11 11 PASS Constructing a ReadableStreamReader directly should be OK if the stream is errored 12 TIMEOUT Reading from a reader for an empty stream will wait until a chunk is available Test timed out 12 PASS Reading from a reader for an empty stream will wait until a chunk is available 13 13 FAIL cancel() on a reader releases the reader before calling through cancel is not implemented 14 14 PASS closed should be fulfilled after stream is closed (.closed access before acquiring) -
trunk/LayoutTests/streams/reference-implementation/readable-stream-reader.html
r185114 r185197 108 108 }, 'Constructing a ReadableStreamReader directly should be OK if the stream is errored'); 109 109 110 var test1 = async_test('Reading from a reader for an empty stream will wait until a chunk is available' , { timeout: 50 });110 var test1 = async_test('Reading from a reader for an empty stream will wait until a chunk is available'); 111 111 test1.step(function() { 112 112 var controller; -
trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt
r185114 r185197 31 31 PASS should be able to acquire multiple readers, since they are all auto-released 32 32 PASS Running templatedRSTwoChunksOpenReader with ReadableStream (two chunks enqueued, still open) reader 33 TIMEOUT calling read() twice without waiting will eventually give both chunks Test timed out 34 TIMEOUT calling read() twice with waiting will eventually give both chunks Test timed out 33 PASS calling read() twice without waiting will eventually give both chunks 34 PASS calling read() twice with waiting will eventually give both chunks 35 35 PASS read() should return distinct promises each time 36 36 FAIL cancel() after a read() should still give that single read result cancel is not implemented 37 37 PASS Running templatedRSTwoChunksClosedReader with ReadableStream (two chunks enqueued, then closed) reader 38 FAIL third read(), without waiting, should give { value: undefined, done: true } assert_object_equals: first result should be correct property "done" expected object "[object Object]" got object "[object Object]" 39 FAIL third read, with waiting, should give { value: undefined, done: true } assert_object_equals: first result should be correct property "done" expected object "[object Object]" got object "[object Object]" 38 PASS third read(), without waiting, should give { value: undefined, done: true } 39 PASS third read, with waiting, should give { value: undefined, done: true } 40 40 PASS draining the stream via read() should cause the reader closed promise to fulfill 41 41 FAIL releasing the lock after the stream is closed should do nothing releaseLock is not implemented -
trunk/LayoutTests/streams/reference-implementation/readable-stream-templated.html
r185114 r185197 370 370 }, 'Running templatedRSTwoChunksOpenReader with ' + label); 371 371 372 var test1 = async_test('calling read() twice without waiting will eventually give both chunks' , { timeout: 50 });372 var test1 = async_test('calling read() twice without waiting will eventually give both chunks'); 373 373 test1.step(function() { 374 374 var { reader } = factory(); -
trunk/LayoutTests/streams/reference-implementation/readable-stream.html
r185114 r185197 369 369 // }); 370 370 371 var test11 = async_test('ReadableStream: should not call pull until the previous pull call\'s promise fulfills' , { timeout: 50 });371 var test11 = async_test('ReadableStream: should not call pull until the previous pull call\'s promise fulfills'); 372 372 test11.step(function() { 373 373 var resolve; … … 566 566 }, 'ReadableStream: enqueue should throw the stored error when the stream is errored'); 567 567 568 var test16 = async_test('ReadableStream: should call underlying source methods as methods' , { timeout: 50 });568 var test16 = async_test('ReadableStream: should call underlying source methods as methods'); 569 569 test16.step(function() { 570 570 var startCalled = 0; -
trunk/Source/WebCore/ChangeLog
r185196 r185197 1 2015-06-04 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Streams API] Implement ReadableStreamController enqueue 4 https://bugs.webkit.org/show_bug.cgi?id=145210 5 6 Reviewed by Darin Adler. 7 8 Added possibility to enqueue any JSValue within ReadableJSStream. 9 They are stored in a Vector of strongified JSValue. 10 11 Added support for streams that contain data but are asked to close. 12 This is done through m_closeRequested boolean and splitting actual closing of the stream from changeStateToClosed(). 13 14 Chunk size and backpressure mechanism is not yet implemented. 15 Neither is pulling once enqueued data is processed. 16 17 Covered by rebased tests. 18 19 * Modules/streams/ReadableStream.cpp: 20 (WebCore::ReadableStream::changeStateToClosed): Split method with newly added close(). 21 (WebCore::ReadableStream::close): Does the actual closing of stream once stream has no more values. 22 (WebCore::ReadableStream::read): Close the stream when stream is emptied and close is requested. 23 (WebCore::ReadableStream::resolveReadCallback): Added to enable ReadableJSStream to resolve read callbacks immediatly at enqueue time. 24 * Modules/streams/ReadableStream.h: 25 (WebCore::ReadableStream::isErrored): Getter added for the custom binding code. 26 (WebCore::ReadableStream::isCloseRequested): Ditto. 27 * bindings/js/JSReadableStreamControllerCustom.cpp: 28 (WebCore::JSReadableStreamController::enqueue): binding code for enqueue, taking care of raising exception if readable stream cannot enqueue. 29 * bindings/js/ReadableJSStream.cpp: 30 (WebCore::ReadableJSStream::hasValue): 31 (WebCore::ReadableJSStream::read): 32 (WebCore::ReadableJSStream::enqueue): 33 * bindings/js/ReadableJSStream.h: 34 1 35 2015-06-04 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 36 -
trunk/Source/WebCore/Modules/streams/ReadableStream.cpp
r185196 r185197 68 68 void ReadableStream::changeStateToClosed() 69 69 { 70 if (m_state != State::Readable) 70 ASSERT(!m_closeRequested); 71 ASSERT(m_state != State::Errored); 72 73 m_closeRequested = true; 74 75 if (m_state != State::Readable || hasValue()) 71 76 return; 77 close(); 78 } 79 80 void ReadableStream::close() 81 { 72 82 m_state = State::Closed; 73 83 … … 145 155 if (hasValue()) { 146 156 successCallback(read()); 157 if (m_closeRequested && !hasValue()) 158 close(); 147 159 return; 148 160 } 149 161 m_readRequests.append({ WTF::move(successCallback), WTF::move(endCallback), WTF::move(failureCallback) }); 150 162 // FIXME: We should try to pull. 163 } 164 165 bool ReadableStream::resolveReadCallback(JSC::JSValue value) 166 { 167 if (m_readRequests.isEmpty()) 168 return false; 169 170 m_readRequests.first().successCallback(value); 171 m_readRequests.remove(0); 172 return true; 151 173 } 152 174 -
trunk/Source/WebCore/Modules/streams/ReadableStream.h
r185196 r185197 67 67 bool isLocked() const { return !!m_reader; } 68 68 69 bool isErrored() const { return m_state == State::Errored; } 69 70 bool isReadable() const { return m_state == State::Readable; } 71 bool isCloseRequested() const { return m_closeRequested; } 70 72 71 73 virtual JSC::JSValue error() = 0; … … 87 89 explicit ReadableStream(ScriptExecutionContext&); 88 90 91 bool resolveReadCallback(JSC::JSValue); 92 89 93 private: 90 94 // ActiveDOMObject API. … … 93 97 94 98 void clearCallbacks(); 99 void close(); 95 100 96 101 virtual bool hasValue() const = 0; … … 110 115 Vector<ReadCallbacks> m_readRequests; 111 116 117 bool m_closeRequested { false }; 112 118 State m_state { State::Readable }; 113 119 }; -
trunk/Source/WebCore/bindings/js/JSReadableStreamControllerCustom.cpp
r185039 r185197 34 34 35 35 #include "JSDOMBinding.h" 36 #include "NotImplemented.h"37 36 #include "ReadableJSStream.h" 38 37 #include <runtime/Error.h> … … 52 51 } 53 52 54 JSValue JSReadableStreamController::enqueue(ExecState* )53 JSValue JSReadableStreamController::enqueue(ExecState* exec) 55 54 { 56 notImplemented(); 57 return jsBoolean(false); 55 ReadableJSStream& stream = impl().stream(); 56 if (stream.isErrored()) 57 return exec->vm().throwException(exec, stream.error()); 58 if (stream.isCloseRequested()) 59 return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Calling enqueue on a stream which is closing"))); 60 stream.enqueue(*exec); 61 return jsUndefined(); 58 62 } 59 63 -
trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp
r185196 r185197 136 136 bool ReadableJSStream::hasValue() const 137 137 { 138 notImplemented(); 139 return false; 138 return m_chunkQueue.size(); 140 139 } 141 140 142 141 JSValue ReadableJSStream::read() 143 142 { 144 notImplemented(); 145 return jsUndefined(); 143 ASSERT(hasValue()); 144 145 return m_chunkQueue.takeFirst().get(); 146 } 147 148 void ReadableJSStream::enqueue(ExecState& exec) 149 { 150 ASSERT(!isCloseRequested()); 151 152 if (!isReadable()) 153 return; 154 155 JSValue chunk = exec.argumentCount() ? exec.argument(0) : jsUndefined(); 156 if (resolveReadCallback(chunk)) 157 return; 158 159 m_chunkQueue.append(JSC::Strong<JSC::Unknown>(exec.vm(), chunk)); 160 // FIXME: Compute chunk size. 161 // FIXME: Add pulling of data here and also when data is passed to resolve callback. 146 162 } 147 163 -
trunk/Source/WebCore/bindings/js/ReadableJSStream.h
r185196 r185197 38 38 #include <runtime/JSCJSValue.h> 39 39 #include <runtime/PrivateName.h> 40 #include <wtf/Deque.h> 40 41 #include <wtf/Ref.h> 41 42 … … 54 55 JSC::JSValue error() { return m_error.get(); } 55 56 57 void enqueue(JSC::ExecState&); 58 56 59 private: 57 60 ReadableJSStream(ScriptExecutionContext&, JSC::ExecState&, JSC::JSObject*); … … 67 70 JSC::Strong<JSC::Unknown> m_error; 68 71 JSC::Strong<JSC::JSObject> m_source; 72 Deque<JSC::Strong<JSC::Unknown>> m_chunkQueue; 69 73 }; 70 74
Note: See TracChangeset
for help on using the changeset viewer.