If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Want way to temporarily twiddle prefs for a mochitest

NEW
Assigned to

Status

Testing
Mochitest
10 years ago
6 years ago

People

(Reporter: bz, Assigned: Robert Sayre)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

From IRC discussion, the winner was:

<sayrer> so setPrefs({}), where the function would reset them on finish

This would be great for something like bfcache prefs.  Once this is fixed, we should use it in content/base/test/test_bug398243.html to make sure bfcache is disabled while the test is running.
Continuation-passing style!

> 
> // calls test, providing a cleanup function as argument
> setPrefs({"pref": value}, test);
>
> // ...or if you don't like that, returns it
> var done = setPrefs({"pref": value});
> 
> function test(done) // argument only needed in first case
> {
>   // ... do stuff, possibly asynchronously...
> 
>   done(); // or inside a function on an object notified when the test completes
> }
> 

I used this style for the simplified HTTP testing of the web server, coded here:

http://mxr.mozilla.org/mozilla/source/netwerk/test/httpserver/test/head_utils.js
Then the test function needs to pass along the continuation all along my test until the end.  That's pretty painful, esp. because some of the test is triggered by load events.
(Assignee)

Comment 3

10 years ago
(In reply to comment #1)
> Continuation-passing style!

Full conversation:

<bz>	sayrer: got a question
<bz>	sayrer: I recently wrote some code to set/restore prefs
<bz>	sayrer: for a test
<bz>	http://lxr.mozilla.org/seamonkey/source/netwerk/test/unit/test_bug396389.js#19
<bz>	sayrer: would it be worth it to add something like that to mochitest?
<sayrer>	bz, yeah probably. something like |var funcWithPrefs = withPrefs({}, func);|
<bz>	that's not good enough for what I need
<bz>	I need to set some prefs
<bz>	run some code
<bz>	wait for some events
<bz>	run some more code
<bz>	unset the prefs
<sayrer>	dangit
<bz>	Specifically, disable bfcache
<bz>	do a load
<bz>	wait for it to finish
<bz>	do a history nav
<bz>	wait for it to finish
<bz>	reenable bfcache
<sayrer>	bz, so you could live with something that set the prefs and then unset them when the test finished?
<bz>	sayrer: yeah
<sayrer>	so setPrefs({}), where the function would reset them on finish
<bz>	ah
<bz>	yeah, that works
<bz>	ok, lemme try that!
<bz>	hmm
<bz>	wait
<bz>	how do I detect finish?
* bz	should just file a bug on this
<sayrer>	yeah, let me write it
<sayrer>	assign to me
Moving a bunch of Core :: Testing bugs to Testing :: Mochitest to clear out the former, which is obsolete now that we have more specialized categories for such bugs; filter on the string "MochitestMmMm" to delete all these notifications.
Component: Testing → Mochitest
Product: Core → Testing
QA Contact: testing → mochitest
Version: Trunk → unspecified
You need to log in before you can comment on or make changes to this bug.