Bug 1384956 - Get log level from main process when script is reloaded. r=whimboo a=test-only
authorAndreas Tolfsen <ato@sny.no>
Sat, 11 Nov 2017 17:43:24 -0800
changeset 444924 20b45a6b07c3284145fcb7dd9d1b62e2354ce990
parent 444923 d0eadbf8ab5bda4be4aecdbb08df007e138760c1
child 444925 6ab6ed6d16644add877596b4697a92180818f01f
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo, test-only
bugs1384956, 1411513
milestone58.0
Bug 1384956 - Get log level from main process when script is reloaded. r=whimboo a=test-only This is a workaround for https://bugzil.la/1411513 about Log.jsm not being compatible with E10s. It queries the log level via synchronous IPC message to the main process. MozReview-Commit-ID: 5RZluH8Rv9o
testing/marionette/driver.js
testing/marionette/frame.js
testing/marionette/listener.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -3474,16 +3474,19 @@ GeckoDriver.prototype.receiveMessage = f
       if (message.json.listenerId === this.curBrowser.curFrameId) {
         // If the frame script gets reloaded we need to call newSession.
         // In the case of desktop this just sets up a small amount of state
         // that doesn't change over the course of a session.
         this.sendAsync("newSession", this.capabilities);
         this.curBrowser.flushPendingCommands();
       }
       break;
+
+    case "Marionette:GetLogLevel":
+      return logger.level;
   }
 };
 /* eslint-enable consistent-return */
 
 GeckoDriver.prototype.responseCompleted = function() {
   if (this.curBrowser !== null) {
     this.curBrowser.pendingCommands = [];
   }
--- a/testing/marionette/frame.js
+++ b/testing/marionette/frame.js
@@ -216,16 +216,17 @@ frame.Manager = class {
     mm.addWeakMessageListener("Marionette:emitTouchEvent", this.driver);
     mm.addWeakMessageListener("Marionette:log", this.driver);
     mm.addWeakMessageListener("Marionette:shareData", this.driver);
     mm.addWeakMessageListener("Marionette:switchToModalOrigin", this.driver);
     mm.addWeakMessageListener("Marionette:switchedToFrame", this.driver);
     mm.addWeakMessageListener("Marionette:getVisibleCookies", this.driver);
     mm.addWeakMessageListener("Marionette:register", this.driver);
     mm.addWeakMessageListener("Marionette:listenersAttached", this.driver);
+    mm.addWeakMessageListener("Marionette:GetLogLevel", this.driver);
     mm.addWeakMessageListener("MarionetteFrame:handleModal", this);
     mm.addWeakMessageListener("MarionetteFrame:getCurrentFrameId", this);
     mm.addWeakMessageListener("MarionetteFrame:getInterruptedState", this);
   }
 
   /**
    * Removes listeners for messages from content frame scripts.
    * We do not remove the MarionetteFrame:getInterruptedState or
@@ -243,16 +244,17 @@ frame.Manager = class {
     mm.removeWeakMessageListener("Marionette:done", this.driver);
     mm.removeWeakMessageListener("Marionette:error", this.driver);
     mm.removeWeakMessageListener("Marionette:log", this.driver);
     mm.removeWeakMessageListener("Marionette:shareData", this.driver);
     mm.removeWeakMessageListener("Marionette:switchedToFrame", this.driver);
     mm.removeWeakMessageListener("Marionette:getVisibleCookies", this.driver);
     mm.removeWeakMessageListener(
         "Marionette:getImportedScripts", this.driver.importedScripts);
+    mm.removeWeakMessageListener("Marionette:GetLogLevel", this.driver);
     mm.removeWeakMessageListener("Marionette:listenersAttached", this.driver);
     mm.removeWeakMessageListener("Marionette:register", this.driver);
     mm.removeWeakMessageListener("MarionetteFrame:handleModal", this);
     mm.removeWeakMessageListener("MarionetteFrame:getCurrentFrameId", this);
   }
 };
 
 frame.Manager.prototype.QueryInterface = XPCOMUtils.generateQI(
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -67,19 +67,21 @@ const SUPPORTED_STRATEGIES = new Set([
 
 let capabilities;
 
 let legacyactions = new legacyaction.Chain(checkForInterrupted);
 
 // last touch for each fingerId
 let multiLast = {};
 
+// TODO: Log.jsm is not e10s compatible (see https://bugzil.la/1411513),
+// query the main process for the current log level
 const logger = Log.repository.getLogger("Marionette");
-// Append only once to avoid duplicated output after listener.js gets reloaded
 if (logger.ownAppenders.length == 0) {
+  logger.level = sendSyncMessage("Marionette:GetLogLevel");
   logger.addAppender(new Log.DumpAppender());
 }
 
 // sandbox storage and name of the current sandbox
 const sandboxes = new Sandboxes(() => curContainer.frame);
 
 const eventObservers = new ContentEventObserverService(
     content, sendAsyncMessage.bind(this));