DevTools: ensure all auto-start modules are loaded before starting the app.

Change-Id: I9dcdabed9e8e255bfb9911234b5c2c2a37d57fd1
Reviewed-on: https://chromium-review.googlesource.com/c/1349501
Reviewed-by: Aleksey Kozyatinskiy <[email protected]>
Commit-Queue: Pavel Feldman <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#610722}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 89caaba1c8fadd39eb064b5dc2f9314436acbdea
diff --git a/front_end/Runtime.js b/front_end/Runtime.js
index 11093b8..46698e7 100644
--- a/front_end/Runtime.js
+++ b/front_end/Runtime.js
@@ -66,8 +66,6 @@
 
     for (let i = 0; i < descriptors.length; ++i)
       this._registerModule(descriptors[i]);
-
-    Runtime._runtimeReadyPromiseCallback();
   }
 
   /**
@@ -237,8 +235,8 @@
   /**
    * @return {!Promise}
    */
-  static async runtimeReady() {
-    return Runtime._runtimeReadyPromise;
+  static async appStarted() {
+    return Runtime._appStartedPromise;
   }
 
   /**
@@ -289,7 +287,8 @@
     }
     self.runtime = new Runtime(moduleDescriptors);
     if (coreModuleNames)
-      return /** @type {!Promise<undefined>} */ (self.runtime._loadAutoStartModules(coreModuleNames));
+      await self.runtime._loadAutoStartModules(coreModuleNames);
+    Runtime._appStartedPromiseCallback();
   }
 
   /**
@@ -1069,8 +1068,8 @@
 Runtime.experiments = new Runtime.ExperimentsSupport();
 
 /** @type {Function} */
-Runtime._runtimeReadyPromiseCallback;
-Runtime._runtimeReadyPromise = new Promise(fulfil => Runtime._runtimeReadyPromiseCallback = fulfil);
+Runtime._appStartedPromiseCallback;
+Runtime._appStartedPromise = new Promise(fulfil => Runtime._appStartedPromiseCallback = fulfil);
 /**
  * @type {?string}
  */
diff --git a/front_end/main/Main.js b/front_end/main/Main.js
index 297b32b..646164f 100644
--- a/front_end/main/Main.js
+++ b/front_end/main/Main.js
@@ -60,7 +60,7 @@
 
   async _loaded() {
     console.timeStamp('Main._loaded');
-    await Runtime.runtimeReady();
+    await Runtime.appStarted();
     Runtime.setPlatform(Host.platform());
     InspectorFrontendHost.getPreferences(this._gotPreferences.bind(this));
   }