Convert remaining Promise.defer() uses to PromiseUtils.defer() or to an inline helper

RESOLVED FIXED in Firefox 56

Status

()

P1
normal
RESOLVED FIXED
5 years ago
2 years ago

People

(Reporter: Irving, Assigned: florian)

Tracking

(Blocks: 2 bugs)

unspecified
mozilla56
Points:
---
Dependency tree / graph
Bug Flags:
qe-verify -

Firefox Tracking Flags

(firefox56 fixed)

Details

(Whiteboard: [qf:p1] [photon-performance])

Attachments

(3 attachments)

Promise.jsm provides a non-standard way of constructing new Promises, using the Promise.defer() static method.

Because ES6 standardized "new Promise(function(resolve, reject){..})" as the way of constructing Promises, we should officially deprecate Promise.defer().

Comment 1

5 years ago
The first step is addressing the dev-doc-needed from bug 941757 on MDN:

https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm

We may at the same time add deprecation notes to the existing documentation.

After this is done, we should find all the "defer" calls in mozilla-central and either:
- Convert to them "new Promise" directly, or
- Replace "Promise.defer" calls with a local helper (that only calls "new Promise"),
  and file a bug against the component for the final conversion to "new Promise".

When there are no more mozilla-central calls, we can add a deprecation warning to the API itself to get add-ons converted as well.

All this work is required for migration to DOM Promises when ready.
David, can we use the defer defined in Promise-backend.js or is there any problem in that approach?
Oops sorry for comment 2
Well, we can't call it, because it is going to disappear, but the same implementation should work.
(Assignee)

Updated

2 years ago
Depends on: 1362882

Updated

2 years ago
Summary: Deprecate Promise.jsm Promise.defer() constructor → Convert remaining Promise.defer() uses to PromiseUtils.defer() or to an inline helper

Updated

2 years ago
Blocks: 1368456

Updated

2 years ago
Blocks: 1363777
No longer blocks: 1368456
Whiteboard: [qf][photon]

Updated

2 years ago
Blocks: 1368456
Whiteboard: [qf][photon] → [qf] [photon-performance] [triage]
Flags: qe-verify-
Priority: -- → P2
Whiteboard: [qf] [photon-performance] [triage] → [qf] [photon-performance]
Whiteboard: [qf] [photon-performance] → [qf:p1] [photon-performance]
Blocks: 1364015
(Assignee)

Comment 5

2 years ago
Created attachment 8879902 [details]
promise.defer calls not replaced by script

Here is the output of my script from bug 1362882, listing the Promise.defer calls it didn't dare replacing, and explaining why.
Assignee: nobody → florian
Status: NEW → ASSIGNED
Iteration: --- → 56.1 - Jun 26
Priority: P2 → P1
(Assignee)

Comment 6

2 years ago
Created attachment 8880184 [details] [diff] [review]
Patch

This handles only the Firefox code. Test, mobile and devtools code will be for follow-up (and I'm not volunteering to fix them).
This is mostly done by hand, although I sometimes used some help from the bug 1362882 script (when converting to new Promise() after tweaking a bit the original file to let the script pass).
Attachment #8880184 - Flags: review?(paolo.mozmail)
(Assignee)

Comment 7

2 years ago
Created attachment 8880185 [details] [diff] [review]
Patch (diff -w)

Diff -w version of attachment 8880184 [details] [diff] [review] for easier review.
Comment on attachment 8880184 [details] [diff] [review]
Patch

Review of attachment 8880184 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/components/jsdownloads/src/DownloadCore.jsm
@@ +840,5 @@
>        return Promise.resolve();
>      }
>  
> +    if (!this._promiseRemovePartialData) {
> +      this._promiseRemovePartialData = (async () => {

Whoa, today I learned about async () => {}
Attachment #8880184 - Flags: review?(paolo.mozmail) → review+

Comment 9

2 years ago
Pushed by florian@queze.net:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ea3fb9e7622e
Convert remaining Promise.defer() uses to PromiseUtils.defer() or new Promise(), r=mconley.
Depends on: 1376105

Comment 10

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/ea3fb9e7622e
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox56: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.