Re: pushPrefEnv/popPrefEnv/flushPrefEnv now return Promises

2016-05-20 Thread Mike Conley
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


Re: pushPrefEnv/popPrefEnv/flushPrefEnv now return Promises

2016-05-20 Thread Ted Mielczarek
On Thu, May 19, 2016, at 07: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]]});
>…
> })

This is a really great improvement, thanks!

-Ted
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: pushPrefEnv/popPrefEnv/flushPrefEnv now return Promises

2016-05-19 Thread Andrew McCreight
On Thu, May 19, 2016 at 4:09 PM, Matthew N.  wrote:

> 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.
>

Another good thing about it is that set*Pref isn't actually synchronous in
the e10s content process, so you can end up with the pref not being set at
the right time. (IIRC the set pref sends a message to the parent telling it
to update the pref, but then continues running before the parent sends a
message back down to the child to actually set the child process pref.)

Andrew


> 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


pushPrefEnv/popPrefEnv/flushPrefEnv now return Promises

2016-05-19 Thread Matthew N.

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