Bug 1369700 - Delay initialization of marionette.js until delayed startup and startup tests are finished, r=ato.
authorFlorian Quèze <florian@queze.net>
Fri, 02 Jun 2017 22:08:21 +0200
changeset 362051 a3f93870b233106e15e8ff90dfa41f0c72241e0c
parent 362050 a2f20b984917c9269796ad69f23f448e9f29882f
child 362052 483b253cdd73802d4de006eedc5a543b4339a3e7
push id90998
push userflorian@queze.net
push dateFri, 02 Jun 2017 20:08:53 +0000
treeherdermozilla-inbound@a3f93870b233 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1369700, 1358798
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1369700 - Delay initialization of marionette.js until delayed startup and startup tests are finished, r=ato. Before this patch, marionette.js starts its initialization right after receiving the "sessionstore-windows-restored" notification. This is unfortunate for the browser_startup.js browser chrome mochitest added in bug 1358798, because it causes lots of marionette file to appear to be loaded before the browser is ready to handle user events.
testing/marionette/components/marionette.js
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -245,28 +245,34 @@ MarionetteComponent.prototype.suppressSa
   }, {once: true});
 };
 
 MarionetteComponent.prototype.init = function () {
   if (this.running || !this.enabled || !this.finalUIStartup) {
     return;
   }
 
-  let s;
-  try {
-    Cu.import("chrome://marionette/content/server.js");
-    s = new server.TCPListener(prefs.port);
-    s.start();
-    this.logger.info(`Listening on port ${s.port}`);
-  } finally {
-    if (s) {
-      this.server = s;
-      this.running = true;
-    }
-  }
+  // Delay initialization until we are done with delayed startup...
+  Services.tm.mainThread.idleDispatch(() => {
+    // ... and with startup tests.
+    Services.tm.mainThread.idleDispatch(() => {
+      let s;
+      try {
+        Cu.import("chrome://marionette/content/server.js");
+        s = new server.TCPListener(prefs.port);
+        s.start();
+        this.logger.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();
   this.running = false;