diff options
Diffstat (limited to 'devtools/server/actors/webconsole/commands/manager.js')
-rw-r--r-- | devtools/server/actors/webconsole/commands/manager.js | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/devtools/server/actors/webconsole/commands/manager.js b/devtools/server/actors/webconsole/commands/manager.js index 538ee7eac1..025e197e3b 100644 --- a/devtools/server/actors/webconsole/commands/manager.js +++ b/devtools/server/actors/webconsole/commands/manager.js @@ -11,6 +11,13 @@ loader.lazyRequireGetter( true ); +loader.lazyRequireGetter( + this, + ["DOM_MUTATIONS"], + "resource://devtools/server/tracer/tracer.jsm", + true +); + loader.lazyGetter(this, "l10n", () => { return new Localization( [ @@ -88,7 +95,7 @@ const WebConsoleCommandsManager = { * } * }); */ - register({ name, isSideEffectFree, command, validArguments, usage }) { + register({ name, isSideEffectFree, command, validArguments }) { if ( typeof command != "function" && !(typeof command == "object" && typeof command.get == "function") @@ -684,7 +691,7 @@ WebConsoleCommandsManager.register({ WebConsoleCommandsManager.register({ name: "help", isSideEffectFree: false, - command(owner, args) { + command(owner) { owner.helperResult = { type: "help" }; }, }); @@ -873,13 +880,35 @@ WebConsoleCommandsManager.register({ const tracerActor = owner.consoleActor.parentActor.getTargetScopedActor("tracer"); const logMethod = args.logMethod || "console"; + let traceDOMMutations = null; + if ("dom-mutations" in args) { + // When no value is passed, track all types of mutations + if (args["dom-mutations"] === true) { + traceDOMMutations = ["add", "attributes", "remove"]; + } else if (typeof args["dom-mutations"] == "string") { + // Otherwise consider the value as coma seperated list and remove any white space. + traceDOMMutations = args["dom-mutations"].split(",").map(e => e.trim()); + const acceptedValues = Object.values(DOM_MUTATIONS); + if (!traceDOMMutations.every(e => acceptedValues.includes(e))) { + throw new Error( + `:trace --dom-mutations only accept a list of strings whose values can be: ${acceptedValues}` + ); + } + } else { + throw new Error( + ":trace --dom-mutations accept only no arguments, or a list mutation type strings (add,attributes,remove)" + ); + } + } // Note that toggleTracing does some sanity checks and will throw meaningful error // when the arguments are wrong. const enabled = tracerActor.toggleTracing({ logMethod, prefix: args.prefix || null, + traceFunctionReturn: !!args.returns, traceValues: !!args.values, traceOnNextInteraction: args["on-next-interaction"] || null, + traceDOMMutations, maxDepth: args["max-depth"] || null, maxRecords: args["max-records"] || null, }); @@ -895,7 +924,9 @@ WebConsoleCommandsManager.register({ "max-depth", "max-records", "on-next-interaction", + "dom-mutations", "prefix", + "returns", "values", ], }); |