Changeset 183803 in webkit
- Timestamp:
- May 5, 2015 6:23:52 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r183802 r183803 1 2015-05-05 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 streams/readable-stream.html is very flaky 4 https://bugs.webkit.org/show_bug.cgi?id=144455 5 6 Reviewed by Darin Adler. 7 8 Moved flaky test to streams/readable-stream-gc.html. 9 Updated flaky test to check that the controller methods work well even if readable stream reference is lost by script. 10 11 * streams/readable-stream-expected.txt: 12 * streams/readable-stream-gc-expected.txt: Added. 13 * streams/readable-stream-gc.html: Added. 14 * streams/readable-stream.html: 15 1 16 2015-05-05 Marcos Chavarría Teijeiro <chavarria1991@gmail.com> 2 17 -
trunk/LayoutTests/streams/readable-stream-expected.txt
r183107 r183803 3 3 PASS ReadableStream start should be called with the proper parameters 4 4 PASS ReadableStream should be able to call start method within prototype chain of its source 5 PASS A readable stream controller methods should throw if its readablestream is collected6 5 -
trunk/LayoutTests/streams/readable-stream.html
r183107 r183803 2 2 <script src='../resources/testharness.js'></script> 3 3 <script src='../resources/testharnessreport.js'></script> 4 <script src='../resources/gc.js'></script>5 4 <script> 6 5 test(function() { … … 59 58 }, 'ReadableStream should be able to call start method within prototype chain of its source'); 60 59 61 t1 = async_test('A readable stream controller methods should throw if its readablestream is collected');62 t1.step(function() {63 var controller;64 new ReadableStream({65 start: function(c) {66 controller = c;67 }68 });69 setTimeout(t1.step_func(function() {70 window.gc();71 assert_throws(new TypeError(), function() { controller.close(); });72 assert_throws(new TypeError(), function() { controller.error(); });73 assert_throws(new TypeError(), function() { controller.enqueue(); });74 t1.done();75 }), 10);76 });77 60 </script> -
trunk/Source/WebCore/ChangeLog
r183799 r183803 1 2015-05-05 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 streams/readable-stream.html is very flaky 4 https://bugs.webkit.org/show_bug.cgi?id=144455 5 6 Reviewed by Darin Adler. 7 8 Changed the link between readadable stream and controller. 9 Controller ref()/deref() now increments/decrements its stream ref counter. 10 This ensures that even if JS scripts do not keep track of the readable stream, 11 the readable stream will not be disposed as long as the JS script has access to its controller. 12 13 Test: streams/readable-stream-gc.html 14 15 * Modules/streams/ReadableStreamController.h: 16 (WebCore::ReadableStreamController::ReadableStreamController): 17 (WebCore::ReadableStreamController::ref): 18 (WebCore::ReadableStreamController::deref): 19 (WebCore::ReadableStreamController::create): Deleted. 20 (WebCore::ReadableStreamController::stream): Deleted. 21 * bindings/js/JSReadableStreamControllerCustom.cpp: 22 (WebCore::JSReadableStreamController::close): 23 (WebCore::JSReadableStreamController::enqueue): 24 (WebCore::JSReadableStreamController::error): 25 * bindings/js/ReadableStreamJSSource.cpp: 26 (WebCore::ReadableStreamJSSource::~ReadableStreamJSSource): 27 (WebCore::ReadableStreamJSSource::start): 28 (WebCore::ReadableJSStream::jsController): 29 * bindings/js/ReadableStreamJSSource.h: 30 1 31 2015-05-05 Myles C. Maxfield <mmaxfield@apple.com> 2 32 -
trunk/Source/WebCore/Modules/streams/ReadableStreamController.h
r183107 r183803 33 33 #if ENABLE(STREAMS_API) 34 34 35 #include <wtf/Ref.h> 36 #include <wtf/RefCounted.h> 35 #include "ReadableStreamJSSource.h" 37 36 38 37 namespace WebCore { 39 40 class ReadableJSStream;41 38 42 39 // This class is only used for JS source readable streams to allow enqueuing, closing or erroring a readable stream. 43 40 // Its definition is at https://streams.spec.whatwg.org/#rs-controller-class. 44 41 // Note that its constructor is taking a ReadableJSStream as it should only be used for JS sources. 45 class ReadableStreamController : public RefCounted<ReadableStreamController>{42 class ReadableStreamController { 46 43 public: 47 static Ref<ReadableStreamController> create(ReadableJSStream& stream) 48 { 49 auto controller = adoptRef(*new ReadableStreamController(stream)); 50 return controller; 51 } 52 ~ReadableStreamController() { } 44 explicit ReadableStreamController(ReadableJSStream& stream) 45 : m_stream(stream) { } 53 46 54 void resetStream() { m_stream = nullptr; } 55 ReadableJSStream* stream() { return m_stream; } 47 ReadableJSStream& stream() { return m_stream; } 48 49 void ref() { m_stream.ref(); } 50 void deref() { m_stream.deref(); } 56 51 57 52 private: 58 ReadableStreamController(ReadableJSStream& stream) { m_stream = &stream; } 59 60 ReadableJSStream* m_stream; 53 ReadableJSStream& m_stream; 61 54 }; 62 55 -
trunk/Source/WebCore/bindings/js/JSReadableStreamControllerCustom.cpp
r183395 r183803 44 44 JSValue JSReadableStreamController::close(ExecState* exec) 45 45 { 46 ReadableJSStream* stream = impl().stream(); 47 if (!stream) 48 return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Controller has no readablestream"))); 46 ReadableJSStream& stream = impl().stream(); 49 47 // FIXME: Handle the case of draining. 50 if (stream ->internalState() != ReadableStream::State::Readable)48 if (stream.internalState() != ReadableStream::State::Readable) 51 49 return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Calling close on a stream which is not readable"))); 52 stream ->changeStateToClosed();50 stream.changeStateToClosed(); 53 51 return jsUndefined(); 54 52 } 55 53 56 JSValue JSReadableStreamController::enqueue(ExecState* exec)54 JSValue JSReadableStreamController::enqueue(ExecState*) 57 55 { 58 ReadableJSStream* stream = impl().stream();59 if (!stream)60 return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Controller has no readablestream")));61 56 notImplemented(); 62 57 return jsBoolean(false); … … 65 60 JSValue JSReadableStreamController::error(ExecState* exec) 66 61 { 67 ReadableJSStream* stream = impl().stream(); 68 if (!stream) 69 return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Controller has no readablestream"))); 70 if (stream->internalState() != ReadableStream::State::Readable) 62 ReadableJSStream& stream = impl().stream(); 63 if (stream.internalState() != ReadableStream::State::Readable) 71 64 return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Calling error on a stream which is not readable"))); 72 65 notImplemented(); -
trunk/Source/WebCore/bindings/js/ReadableStreamJSSource.cpp
r183744 r183803 36 36 #include "JSDOMPromise.h" 37 37 #include "JSReadableStream.h" 38 #include "JSReadableStreamController.h" 38 39 #include "NotImplemented.h" 39 40 #include "ScriptExecutionContext.h" … … 91 92 ReadableStreamJSSource::~ReadableStreamJSSource() 92 93 { 93 if (m_controller)94 m_controller.get()->impl().resetStream();95 94 } 96 95 … … 112 111 JSLockHolder lock(&exec); 113 112 114 Ref<ReadableStreamController> controller = ReadableStreamController::create(readableStream);115 m_controller.set(exec.vm(), jsDynamicCast<JSReadableStreamController*>(toJS(&exec, globalObject(), controller)));116 117 113 JSValue startFunction = getPropertyFromObject(&exec, m_source.get(), "start"); 118 114 if (!startFunction.isFunction()) { … … 125 121 126 122 MarkedArgumentBuffer arguments; 127 arguments.append( m_controller.get());123 arguments.append(readableStream.jsController(exec, globalObject())); 128 124 129 125 JSValue exception; … … 162 158 } 163 159 160 JSValue ReadableJSStream::jsController(ExecState& exec, JSDOMGlobalObject* globalObject) 161 { 162 if (!m_controller) 163 m_controller = std::make_unique<ReadableStreamController>(*this); 164 return toJS(&exec, globalObject, m_controller.get()); 165 } 166 164 167 Ref<ReadableJSStream::Reader> ReadableJSStream::Reader::create(ReadableJSStream& stream) 165 168 { -
trunk/Source/WebCore/bindings/js/ReadableStreamJSSource.h
r183744 r183803 33 33 #if ENABLE(STREAMS_API) 34 34 35 #include "JSReadableStreamController.h"36 35 #include "ReadableStream.h" 37 36 #include "ReadableStreamReader.h" … … 44 43 45 44 namespace WebCore { 45 46 class JSDOMGlobalObject; 47 class ReadableJSStream; 48 class ReadableStreamController; 46 49 47 50 class ReadableStreamJSSource: public ReadableStreamSource { … … 58 61 // Object passed to constructor. 59 62 JSC::Strong<JSC::JSObject> m_source; 60 61 JSC::Strong<JSReadableStreamController> m_controller;62 63 }; 63 64 … … 66 67 static Ref<ReadableJSStream> create(JSC::ExecState&, ScriptExecutionContext&); 67 68 virtual Ref<ReadableStreamReader> createReader() override; 69 68 70 ReadableStreamJSSource& jsSource(); 71 JSC::JSValue jsController(JSC::ExecState&, JSDOMGlobalObject*); 69 72 70 73 private: … … 77 80 explicit Reader(ReadableJSStream&); 78 81 }; 82 83 std::unique_ptr<ReadableStreamController> m_controller; 79 84 }; 80 85
Note: See TracChangeset
for help on using the changeset viewer.