Open Bug 1553950 Opened 7 months ago Updated 7 months ago

We have way too many variants of promiseObserved

Categories

(Toolkit :: General, task, P5)

task

Tracking

()

Tracking Status
firefox69 --- affected

People

(Reporter: kmag, Unassigned, NeedInfo)

References

(Regression)

Details

Currently we have, for a start, 3 general-purpose helper functions to return a promise when an observer has been notified:

https://searchfox.org/mozilla-central/rev/662de518b1686c4769320d6b8825ce4864c4eda0/toolkit/components/extensions/ExtensionUtils.jsm#227-249
https://searchfox.org/mozilla-central/rev/662de518b1686c4769320d6b8825ce4864c4eda0/toolkit/modules/BrowserUtils.jsm#697-719
https://searchfox.org/mozilla-central/rev/662de518b1686c4769320d6b8825ce4864c4eda0/testing/modules/TestUtils.jsm#37-70

This is not the end of the world, but it would be nice if these could all be replaced with a single helper in toolkit.

However, according to this horrendous one-liner and some code reading:

hg manifest | grep '\.jsm?$' | perl -e 'for my $fn (<STDIN>) { chomp($fn); eval { open(my $fh, "<", $fn); my $meh = join("", <$fh>); if ($meh =~ /new Promise\(.*\n.*(Services.obs.addObserver|ubject.*opic)/) { print $fn, "\n"; } } }'

we actually have many, many more, with varying degrees of badness. Some don't even remove the observer. Some are multiple repetitions of the same code for different topics. Most of them make the code around them difficult to follow.

We should try to update most of these to use the shared helper, and possibly even add an ESLint rule to prevent people from adding new instances.

Apparently Johann promised to file a follow-up to fix some of this in bug 1529643.

Type: defect → task
Regressed by: 1529643
Flags: needinfo?(jhofmann)
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.