Closed Bug 973239 Opened 11 years ago Closed 11 years ago

Promise should call executor and handlers with "undefined" as thisArg

Categories

(Toolkit :: Async Tooling, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla31

People

(Reporter: bbenvie, Assigned: Paolo)

References

Details

Attachments

(1 file)

When implementing the Promise constructor, I followed our DOM Promise implementation's lead on setting the receiver in the executor to the newly created promise. Upon reviewing the spec I realized that this is incorrect and it should be set to `undefined`.
Attached patch The patch (deleted) — Splinter Review
This fixes both the constructor and the "then" handlers.
Assignee: nobody → paolo.mozmail
Status: NEW → ASSIGNED
Attachment #8394706 - Flags: review?(bbenvie)
Summary: Promise constructor should call the executor with `undefined` as thisArg → Promise should call executor and handlers with "undefined" as thisArg
Blocks: 887923
Comment on attachment 8394706 [details] [diff] [review] The patch Review of attachment 8394706 [details] [diff] [review]: ----------------------------------------------------------------- LGTM except for one thing. ::: toolkit/modules/Promise-backend.js @@ +703,5 @@ > // to determine the state of the next promise, that will be resolved with > // the returned value, that can also be another promise. > if (nextStatus == STATUS_RESOLVED) { > if (typeof(this.onResolve) == "function") { > + nextValue = this.onResolve.call(undefined, nextValue); Either these two should use Function.prototype.call.call or the constructor's call of aExecutor above should just use .call as it is used here.
Attachment #8394706 - Flags: review?(bbenvie) → review+
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: