Bug 142435 - [Streams API] Closing a ReadableStream should resolve the ready and closed promises
Summary: [Streams API] Closing a ReadableStream should resolve the ready and closed pr...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords:
Depends on: 141160
Blocks: 141162
  Show dependency treegraph
 
Reported: 2015-03-07 01:15 PST by youenn fablet
Modified: 2015-05-22 04:48 PDT (History)
3 users (show)

See Also:


Attachments
Patch (8.95 KB, patch)
2015-03-07 01:22 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Switching to postTask (12.13 KB, patch)
2015-03-09 10:41 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Cleaning things (11.82 KB, patch)
2015-03-11 20:30 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2015-03-07 01:15:42 PST
As per the spec, When close() is called, the stream should be put in closed state.
At the same time, the ready and closed promises should be resolved.
Comment 1 youenn fablet 2015-03-07 01:22:52 PST
Created attachment 248149 [details]
Patch
Comment 2 Benjamin Poulain 2015-03-08 21:05:31 PDT
Comment on attachment 248149 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=248149&action=review

Please poke me on IRC when this is up for review.

> Source/WebCore/Modules/streams/ReadableStream.cpp:88
> +    callOnMainThread(std::bind(WTF::move(m_closedSuccessCallback)));

I am quite confused by this callOnMainThread. Are stream multithread?

If you intended to resolve the promise asynchronously, it should be scheduled on the next Microtask, I don't think callOnMainThread() does that.

Can you explain this?

> Source/WebCore/Modules/streams/ReadableStream.cpp:96
> +    if (m_state == State::Closed)
> +        resolveClosedCallback();

I can't get used to it :)

> Source/WebCore/Modules/streams/ReadableStream.cpp:114
> +    callOnMainThread(std::bind(WTF::move(m_readyCallback)));

Same question for callOnMainThread()

> Source/WebCore/bindings/js/JSDOMPromise.h:101
> +inline void DeferredWrapper::resolve<JSC::JSValue>(const JSC::JSValue& value)

I would add a resolve() without argument.

> LayoutTests/streams/readablestream-start.html:52
> +test1 = async_test('ReadableStream close should fulfill ready and closed promises');

I would like tests for every aspect of the patch, including:
-Open a stream, close it. Add a callback for "closed" after a timer.
-Open a stream. Add ready callback in response to start.
-Open a stream. Add closed callback in response to start.
-Verify that neither callback are called synchronously on close.
-etc.

This is a new feature, we need shitload of tests.
The difference between a great feature and a shitty feature is flawless execution and great performance. Having overkill test coverage will give you the flawless execution.
Comment 3 youenn fablet 2015-03-09 10:41:26 PDT
Created attachment 248254 [details]
Switching to postTask
Comment 4 youenn fablet 2015-03-09 10:45:32 PDT
Comment on attachment 248149 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=248149&action=review

>> Source/WebCore/Modules/streams/ReadableStream.cpp:88
>> +    callOnMainThread(std::bind(WTF::move(m_closedSuccessCallback)));
> 
> I am quite confused by this callOnMainThread. Are stream multithread?
> 
> If you intended to resolve the promise asynchronously, it should be scheduled on the next Microtask, I don't think callOnMainThread() does that.
> 
> Can you explain this?

Right, switching to ScriptExecutionContext::postTask is more appropriate.

>> Source/WebCore/bindings/js/JSDOMPromise.h:101
>> +inline void DeferredWrapper::resolve<JSC::JSValue>(const JSC::JSValue& value)
> 
> I would add a resolve() without argument.

We will add later on a reject(JSValue) which is actually needed as an error may be anything.
This function mirrors that future one.

> LayoutTests/streams/readablestream-start.html:53
> +test1.step(function()

Agreed.
I added some more tests and will continue adding more.
Comment 5 youenn fablet 2015-03-11 20:30:14 PDT
Created attachment 248482 [details]
Cleaning things
Comment 6 youenn fablet 2015-05-22 04:48:31 PDT
Wontfix as spec changed and no longer has a ready promise.