Bug 150934 - [Streams API] Shield implementation from mangling then and catch promise methods
Summary: [Streams API] Shield implementation from mangling then and catch promise methods
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Xabier Rodríguez Calvar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-05 08:12 PST by Xabier Rodríguez Calvar
Modified: 2019-09-26 07:42 PDT (History)
6 users (show)

See Also:


Attachments
Patch (13.77 KB, patch)
2015-11-05 08:19 PST, Xabier Rodríguez Calvar
no flags Details | Formatted Diff | Diff
Patch (14.40 KB, patch)
2015-11-06 02:59 PST, Xabier Rodríguez Calvar
no flags Details | Formatted Diff | Diff
Patch (15.13 KB, patch)
2015-11-09 04:14 PST, Xabier Rodríguez Calvar
no flags Details | Formatted Diff | Diff
Patch for landing (14.78 KB, patch)
2015-11-09 07:14 PST, Xabier Rodríguez Calvar
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xabier Rodríguez Calvar 2015-11-05 08:12:12 PST
[Streams API] Shield implementation from mangling then and catch promise methods
Comment 1 Xabier Rodríguez Calvar 2015-11-05 08:19:27 PST
Created attachment 264866 [details]
Patch
Comment 2 Xabier Rodríguez Calvar 2015-11-06 02:59:59 PST
Created attachment 264931 [details]
Patch

Added another test for Object.setPrototypeOf. The test was already working before but it might be interesting to keep it just in case.
Comment 3 youenn fablet 2015-11-06 06:19:02 PST
Comment on attachment 264931 [details]
Patch

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

> LayoutTests/streams/streams-promises.html:60
> +        Object.setPrototypeOf(promise, { then: function() { assert_unreached("streams should not use this promise then method"); } });

I am surprised the test is working before the patch.
Can you try:  Object.setPrototypeOf(promise, { constructor: Promise, then: ... });
It may be the case that Promise.resolve is wrapping the "promise" object because its constructor is not Promise.
Comment 4 youenn fablet 2015-11-09 03:09:24 PST
Comment on attachment 264931 [details]
Patch

Additional comments.

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

> LayoutTests/streams/streams-promises.html:65
> +}, 'Streams implementation is not affected if an attempt to replace promise prototype is made');

The two tests have the same name.
Might be good to precise it here.

> LayoutTests/streams/streams-promises.html:87
> +        rs.tee();

Are we sure closed.catch is actually triggered?
We should probably beef up the test here so that we ensure this in some way.

> LayoutTests/streams/streams-promises.html:101
> +}, 'Streams implementation is not affected if promise then method is replaced');

Same name as above test.
May be good to precise it.
Comment 5 Xabier Rodríguez Calvar 2015-11-09 04:14:51 PST
Created attachment 265040 [details]
Patch
Comment 6 youenn fablet 2015-11-09 05:24:22 PST
Comment on attachment 265040 [details]
Patch

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

r=me

Test names look much better to me. Some small suggestions below.

> LayoutTests/streams/streams-promises-expected.txt:5
> +PASS Streams and promises: attempt to replace Promise prototype 

Not sure we should keep this test

> LayoutTests/streams/streams-promises-expected.txt:6
> +FAIL Streams and promises: replace a single promise prototype undefined is not a function

replace prototype of a Promise object

> LayoutTests/streams/streams-promises-expected.txt:7
> +PASS Streams and promises: replace then prototype method 

replace then function in Promise prototype

> LayoutTests/streams/streams-promises-expected.txt:8
> +PASS Streams and promises: replace catch prototype method 

replace catch function in Promise prototype

> LayoutTests/streams/streams-promises-expected.txt:9
> +PASS Streams and promises: replace then method in a single promise 

replace then function in Promise object
Also, should we have a test for "replace catch function in Promise object"?
Comment 7 Xabier Rodríguez Calvar 2015-11-09 07:14:37 PST
Created attachment 265046 [details]
Patch for landing
Comment 8 Xabier Rodríguez Calvar 2015-11-09 07:19:23 PST
(In reply to comment #6)
> > LayoutTests/streams/streams-promises-expected.txt:5
> > +PASS Streams and promises: attempt to replace Promise prototype 
> 
> Not sure we should keep this test

Me neither, removed.

 
> replace prototype of a Promise object
> 
> replace then function in Promise prototype
> 
> replace catch function in Promise prototype
> 
> replace then function in Promise object

Changed all this names too, used method instead of function to be more OO.

> Also, should we have a test for "replace catch function in Promise object"?

Currently we don't need it because the only place were we use catch is in tee, with a promise that never leaves the code so currently there is not way to test it either.
Comment 9 WebKit Commit Bot 2015-11-09 08:12:36 PST
Comment on attachment 265046 [details]
Patch for landing

Clearing flags on attachment: 265046

Committed r192157: <http://trac.webkit.org/changeset/192157>
Comment 10 WebKit Commit Bot 2015-11-09 08:12:41 PST
All reviewed patches have been landed.  Closing bug.