mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1929007
- [devtools] Collect console API calls when tracing from DevTools. r=dthayer
Because the tracer actor runs in the content process, the preference toggling logic has to be done in some code running in the parent process: TargetConfiguration. Differential Revision: https://phabricator.services.mozilla.com/D227833
This commit is contained in:
parent
868a58edfe
commit
049093be6b
@ -104,6 +104,9 @@ class TargetConfigurationActor extends Actor {
|
||||
this._browsingContext = this.watcherActor.browserElement?.browsingContext;
|
||||
}
|
||||
|
||||
// Value of `logging.console` pref, before starting recording JS Traces
|
||||
#consolePrefValue;
|
||||
|
||||
form() {
|
||||
return {
|
||||
actor: this.actorID,
|
||||
@ -234,6 +237,11 @@ class TargetConfigurationActor extends Actor {
|
||||
* @param {Object} configuration: See `updateConfiguration`
|
||||
*/
|
||||
_updateParentProcessConfiguration(configuration) {
|
||||
// Process "tracerOptions" for all session types, as this isn't specific to tab debugging
|
||||
if ("tracerOptions" in configuration) {
|
||||
this._setTracerOptions(configuration.tracerOptions);
|
||||
}
|
||||
|
||||
if (!this._shouldHandleConfigurationInParentProcess()) {
|
||||
return;
|
||||
}
|
||||
@ -290,6 +298,11 @@ class TargetConfigurationActor extends Actor {
|
||||
}
|
||||
|
||||
_restoreParentProcessConfiguration() {
|
||||
// Always process tracer options as this isn't specific to tab debugging
|
||||
if (this.#consolePrefValue !== undefined) {
|
||||
this._setTracerOptions();
|
||||
}
|
||||
|
||||
if (!this._shouldHandleConfigurationInParentProcess()) {
|
||||
return;
|
||||
}
|
||||
@ -495,6 +508,37 @@ class TargetConfigurationActor extends Actor {
|
||||
}
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the tracer is toggled on/off by the frontend.
|
||||
* Note that when `options` is defined, it is meant to be enabled.
|
||||
* It may not actually be tracing yet depending on the passed options.
|
||||
*
|
||||
* @param {Object} options
|
||||
*/
|
||||
_setTracerOptions(options) {
|
||||
if (!options) {
|
||||
if (this.#consolePrefValue === -1) {
|
||||
Services.prefs.clearUserPref("logging.console");
|
||||
} else {
|
||||
Services.prefs.setIntPref("logging.console", this.#consolePrefValue);
|
||||
}
|
||||
this.#consolePrefValue = undefined;
|
||||
return;
|
||||
}
|
||||
// Enable `MOZ_LOG=console:5` via the logging.console so that all console API calls
|
||||
// are stored in the profiler when recording JS Traces via the profiler.
|
||||
//
|
||||
// We do this from here as TargetConfiguration runs in the parent process,
|
||||
// where we can set preferences. Whereas the profiler tracer actor runs in the content process.
|
||||
const LOG_DISABLED = -1;
|
||||
const LOG_VERBOSE = 5;
|
||||
this.#consolePrefValue = Services.prefs.getIntPref(
|
||||
"logging.console",
|
||||
LOG_DISABLED
|
||||
);
|
||||
Services.prefs.setIntPref("logging.console", LOG_VERBOSE);
|
||||
}
|
||||
}
|
||||
|
||||
exports.TargetConfigurationActor = TargetConfigurationActor;
|
||||
|
Loading…
Reference in New Issue
Block a user