Bug 1432212 - Await startup recorder by using async function. r?maja_zf
Reduces block level indentation by one level by employing an async
arrow function and the await statement to wait for the startup
tests recorder to do its work.
MozReview-Commit-ID: 293qw0W2Puo
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -279,36 +279,38 @@ MarionetteComponent.prototype.suppressSa
}, {once: true});
};
MarionetteComponent.prototype.init = function() {
if (this.running || !this.enabled || !this.finalUIStartup) {
return;
}
- // Delay initialization until we are done with delayed startup...
- Services.tm.idleDispatchToMainThread(() => {
- // ... and with startup tests.
- let promise = Promise.resolve();
- if ("@mozilla.org/test/startuprecorder;1" in Cc)
- promise = Cc["@mozilla.org/test/startuprecorder;1"].getService().wrappedJSObject.done;
- promise.then(() => {
- let s;
- try {
- Cu.import("chrome://marionette/content/server.js");
- s = new server.TCPListener(prefs.port);
- s.start();
- log.info(`Listening on port ${s.port}`);
- } finally {
- if (s) {
- this.server = s;
- this.running = true;
- }
+ // wait for delayed startup...
+ Services.tm.idleDispatchToMainThread(async () => {
+ // ... and for startup tests
+ let startupRecorder = Promise.resolve();
+ if ("@mozilla.org/test/startuprecorder;1" in Cc) {
+ startupRecorder = Cc["@mozilla.org/test/startuprecorder;1"]
+ .getService().wrappedJSObject.done;
+ }
+ await startupRecorder;
+
+ let s;
+ try {
+ Cu.import("chrome://marionette/content/server.js");
+ s = new server.TCPListener(prefs.port);
+ s.start();
+ log.info(`Listening on port ${s.port}`);
+ } finally {
+ if (s) {
+ this.server = s;
+ this.running = true;
}
- });
+ }
});
};
MarionetteComponent.prototype.uninit = function() {
if (!this.running) {
return;
}
this.server.stop();