There is a utility function `utils.processEvents` for this on [commit for 921417](https://github.com/mozilla-b2g/gaia/pull/13159), please use it if it's landed.