Bug 1357407 - Enable logger output for framescript when remoteness is enabled. draft
authorHenrik Skupin <mail@hskupin.info>
Thu, 27 Apr 2017 12:09:10 +0200
changeset 569357 29b51dbfca5c7bcb3a90cf8e66e185f9f720e4da
parent 568509 0f5ba06c4c5959030a05cb852656d854065e2226
child 626181 8bd2dfd5e103e3a6e09ef715940819d304dce5bd
push id56145
push userbmo:hskupin@gmail.com
push dateThu, 27 Apr 2017 10:36:09 +0000
bugs1357407
milestone55.0a1
Bug 1357407 - Enable logger output for framescript when remoteness is enabled. With remoteness enabled content framescripts don't seem to inherit the appenders for loggers, which have been set by the main script. To get the output written to stdout they have to add their own appender. To prevent duplicated output after framescripts get reloaded, the addition of the appender should only happen once. MozReview-Commit-ID: A5TMQvQu0Iy
testing/marionette/listener.js
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -88,16 +88,20 @@ var asyncChrome = proxy.toChromeAsync({
   sendAsyncMessage: sendAsyncMessage.bind(this),
 });
 var syncChrome = proxy.toChrome(sendSyncMessage.bind(this));
 var cookies = new Cookies(() => curContainer.frame.document, syncChrome);
 var importedScripts = new evaluate.ScriptStorageServiceClient(syncChrome);
 
 Cu.import("resource://gre/modules/Log.jsm");
 var logger = Log.repository.getLogger("Marionette");
+// Append only once to avoid duplicated output after listener.js gets reloaded
+if (logger.ownAppenders.length == 0) {
+  logger.addAppender(new Log.DumpAppender());
+}
 logger.debug("loaded listener.js");
 
 var modalHandler = function() {
   // This gets called on the system app only since it receives the mozbrowserprompt event
   sendSyncMessage("Marionette:switchedToFrame", {frameValue: null, storePrevious: true});
   let isLocal = sendSyncMessage("MarionetteFrame:handleModal", {})[0].value;
   if (isLocal) {
     previousContainer = curContainer;
@@ -664,23 +668,16 @@ function resetValues() {
   sandboxes.clear();
   curContainer = {frame: content, shadowRoot: null};
   legacyactions.mouseEventsOnly = false;
   action.inputStateMap = new Map();
   action.inputsToCancel = [];
 }
 
 /**
- * Dump a logline to stdout. Prepends logline with a timestamp.
- */
-function dumpLog(logline) {
-  dump(Date.now() + " Marionette: " + logline);
-}
-
-/**
  * Check if our context was interrupted
  */
 function wasInterrupted() {
   if (previousContainer) {
     let element = content.document.elementFromPoint((content.innerWidth/2), (content.innerHeight/2));
     if (element.id.indexOf("modal-dialog") == -1) {
       return true;
     }
@@ -773,18 +770,20 @@ function setTestName(msg) {
   sendOk(msg.json.command_id);
 }
 
 /**
  * This function creates a touch event given a touch type and a touch
  */
 function emitTouchEvent(type, touch) {
   if (!wasInterrupted()) {
-    let loggingInfo = "emitting Touch event of type " + type + " to element with id: " + touch.target.id + " and tag name: " + touch.target.tagName + " at coordinates (" + touch.clientX + ", " + touch.clientY + ") relative to the viewport";
-    dumpLog(loggingInfo);
+    logger.info(`Emitting Touch event of type ${type} to element with id: ${touch.target.id} ` +
+                `and tag name: ${touch.target.tagName} at coordinates (${touch.clientX}, ` +
+                `${touch.clientY}) relative to the viewport`);
+
     var docShell = curContainer.frame.document.defaultView.
                    QueryInterface(Components.interfaces.nsIInterfaceRequestor).
                    getInterface(Components.interfaces.nsIWebNavigation).
                    QueryInterface(Components.interfaces.nsIDocShell);
     if (docShell.asyncPanZoomEnabled && legacyactions.scrolling) {
       // if we're in APZ and we're scrolling, we must use sendNativeTouchPoint to dispatch our touchmove events
       let index = sendSyncMessage("MarionetteFrame:getCurrentFrameId");
       // only call emitTouchEventForIFrame if we're inside an iframe.