erikvold/jetpack-sdk — comment on commit 818eb0e6c7c480e01ef33541393db40075aa75c5
File: packages/addon-kit/tests/test-simple-prefs.js line 207
By mykmelez:

Such timeouts are brittle and prone to failure on slow machines like buildslaves and mobile devices. There are two alternatives:

1. If this is just about waiting for one turn of the event loop to ensure the emission of the event, which always happens before any timeouts fire, then the timeout is fine, but the `delay` should be set to 0 (zero) to make that more obvious. In my tests, this worked.

2. If this really does need to wait for an indeterminate period of time, then we need to use a different technique, like using the access to the private scope of the *simple-prefs* module to replace the `events` object with another one composed from that one but exposing its private list of event listeners, so you can inspect that list directly after unloading the module to make sure it has been cleared.