Bug 830865 - Mirror gaia_app.js from gaia-ui-tests to gaia, r=lightsofap...

...ollo, a=test-only

This merges the work done in bug 830240 (to adapt Gaia UI Tests to recent window_manager changes) from gaia-ui-tests to gaia.

The primary difference from an earlier merged PR is to add a new method, getRunningApps(), that can return a version of the runningApps object that is JSON-serializable, and to change the return value of launchWithName so that the 'frame' attribute of the returned object specifies the actual application frame, and not just its id.  We needed to make this change because app iframes do not always have an id now.

AFAICT, this should work with the Gaia integration tests (at e.g., https://github.com/mozilla-b2g/gaia/blob/master/tests/js/app_integration.js#L243)  without further changes.  However, they fail for me on an unagi with and without this patch for apparently unrelated reasons.