Bug 143363

Summary: [Streams API] ReadableStream constructor start function should be able to close the stream
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebKit Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, calvaris, cgarcia, commit-queue
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 141160, 143714, 143774    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing
none
Patch none

youenn fablet
Reported 2015-04-03 00:19:52 PDT
Support for the close function passed as parameter to "start" and "pull" source functions should be implemented. THis should end up putting the stream and reader in closed state and fulfilling the reader closed promise.
Attachments
Patch (14.85 KB, patch)
2015-04-03 04:52 PDT, youenn fablet
no flags
Patch (16.85 KB, patch)
2015-04-09 03:36 PDT, youenn fablet
no flags
Patch for landing (16.21 KB, patch)
2015-04-14 05:58 PDT, youenn fablet
no flags
Patch (15.37 KB, patch)
2015-04-23 02:00 PDT, Xabier Rodríguez Calvar
no flags
youenn fablet
Comment 1 2015-04-03 04:52:58 PDT
youenn fablet
Comment 2 2015-04-09 03:36:15 PDT
Benjamin Poulain
Comment 3 2015-04-09 21:51:17 PDT
Comment on attachment 250434 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=250434&action=review Very quick review. Something is fishy. If that's right, please add tests for the controller. Can you please add the type exception on errored? It is not testable yet, but it may be harder to forget if there is already if branch for it. > Source/WebCore/Modules/streams/ReadableStream.cpp:61 > +void ReadableStream::changeStateToClosed() How will you raise the TypeError when closeRequested == true or state == "errored"? > Source/WebCore/bindings/js/ReadableStreamJSSource.cpp:127 > + getReadableJSStream(exec).changeStateToClosed(); > + return JSValue::encode(jsUndefined()); Hum, reading the spec side by side with the code...I don't think that is quite correct. Say I keep the function close in a variable close. I could do: close.call("foobar"); and that would still close the original stream. The specs says to get the internal slot on the this object. If the this object is not a controller: If IsReadableStreamController(this) is false, throw a TypeError exception. Note that this also let you do close.call(otherController) to close the controller of one object with the close function from an other object. If I am reading this correctly, you need to have the internal slot on the controller object, and get it out through the this object.
youenn fablet
Comment 4 2015-04-10 03:31:55 PDT
(In reply to comment #3) > Comment on attachment 250434 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=250434&action=review > > Very quick review. Something is fishy. If that's right, please add tests for > the controller. > > Can you please add the type exception on errored? It is not testable yet, > but it may be harder to forget if there is already if branch for it. > > > Source/WebCore/Modules/streams/ReadableStream.cpp:61 > > +void ReadableStream::changeStateToClosed() > > How will you raise the TypeError when closeRequested == true or state == > "errored"? > > > Source/WebCore/bindings/js/ReadableStreamJSSource.cpp:127 > > + getReadableJSStream(exec).changeStateToClosed(); > > + return JSValue::encode(jsUndefined()); > > Hum, reading the spec side by side with the code...I don't think that is > quite correct. > > Say I keep the function close in a variable close. I could do: > close.call("foobar"); > and that would still close the original stream. > > The specs says to get the internal slot on the this object. If the this > object is not a controller: > If IsReadableStreamController(this) is false, throw a TypeError > exception. > > Note that this also let you do close.call(otherController) to close the > controller of one object with the close function from an other object. > > If I am reading this correctly, you need to have the internal slot on the > controller object, and get it out through the this object. You are reading correctly. I was expecting to first do that patch and then upgrade the controller implementation so that it matches the spec and ensure close is still working. But I can do it the other way as well. For the controller, I am not yet sure whether going the IDL way or making a full custom implementation of it.
Benjamin Poulain
Comment 5 2015-04-12 12:46:33 PDT
(In reply to comment #4) > > If I am reading this correctly, you need to have the internal slot on the > > controller object, and get it out through the this object. > > You are reading correctly. > I was expecting to first do that patch and then upgrade the controller > implementation so that it matches the spec and ensure close is still working. > But I can do it the other way as well. > > For the controller, I am not yet sure whether going the IDL way or making a > full custom implementation of it. A fix in a follow up is okay with me. I r+ed this one. Poke me when you have the follow up.
youenn fablet
Comment 6 2015-04-14 05:58:51 PDT
Created attachment 250702 [details] Patch for landing
WebKit Commit Bot
Comment 7 2015-04-14 06:54:00 PDT
Comment on attachment 250702 [details] Patch for landing Clearing flags on attachment: 250702 Committed r182794: <http://trac.webkit.org/changeset/182794>
WebKit Commit Bot
Comment 8 2015-04-14 06:54:05 PDT
All reviewed patches have been landed. Closing bug.
WebKit Commit Bot
Comment 9 2015-04-14 09:09:19 PDT
Re-opened since this is blocked by bug 143714
Xabier Rodríguez Calvar
Comment 10 2015-04-23 02:00:10 PDT
Created attachment 251421 [details] Patch Rebased against trunk.
WebKit Commit Bot
Comment 11 2015-04-27 06:33:13 PDT
Comment on attachment 251421 [details] Patch Clearing flags on attachment: 251421 Committed r183395: <http://trac.webkit.org/changeset/183395>
WebKit Commit Bot
Comment 12 2015-04-27 06:33:16 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.