Closed Bug 1387123 Opened 7 years ago Closed 7 years ago

Replace all usages of require(promise).defer by require(devtools/shared/defer).defer

Categories

(DevTools :: General, enhancement)

enhancement
Not set
normal

Tracking

(firefox57 fixed)

RESOLVED FIXED
Firefox 57
Tracking Status
firefox57 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

Details

Attachments

(3 files)

In order to help removing usages of Promise.jsm, we could automatically convert all usages of require("promise").defer as that's the only one API from Promise.jsm that doesn't work with DOM Promise.

We already have an helper module: devtools/shared/defer which exposes just and only that.
Ideally, we would followup to ensure that we can't replace some usages by plain DOM Promise, with the constructor pattern like: "new Promise(done => {})".
Blocks: 1387128
(In reply to Alexandre Poirot [:ochameau] from comment #0)

> Ideally, we would followup to ensure that we can't replace some usages by
> plain DOM Promise, with the constructor pattern like: "new Promise(done =>
> {})".

This followup is bug 1283869.
Comment on attachment 8893494 [details]
Bug 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer.

https://reviewboard.mozilla.org/r/164574/#review170016

Thanks for the patch.  I like this approach.
Attachment #8893494 - Flags: review+
Comment on attachment 8893495 [details]
Bug 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer.

https://reviewboard.mozilla.org/r/164576/#review170020

Thanks.  Because this is large and auto-generated, I didn't read every hunk.
I do agree with the approach you took.  In the unlikely event that there's some issue, I imagine try will find it.
Attachment #8893495 - Flags: review+
Comment on attachment 8893496 [details]
Bug 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer.

https://reviewboard.mozilla.org/r/164578/#review170026

Thanks again.  This looks good, though there's one question that I think needs to be answered.

::: devtools/server/main.js:736
(Diff revision 1)
>  
>      return this._onConnection(transport, prefix, true);
>    },
>  
>    connectToContent(connection, mm, onDestroy) {
> -    let deferred = Syncdefer();
> +    let deferred = SyncPromise.defer();

I guess that regexp could have been a bit tighter.  But no worries.

::: devtools/server/worker.js:31
(Diff revision 1)
>  };
>  
>  loadSubScript("resource://devtools/shared/worker/loader.js");
>  
> -var Promise = worker.require("promise");
>  const defer = require("devtools/shared/defer");

Should this be worker.require, like the other requires here?
Attachment #8893496 - Flags: review+
(In reply to Tom Tromey :tromey from comment #9)
> Comment on attachment 8893496 [details]
> ::: devtools/server/worker.js:31
> (Diff revision 1)
> >  };
> >  
> >  loadSubScript("resource://devtools/shared/worker/loader.js");
> >  
> > -var Promise = worker.require("promise");
> >  const defer = require("devtools/shared/defer");
> 
> Should this be worker.require, like the other requires here?

Good catch!
Quick update on last orange try:

* Debugger frontend still uses depreated-sync promises and it doesn't play well with these scripts.
So I opened bug 1388364 to handle Promise.jsm removal for devtools/client/debugger manually.

* devtools/server/tests/mochitest/inspector-helpers.js still need to import promise as it is a shared test script exposing promise symbol to various tests. I made a one line eslint exception. Hopefully we would get rid of this require(promise) in bug 1387128.
Pushed by apoirot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/40601ae660c6
Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey
https://hg.mozilla.org/integration/autoland/rev/a820e391d900
Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey
https://hg.mozilla.org/integration/autoland/rev/84755985ba13
Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: