copy of http://mxr.mozilla.org/mozilla-central/source/browser/components/loop/standalone/