Closed Bug 1607939 Opened 4 years ago Closed 4 years ago

Functions that create resolved/rejected promises are byzantine

Categories

(Core :: JavaScript: Standard Library, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: Waldo, Assigned: Waldo)

Details

Attachments

(2 files)

The code underneath PromiseObject::unforgeable{Resolve,Reject} is byzantine -- you gotta get the original Promise constructor and feed that through a mess of APIs that do a whole bunch of work. But really, there's no reason this can't be much more than a moral equivalent of StringObject::create, if we boil away a bunch of make-work. And we should.

This also has the benefit of giving PromiseObject::unforgeableReject a better return type, and we can split out a PromiseObject::unforgeableResolveWithNonPromise that knowledgeable users can use to avoid a bunch of work. (PromiseObject::unforgeableResolve, sadly, still has to do work for the case where the provided value is a promise. Maybe in followup work we could just have that function detect, then call, either the non-promise version or a new PromiseObject::unforgeableResolvePromise that only handles the case of being passed in a promise.)

Assignee: nobody → jwalden
Status: NEW → ASSIGNED
Attachment #9119578 - Attachment description: Bug 1607939 - Inline a whole bunch of flab from the wholly-generic unforgeable{Resolve,Reject} functions and provide forms of them that (where possible, or given restricted arguments) return PromiseObject*. r=arai → Bug 1607939 - Inline a whole bunch of flab from the wholly-generic unforgeable{Resolve,Reject} functions and provide forms of them that return PromiseObject* (perhaps if arguments are sufficiently restrictive). r=arai
Pushed by jwalden@mit.edu:
https://hg.mozilla.org/integration/autoland/rev/674372340cf5
Make |ReadableStreamAddReadOrReadIntoRequest| return |PromiseObject*| for more specificity.  r=arai
https://hg.mozilla.org/integration/autoland/rev/9f267cbec223
Inline a whole bunch of flab from the wholly-generic unforgeable{Resolve,Reject} functions and provide forms of them that return PromiseObject* (perhaps if arguments are sufficiently restrictive).  r=arai
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: