WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
150895
[Streams API] Shield implementation from user mangling Promise.reject and resolve methods
https://bugs.webkit.org/show_bug.cgi?id=150895
Summary
[Streams API] Shield implementation from user mangling Promise.reject and res...
Xabier Rodríguez Calvar
Reported
2015-11-04 10:17:09 PST
[Streams API] Shield implementation from user mangling Promise.reject and resolve methods
Attachments
Patch
(21.17 KB, patch)
2015-11-04 10:28 PST
,
Xabier Rodríguez Calvar
no flags
Details
Formatted Diff
Diff
Patch
(21.29 KB, patch)
2015-11-05 02:49 PST
,
Xabier Rodríguez Calvar
no flags
Details
Formatted Diff
Diff
Patch
(20.73 KB, patch)
2015-11-05 04:16 PST
,
Xabier Rodríguez Calvar
no flags
Details
Formatted Diff
Diff
Patch
(20.21 KB, patch)
2015-11-05 04:53 PST
,
Xabier Rodríguez Calvar
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Xabier Rodríguez Calvar
Comment 1
2015-11-04 10:28:34 PST
Created
attachment 264797
[details]
Patch The idea of this patch is shielding the Streams implementation from any changes that the user can do to the Promise constructor or prototype. This case tackles the touching the constructor resolve and reject functions to create already vended promises. Given that there's other (known) way of getting the original implementation of those functions (prior to the user changing them), we keep them in an internal slot for later usage and in the code we avoid using @Promise.resolve and reject to use @Promise.@resolve and @reject.
youenn fablet
Comment 2
2015-11-04 13:40:12 PST
Comment on
attachment 264797
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=264797&action=review
> Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp:87 > + putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().rejectPrivateName(), JSFunction::createBuiltinFunction(vm, promiseConstructorRejectCodeGenerator(vm), globalObject, vm.propertyNames->builtinNames().rejectPrivateName().string()), DontEnum | DontDelete | ReadOnly);
No need for function name. Also, I think you can use JSC_BUILTIN_FUNCTION macro instead. These private slots are probably not needed for InternalPromise. We could move this init code to another function, but I think this is ok as is.
> LayoutTests/streams/streams-promises.html:10 > Promise = function() { throw new Error("nasty things"); };
I would prefer having PromiseBackup inside the test block. Promise can be set again at the end of the test using try/finally. Also, instead of "throw new Error(...)", assert_unreached("...") can be used.
> LayoutTests/streams/streams-promises.html:13 > const ws = new WritableStream(); // Does not throw.
Maybe remove const rs/const ws and the comments as well.
> LayoutTests/streams/streams-promises.html:19 > + Promise.resolve = function() { throw new Error("nasty resolve things"); };
Ditto for assert_unreached.
> LayoutTests/streams/streams-promises.html:20 > + Promise.reject = function() { throw new Error("nasty reject things"); };
Promise.reject is probably not tested here. It would be good to add a specific test for it.
> LayoutTests/streams/streams-promises.html:23 > + const ws = new WritableStream(); // Does not throw.
Ditto for rs/ws and comments. We can also set again Promise.resolve and Promise.reject properly at the end of this test.
Xabier Rodríguez Calvar
Comment 3
2015-11-05 02:49:59 PST
Created
attachment 264847
[details]
Patch Honored Youenn's comments.
Xabier Rodríguez Calvar
Comment 4
2015-11-05 04:16:42 PST
Created
attachment 264850
[details]
Patch As spoken with Youenn on IRC, I fixed the third test, fixed the comments, improved the error messages and save/restore only the things that we mangle during the given test. I also made that the internal slots are not added to @InternalPromise as suggested for the previous and and improved the test names.
youenn fablet
Comment 5
2015-11-05 04:38:28 PST
Comment on
attachment 264850
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=264850&action=review
> Source/JavaScriptCore/runtime/JSGlobalObject.cpp:411 > + promiseConstructor->addOwnInternalSlots(vm, this);
Can you move the call to addOwnInternalSlots within JSPromiseConstructor::create?
> Source/JavaScriptCore/runtime/JSPromiseConstructor.h:44 > + void addOwnInternalSlots(VM&, JSGlobalObject*);
Can it be private?
Xabier Rodríguez Calvar
Comment 6
2015-11-05 04:53:04 PST
Created
attachment 264851
[details]
Patch Made addOwnInternalSlots private.
WebKit Commit Bot
Comment 7
2015-11-05 06:02:08 PST
Comment on
attachment 264851
[details]
Patch Clearing flags on attachment: 264851 Committed
r192057
: <
http://trac.webkit.org/changeset/192057
>
WebKit Commit Bot
Comment 8
2015-11-05 06:02:13 PST
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.
Top of Page
Format For Printing
XML
Clone This Bug