This is great, thank you!
On 19/05/2016 7:09 PM, Matthew N. wrote: > Hello, > > One of the reasons developers have been avoiding pushPrefEnv compared to > the synchronous set*Pref (with a registerCleanupFunction) is because > pushPrefEnv required using a callback function to wait for the > preference change before moving on in the test file. This can make the > test flow more complicated (especially when using add_task) and > therefore harder to follow. > > Bug 1197310[1] made pushPrefEnv/popPrefEnv/flushPrefEnv return a promise > which resolves when the callbacks would have been called so now you can > simply write test code like so: > > add_task(function* setup() { > yield SpecialPowers.pushPrefEnv({"set": [["signon.debug", true]]}); > … > }) > > As a reminder, the nice thing about pushPrefEnv is that the pref changes > are reverted at the end of the test file which avoids them leaking into > other tests unintentionally. > > There are various places in the tree which wrote their own Promise > wrappers for pushPrefEnv so feel free to file follow-up bugs blocking > bug 1197310 to remove them. > > Cheers, > Matthew N. (:MattN) > > [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1197310 > > P.S. For those of you who didn't hear (since there was no announcement), > you can use add_task in mochitest-plain and mochitest-chrome thanks to > bug 1187701 if you load …/tests/SimpleTest/SpawnTask.js. > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform