Bug 1431089 - Truncate logged URLs. r?maja_zf
Because we use a lot of data URIs when testing Marionette, the URLs
we log during navigation can be quite long. As with logged packets,
we should truncate the URLs.
MozReview-Commit-ID: AKpr5vvdU8P
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -33,16 +33,17 @@ const {
NoSuchFrameError,
pprint,
TimeoutError,
UnknownError,
} = Cu.import("chrome://marionette/content/error.js", {});
Cu.import("chrome://marionette/content/evaluate.js");
Cu.import("chrome://marionette/content/event.js");
const {ContentEventObserverService} = Cu.import("chrome://marionette/content/dom.js", {});
+const {truncate} = Cu.import("chrome://marionette/content/format.js", {});
Cu.import("chrome://marionette/content/interaction.js");
Cu.import("chrome://marionette/content/legacyaction.js");
Cu.import("chrome://marionette/content/navigate.js");
Cu.import("chrome://marionette/content/proxy.js");
Cu.import("chrome://marionette/content/session.js");
Cu.importGlobalProperties(["URL"]);
@@ -154,17 +155,17 @@ const loadListener = {
} else {
// The frame script got reloaded due to a new content process.
// Due to the time it takes to re-register the browser in Marionette,
// it can happen that page load events are missed before the listeners
// are getting attached again. By checking the document readyState the
// command can return immediately if the page load is already done.
let readyState = content.document.readyState;
let documentURI = content.document.documentURI;
- logger.debug(`Check readyState "${readyState} for "${documentURI}"`);
+ logger.debug(truncate`Check readyState ${readyState} for ${documentURI}`);
// If the page load has already finished, don't setup listeners and
// timers but return immediatelly.
if (this.handleReadyState(readyState, documentURI)) {
return;
}
addEventListener("DOMContentLoaded", loadListener, true);
addEventListener("pageshow", loadListener, true);
@@ -208,17 +209,17 @@ const loadListener = {
// Only care about events from the currently selected browsing context,
// whereby some of those do not bubble up to the window.
if (event.target != curContainer.frame &&
event.target != curContainer.frame.document) {
return;
}
let location = event.target.documentURI || event.target.location.href;
- logger.debug(`Received DOM event "${event.type}" for "${location}"`);
+ logger.debug(truncate`Received DOM event ${event.type} for ${location}`);
switch (event.type) {
case "beforeunload":
this.seenBeforeUnload = true;
break;
case "unload":
this.seenUnload = true;
@@ -347,17 +348,17 @@ const loadListener = {
},
observe(subject, topic) {
const win = curContainer.frame;
const winID = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
const curWinID = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
- logger.debug(`Received observer notification "${topic}" for "${winID}"`);
+ logger.debug(`Received observer notification ${topic} for ${winID}`);
switch (topic) {
// In the case when the currently selected frame is closed,
// there will be no further load events. Stop listening immediately.
case "outer-window-destroyed":
if (curWinID === winID) {
this.stop();
sendOk(this.commandID);
@@ -1623,17 +1624,17 @@ async function reftestWait(url, remote)
let windowUtils = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let reftestWait = false;
if (document.location.href !== url || document.readyState != "complete") {
- logger.debug(`Waiting for page load of ${url}`);
+ logger.debug(truncate`Waiting for page load of ${url}`);
await new Promise(resolve => {
let maybeResolve = event => {
if (event.target === curContainer.frame.document &&
event.target.location.href === url) {
win = curContainer.frame;
document = curContainer.frame.document;
reftestWait = document.documentElement.classList.contains("reftest-wait");
removeEventListener("load", maybeResolve, {once: true});