Bug 1464469 - Use MarionetteLog throughout. r?whimboo
Replace direct invocations of Log.jsm with the new Marionette-specific
logger.
The patch also moves the Log.get() call to a lazy getter.
MozReview-Commit-ID: H1HoAgL2Cvs
--- a/testing/marionette/accessibility.js
+++ b/testing/marionette/accessibility.js
@@ -1,22 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Log.jsm");
-const logger = Log.repository.getLogger("Marionette");
+const {ElementNotAccessibleError} = ChromeUtils.import("chrome://marionette/content/error.js", {});
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
-const {ElementNotAccessibleError} =
- ChromeUtils.import("chrome://marionette/content/error.js", {});
+XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
XPCOMUtils.defineLazyGetter(this, "service", () => {
try {
return Cc["@mozilla.org/accessibilityService;1"]
.getService(Ci.nsIAccessibilityService);
} catch (e) {
logger.warn("Accessibility module is not present");
return undefined;
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1,16 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* global XPCNativeWrapper */
-ChromeUtils.import("resource://gre/modules/Log.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("chrome://marionette/content/accessibility.js");
const {Addon} = ChromeUtils.import("chrome://marionette/content/addon.js", {});
ChromeUtils.import("chrome://marionette/content/assert.js");
ChromeUtils.import("chrome://marionette/content/atom.js");
const {
@@ -42,26 +41,28 @@ const {
UnsupportedOperationError,
WebDriverError,
} = ChromeUtils.import("chrome://marionette/content/error.js", {});
ChromeUtils.import("chrome://marionette/content/evaluate.js");
const {pprint} = ChromeUtils.import("chrome://marionette/content/format.js", {});
ChromeUtils.import("chrome://marionette/content/interaction.js");
ChromeUtils.import("chrome://marionette/content/l10n.js");
ChromeUtils.import("chrome://marionette/content/legacyaction.js");
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
ChromeUtils.import("chrome://marionette/content/modal.js");
const {MarionettePrefs} = ChromeUtils.import("chrome://marionette/content/prefs.js", {});
ChromeUtils.import("chrome://marionette/content/proxy.js");
ChromeUtils.import("chrome://marionette/content/reftest.js");
ChromeUtils.import("chrome://marionette/content/session.js");
const {
PollPromise,
TimedPromise,
} = ChromeUtils.import("chrome://marionette/content/sync.js", {});
+XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
this.EXPORTED_SYMBOLS = ["GeckoDriver"];
const APP_ID_FIREFOX = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
const FRAME_SCRIPT = "chrome://marionette/content/listener.js";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@@ -71,17 +72,16 @@ const SUPPORTED_STRATEGIES = new Set([
element.Strategy.Selector,
element.Strategy.ID,
element.Strategy.TagName,
element.Strategy.XPath,
element.Strategy.Anon,
element.Strategy.AnonAttribute,
]);
-const logger = Log.repository.getLogger("Marionette");
const globalMessageManager = Services.mm;
/**
* The Marionette WebDriver services provides a standard conforming
* implementation of the W3C WebDriver specification.
*
* @see {@link https://w3c.github.io/webdriver/webdriver-spec.html}
* @namespace driver
--- a/testing/marionette/evaluate.js
+++ b/testing/marionette/evaluate.js
@@ -1,30 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
-ChromeUtils.import("resource://gre/modules/Log.jsm");
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
ChromeUtils.import("resource://gre/modules/Timer.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("chrome://marionette/content/assert.js");
const {
element,
WebElement,
} = ChromeUtils.import("chrome://marionette/content/element.js", {});
const {
JavaScriptError,
ScriptTimeoutError,
} = ChromeUtils.import("chrome://marionette/content/error.js", {});
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
-const log = Log.repository.getLogger("Marionette");
+XPCOMUtils.defineLazyGetter(this, "log", Log.get);
this.EXPORTED_SYMBOLS = ["evaluate", "sandbox", "Sandboxes"];
const ARGUMENTS = "__webDriverArguments";
const CALLBACK = "__webDriverCallback";
const COMPLETE = "__webDriverComplete";
const DEFAULT_TIMEOUT = 10000; // ms
const FINISH = "finish";
--- a/testing/marionette/format.js
+++ b/testing/marionette/format.js
@@ -1,20 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
-ChromeUtils.import("resource://gre/modules/Log.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
+
+XPCOMUtils.defineLazyGetter(this, "log", Log.get);
this.EXPORTED_SYMBOLS = ["pprint", "truncate"];
-const log = Log.repository.getLogger("Marionette");
-
const MAX_STRING_LENGTH = 250;
/**
* Pretty-print values passed to template strings.
*
* Usage:
*
* <pre><code>
--- a/testing/marionette/legacyaction.js
+++ b/testing/marionette/legacyaction.js
@@ -1,29 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
-ChromeUtils.import("resource://gre/modules/Log.jsm");
ChromeUtils.import("resource://gre/modules/Preferences.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {
element,
WebElement,
} = ChromeUtils.import("chrome://marionette/content/element.js", {});
ChromeUtils.import("chrome://marionette/content/evaluate.js");
ChromeUtils.import("chrome://marionette/content/event.js");
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
+
+XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
const CONTEXT_MENU_DELAY_PREF = "ui.click_hold_context_menus.delay";
const DEFAULT_CONTEXT_MENU_DELAY = 750; // ms
this.EXPORTED_SYMBOLS = ["legacyaction"];
-const logger = Log.repository.getLogger("Marionette");
-
/** @namespace */
this.legacyaction = this.action = {};
/**
* Functionality for (single finger) action chains.
*/
action.Chain = function() {
// for assigning unique ids to all touches
--- a/testing/marionette/proxy.js
+++ b/testing/marionette/proxy.js
@@ -1,35 +1,34 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
-ChromeUtils.import("resource://gre/modules/Log.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {
error,
WebDriverError,
} = ChromeUtils.import("chrome://marionette/content/error.js", {});
ChromeUtils.import("chrome://marionette/content/evaluate.js");
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
ChromeUtils.import("chrome://marionette/content/modal.js");
const {
MessageManagerDestroyedPromise,
} = ChromeUtils.import("chrome://marionette/content/sync.js", {});
this.EXPORTED_SYMBOLS = ["proxy"];
+XPCOMUtils.defineLazyGetter(this, "log", Log.get);
XPCOMUtils.defineLazyServiceGetter(
this, "uuidgen", "@mozilla.org/uuid-generator;1", "nsIUUIDGenerator");
-const log = Log.repository.getLogger("Marionette");
-
// Proxy handler that traps requests to get a property. Will prioritise
// properties that exist on the object's own prototype.
const ownPriorityGetterTrap = {
get: (obj, prop) => {
if (obj.hasOwnProperty(prop)) {
return obj[prop];
}
return (...args) => obj.send(prop, args);
--- a/testing/marionette/reftest.js
+++ b/testing/marionette/reftest.js
@@ -1,29 +1,29 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
-ChromeUtils.import("resource://gre/modules/Log.jsm");
ChromeUtils.import("resource://gre/modules/Preferences.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("chrome://marionette/content/assert.js");
ChromeUtils.import("chrome://marionette/content/capture.js");
-const {InvalidArgumentError} =
- ChromeUtils.import("chrome://marionette/content/error.js", {});
+const {InvalidArgumentError} = ChromeUtils.import("chrome://marionette/content/error.js", {});
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
+
+XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
this.EXPORTED_SYMBOLS = ["reftest"];
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const PREF_E10S = "browser.tabs.remote.autostart";
-const logger = Log.repository.getLogger("Marionette");
-
const SCREENSHOT_MODE = {
unexpected: 0,
fail: 1,
always: 2,
};
const STATUS = {
PASS: "PASS",
--- a/testing/marionette/server.js
+++ b/testing/marionette/server.js
@@ -6,35 +6,36 @@
const CC = Components.Constructor;
const ServerSocket = CC(
"@mozilla.org/network/server-socket;1",
"nsIServerSocket",
"initSpecialConnection");
-ChromeUtils.import("resource://gre/modules/Log.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("chrome://marionette/content/assert.js");
const {GeckoDriver} = ChromeUtils.import("chrome://marionette/content/driver.js", {});
const {WebElement} = ChromeUtils.import("chrome://marionette/content/element.js", {});
const {
error,
UnknownCommandError,
} = ChromeUtils.import("chrome://marionette/content/error.js", {});
const {
Command,
Message,
Response,
} = ChromeUtils.import("chrome://marionette/content/message.js", {});
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
const {MarionettePrefs} = ChromeUtils.import("chrome://marionette/content/prefs.js", {});
const {DebuggerTransport} = ChromeUtils.import("chrome://marionette/content/transport.js", {});
-const logger = Log.repository.getLogger("Marionette");
+XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
const {KeepWhenOffline, LoopbackOnly} = Ci.nsIServerSocket;
this.EXPORTED_SYMBOLS = [
"TCPConnection",
"TCPListener",
];
--- a/testing/marionette/sync.js
+++ b/testing/marionette/sync.js
@@ -1,33 +1,34 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
-ChromeUtils.import("resource://gre/modules/Log.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {
error,
TimeoutError,
} = ChromeUtils.import("chrome://marionette/content/error.js", {});
+const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
+
+XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
this.EXPORTED_SYMBOLS = [
/* exported PollPromise, TimedPromise */
"PollPromise",
"TimedPromise",
/* exported MessageManagerDestroyedPromise */
"MessageManagerDestroyedPromise",
];
-const logger = Log.repository.getLogger("Marionette");
-
const {TYPE_ONE_SHOT, TYPE_REPEATING_SLACK} = Ci.nsITimer;
/**
* @callback Condition
*
* @param {function(*)} resolve
* To be called when the condition has been met. Will return the
* resolved value.