mozilla/addon-sdk — pull request #463 by KWierso (2012-06-13 05:15:06+00:00)
Title: Move all 'timer' requires to the top of test files to help prevent setTimeouts from being garbage collected

From IRC between me and Philor:

10:22:54 PM - KWierso: philor: so on aurora, win debug's results are always orange, and they all seem to be the same issue: https://tbpl.mozilla.org/?noignore=1&tree=Mozilla-Aurora&jobname=jetpack
10:47:05 PM - philor: I *think* maybe what that means is that you aren't protecting your timer against GC
10:50:08 PM - philor: having a setTimeout(0) get GCed before it fires is pretty awesome, but that's where you would be, and it's dead
11:05:30 PM - KWierso: philor: how does one protect against that?
11:06:50 PM - philor: there was a big push to put getting the timer service at the top level, not inside a function, in mochitests I think, because otherwise the timer could go away, that's the extent of my knowledge

So this pull request moves all instances of require("timer") to the top of the file so it's not wrapped inside a function. Hopefully this would prevent the random and/or almost-constant timeouts from occurring.