Changeset 185406 in webkit
- Timestamp:
- Jun 10, 2015 1:09:02 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r185402 r185406 1 2015-06-10 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Streams API] Implement pulling of a source by a ReadableStream 4 https://bugs.webkit.org/show_bug.cgi?id=145262 5 6 Reviewed by Darin Adler 7 8 Rebased expectations, removed some "timeout: 50" parameters. 9 Removed a test from streams/reference-implementation/readable-stream.html that cannot pass 10 until promises returned to start and pull JS callbacks are handled. 11 Fixed bug in streams-utils.js (was using the old API replaced by controller). 12 13 * streams/reference-implementation/bad-underlying-sources-expected.txt: 14 * streams/reference-implementation/bad-underlying-sources.html: 15 * streams/reference-implementation/readable-stream-expected.txt: 16 * streams/reference-implementation/readable-stream.html: 17 * streams/reference-implementation/resources/streams-utils.js: 18 (.stream.new.ReadableStream.): 19 (.stream.new.ReadableStream): 20 (sequentialReadableStream): 21 1 22 2015-06-09 Daegyu Lee <daegyu.lee@navercorp.com> 2 23 -
trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources-expected.txt
r185356 r185406 2 2 PASS Underlying source start: throwing getter 3 3 PASS Underlying source start: throwing method 4 TIMEOUT Underlying source: throwing pull getter (initial pull) Test timed out 5 TIMEOUT Underlying source: throwing pull method (initial pull) Test timed out 6 TIMEOUT Underlying source: throwing pull getter (second pull) Test timed out 7 TIMEOUT Underlying source: throwing pull method (second pull) Test timed out 4 PASS Underlying source: throwing pull getter (initial pull) 5 PASS Underlying source: throwing pull method (initial pull) 6 PASS Underlying source: throwing pull getter (second pull) 7 PASS Underlying source: throwing pull method (second pull) 8 8 FAIL Underlying source: throwing cancel getter cancel is not implemented 9 9 FAIL Underlying source: throwing cancel method cancel is not implemented -
trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources.html
r185114 r185406 28 28 }, 'Underlying source start: throwing method'); 29 29 30 var test1 = async_test('Underlying source: throwing pull getter (initial pull)' , { timeout: 50 });30 var test1 = async_test('Underlying source: throwing pull getter (initial pull)'); 31 31 test1.step(function() { 32 32 var theError = new Error('a unique string'); … … 45 45 }); 46 46 47 var test2 = async_test('Underlying source: throwing pull method (initial pull)' , { timeout: 50 });47 var test2 = async_test('Underlying source: throwing pull method (initial pull)'); 48 48 test2.step(function() { 49 49 var theError = new Error('a unique string'); … … 62 62 }); 63 63 64 var test3 = async_test('Underlying source: throwing pull getter (second pull)' , { timeout: 50 });64 var test3 = async_test('Underlying source: throwing pull getter (second pull)'); 65 65 test3.step(function() { 66 66 var theError = new Error('a unique string'); … … 90 90 }); 91 91 92 var test4 = async_test('Underlying source: throwing pull method (second pull)' , { timeout: 50 });92 var test4 = async_test('Underlying source: throwing pull method (second pull)'); 93 93 test4.step(function() { 94 94 var theError = new Error('a unique string'); -
trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt
r185356 r185406 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 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 013 FAIL ReadableStream: should not call pull until the previous pull call's promise fulfills assert_equals: after the promise returned by pull is fulfilled, pull should be called a second time expected 2 but got 1 14 14 PASS ReadableStream: should not call pull after start if the stream is now closed 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 016 TIMEOUT ReadableStream pull should be able to close a stream. Test timed out 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 1 16 PASS ReadableStream pull should be able to close a stream. 17 17 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 18 PASS ReadableStream: enqueue should throw when the stream is closed … … 22 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 TIMEOUT ReadableStream integration test: adapting a sync pull source Test timed out 25 TIMEOUT ReadableStream integration test: adapting an async pull source Test timed out 24 PASS ReadableStream integration test: adapting a sync pull source 26 25 -
trunk/LayoutTests/streams/reference-implementation/readable-stream.html
r185197 r185406 517 517 }); 518 518 519 var test15 = async_test('ReadableStream pull should be able to close a stream.' , { timeout: 50 });519 var test15 = async_test('ReadableStream pull should be able to close a stream.'); 520 520 test15.step(function() { 521 521 var pullCalled = false; … … 703 703 }); 704 704 705 var test19 = async_test('ReadableStream integration test: adapting a sync pull source' , { timeout: 50 });705 var test19 = async_test('ReadableStream integration test: adapting a sync pull source'); 706 706 test19.step(function() { 707 707 var rs = sequentialReadableStream(10); … … 714 714 })); 715 715 }); 716 716 /* 717 717 var test20 = async_test('ReadableStream integration test: adapting an async pull source', { timeout: 50 }); 718 718 test20.step(function() { … … 726 726 })); 727 727 }); 728 */ 728 729 </script> -
trunk/LayoutTests/streams/reference-implementation/resources/streams-utils.js
r182629 r185406 151 151 if (err) { 152 152 reject(err); 153 return; 153 154 } 154 155 resolve(); … … 157 158 }, 158 159 159 pull: function( enqueue, finish, error) {160 pull: function(c) { 160 161 sequentialSource.read(function(err, done, chunk) { 161 162 if (err) { 162 error(err);163 c.error(err); 163 164 } else if (done) { 164 165 sequentialSource.close(function(err) { 165 166 if (err) { 166 error(err); 167 c.error(err); 168 return; 167 169 } 168 finish();170 c.close(); 169 171 }); 170 172 } else { 171 enqueue(chunk);173 c.enqueue(chunk); 172 174 } 173 175 }); -
trunk/Source/WebCore/ChangeLog
r185404 r185406 1 2015-06-10 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Streams API] Implement pulling of a source by a ReadableStream 4 https://bugs.webkit.org/show_bug.cgi?id=145262 5 6 Reviewed by Darin Adler 7 8 Introduced abstract ReadableStream::doPull() which is overriden in ReadableJSStream. 9 Added support to call the "pull" JS callback in ReadableJSStream::doPull(). 10 Added calls to pull as requested by the spec (when resolving a read callback, at start time...). 11 12 Fixed issue in ReadableStreamReader::read() (use of successCallback(JSValue()) in lieu of endCallback()) 13 14 Covered by rebased tests. 15 16 * Modules/streams/ReadableStream.cpp: 17 (WebCore::ReadableStream::start): calling pull() once start. 18 (WebCore::ReadableStream::pull): calling doPull() if readableStream states requires to. 19 (WebCore::ReadableStream::read): calling pull() after resolving a read callback. 20 * Modules/streams/ReadableStream.h: 21 * Modules/streams/ReadableStreamReader.cpp: 22 (WebCore::ReadableStreamReader::read): fixed JSValue() bug. 23 * bindings/js/ReadableJSStream.cpp: 24 (WebCore::ReadableJSStream::doPull): calling of JS callback. 25 (WebCore::ReadableJSStream::storeException): catches exception and store them. 26 (WebCore::ReadableJSStream::storeError): refactoring for checkForException. 27 (WebCore::ReadableJSStream::enqueue): 28 * bindings/js/ReadableJSStream.h: 29 1 30 2015-06-09 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 31 -
trunk/Source/WebCore/Modules/streams/ReadableStream.cpp
r185260 r185406 113 113 } 114 114 115 void ReadableStream::start() 116 { 117 m_isStarted = true; 118 pull(); 119 } 120 121 void ReadableStream::pull() 122 { 123 if (!m_isStarted || m_state == State::Closed || m_state == State::Errored || m_closeRequested) 124 return; 125 // FIXME: Implement queueSize check. 126 if (m_readRequests.isEmpty() && hasValue()) 127 return; 128 // FIXME: Implement async pull check. 129 doPull(); 130 } 131 115 132 ReadableStreamReader& ReadableStream::getReader() 116 133 { … … 155 172 if (hasValue()) { 156 173 successCallback(read()); 157 if (m_closeRequested && !hasValue()) 174 if (!m_closeRequested) 175 pull(); 176 else if (!hasValue()) 158 177 close(); 159 178 return; 160 179 } 161 180 m_readRequests.append({ WTF::move(successCallback), WTF::move(endCallback), WTF::move(failureCallback) }); 162 // FIXME: We should try to pull.181 pull(); 163 182 } 164 183 … … 172 191 } 173 192 174 void ReadableStream::start()175 {176 notImplemented();177 }178 179 193 const char* ReadableStream::activeDOMObjectName() const 180 194 { -
trunk/Source/WebCore/Modules/streams/ReadableStream.h
r185260 r185406 90 90 91 91 bool resolveReadCallback(JSC::JSValue); 92 void pull(); 92 93 93 94 private: … … 101 102 virtual bool hasValue() const = 0; 102 103 virtual JSC::JSValue read() = 0; 104 virtual void doPull() = 0; 103 105 104 106 std::unique_ptr<ReadableStreamReader> m_reader; … … 115 117 Deque<ReadCallbacks> m_readRequests; 116 118 119 bool m_isStarted { false }; 117 120 bool m_closeRequested { false }; 118 121 State m_state { State::Readable }; -
trunk/Source/WebCore/Modules/streams/ReadableStreamReader.cpp
r185114 r185406 49 49 { 50 50 if (m_stream.isReadable() && m_stream.reader() != this) { 51 successCallback(JSC::JSValue());51 endCallback(); 52 52 return; 53 53 } -
trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp
r185356 r185406 40 40 #include "ScriptExecutionContext.h" 41 41 #include <runtime/Error.h> 42 #include <runtime/Exception.h> 42 43 #include <runtime/JSCJSValueInlines.h> 43 44 #include <runtime/JSString.h> … … 101 102 // FIXME: Implement handling promise as result of calling start function. 102 103 startReadableStreamAsync(*this); 104 } 105 106 void ReadableJSStream::doPull() 107 { 108 ExecState& state = *globalObject()->globalExec(); 109 JSLockHolder lock(&state); 110 111 invoke(state, "pull"); 112 113 if (state.hadException()) { 114 storeException(state); 115 ASSERT(!state.hadException()); 116 return; 117 } 118 // FIXME: Implement handling promise as result of calling pull function. 103 119 } 104 120 … … 137 153 } 138 154 155 void ReadableJSStream::storeException(JSC::ExecState& state) 156 { 157 JSValue exception = state.exception()->value(); 158 state.clearException(); 159 storeError(state, exception); 160 } 161 139 162 void ReadableJSStream::storeError(JSC::ExecState& exec) 140 163 { 164 storeError(exec, exec.argumentCount() ? exec.argument(0) : createError(&exec, ASCIILiteral("Error function called."))); 165 } 166 167 void ReadableJSStream::storeError(JSC::ExecState& exec, JSValue error) 168 { 141 169 if (m_error) 142 170 return; 143 JSValue error = exec.argumentCount() ? exec.argument(0) : createError(&exec, ASCIILiteral("Error function called."));144 171 m_error.set(exec.vm(), error); 145 172 … … 167 194 168 195 JSValue chunk = exec.argumentCount() ? exec.argument(0) : jsUndefined(); 169 if (resolveReadCallback(chunk)) 170 return; 196 if (resolveReadCallback(chunk)) { 197 pull(); 198 return; 199 } 171 200 172 201 m_chunkQueue.append(JSC::Strong<JSC::Unknown>(exec.vm(), chunk)); 173 202 // FIXME: Compute chunk size. 174 // FIXME: Add pulling of data here and also when data is passed to resolve callback.203 pull(); 175 204 } 176 205 -
trunk/Source/WebCore/bindings/js/ReadableJSStream.h
r185356 r185406 63 63 64 64 JSC::JSValue invoke(JSC::ExecState&, const char*); 65 void storeException(JSC::ExecState&); 66 void storeError(JSC::ExecState&, JSC::JSValue); 65 67 66 68 virtual bool hasValue() const override; 67 69 virtual JSC::JSValue read() override; 70 virtual void doPull() override; 68 71 69 72 JSDOMGlobalObject* globalObject();
Note: See TracChangeset
for help on using the changeset viewer.