зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1870801 - [devtools] Log JS tracer start/stop, even when not initiated from console command. r=devtools-reviewers,nchevobbe
The JavaScript Tracer may be initiated by the debugger, or stoped by itself when reaching some limit. In these cases, the start and stop messages wouldn't have been logged in the console. Differential Revision: https://phabricator.services.mozilla.com/D196831
This commit is contained in:
Родитель
19cfb1bddc
Коммит
2124160fff
|
@ -27,6 +27,8 @@ add_task(async function () {
|
|||
"Split console is automatically opened when tracing to the console"
|
||||
);
|
||||
|
||||
await hasConsoleMessage(dbg, "Started tracing to Web Console");
|
||||
|
||||
invokeInTab("main");
|
||||
|
||||
info("Wait for console messages for the whole trace");
|
||||
|
@ -91,6 +93,7 @@ add_task(async function () {
|
|||
await waitForState(dbg, state => {
|
||||
return !dbg.selectors.getIsThreadCurrentlyTracing(topLevelThreadActorID);
|
||||
});
|
||||
await hasConsoleMessage(dbg, "Stopped tracing");
|
||||
|
||||
invokeInTab("inline_script2");
|
||||
|
||||
|
|
|
@ -364,35 +364,8 @@ function handleHelperResult(response) {
|
|||
break;
|
||||
|
||||
case "traceOutput":
|
||||
const { enabled, logMethod } = helperResult;
|
||||
let message;
|
||||
if (enabled) {
|
||||
if (logMethod == "stdout") {
|
||||
message = l10n.getStr(
|
||||
"webconsole.message.commands.startTracingToStdout"
|
||||
);
|
||||
} else if (logMethod == "console") {
|
||||
message = l10n.getStr(
|
||||
"webconsole.message.commands.startTracingToWebConsole"
|
||||
);
|
||||
} else if (logMethod == "profiler") {
|
||||
message = l10n.getStr(
|
||||
"webconsole.message.commands.startTracingToProfiler"
|
||||
);
|
||||
} else {
|
||||
throw new Error(`Unsupported tracer log method ${logMethod}`);
|
||||
}
|
||||
} else {
|
||||
message = l10n.getStr("webconsole.message.commands.stopTracing");
|
||||
}
|
||||
dispatch(
|
||||
messagesActions.messagesAdd([
|
||||
{
|
||||
resourceType: ResourceCommand.TYPES.PLATFORM_MESSAGE,
|
||||
message,
|
||||
},
|
||||
])
|
||||
);
|
||||
// Nothing in particular to do.
|
||||
// The JSTRACER_STATE resource will report the start/stop of the profiler.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ add_task(async function () {
|
|||
ok(msg.textContent.includes("Toggles the JavaScript tracer"));
|
||||
|
||||
info("Test toggling the tracer ON");
|
||||
// Pass `console-api` specific classname as the command results aren't logged as "result".
|
||||
// Instead the frontend log a message as a console API message.
|
||||
// Pass `console-api` specific classname as the command results don't log anything.
|
||||
// Instead a JSTRACER_STATE resource logs a console-api message.
|
||||
msg = await evaluateExpressionInConsole(
|
||||
hud,
|
||||
":trace --logMethod console --prefix foo --values --on-next-interaction",
|
||||
|
|
|
@ -126,6 +126,10 @@ function transformResource(resource, persistLogs) {
|
|||
return transformTraceResource(resource);
|
||||
}
|
||||
|
||||
case ResourceCommand.TYPES.JSTRACER_STATE: {
|
||||
return transformTracerStateResource(resource);
|
||||
}
|
||||
|
||||
case "will-navigate": {
|
||||
return transformNavigationMessagePacket(resource);
|
||||
}
|
||||
|
@ -409,6 +413,36 @@ function transformTraceResource(traceResource) {
|
|||
});
|
||||
}
|
||||
|
||||
function transformTracerStateResource(stateResource) {
|
||||
const { targetFront, enabled, logMethod, timeStamp } = stateResource;
|
||||
let message;
|
||||
if (enabled) {
|
||||
if (logMethod == "stdout") {
|
||||
message = l10n.getStr("webconsole.message.commands.startTracingToStdout");
|
||||
} else if (logMethod == "console") {
|
||||
message = l10n.getStr(
|
||||
"webconsole.message.commands.startTracingToWebConsole"
|
||||
);
|
||||
} else if (logMethod == "profiler") {
|
||||
message = l10n.getStr(
|
||||
"webconsole.message.commands.startTracingToProfiler"
|
||||
);
|
||||
} else {
|
||||
throw new Error(`Unsupported tracer log method ${logMethod}`);
|
||||
}
|
||||
} else {
|
||||
message = l10n.getStr("webconsole.message.commands.stopTracing");
|
||||
}
|
||||
return new ConsoleMessage({
|
||||
targetFront,
|
||||
source: MESSAGE_SOURCE.CONSOLE_API,
|
||||
type: MESSAGE_TYPE.LOG,
|
||||
level: MESSAGE_LEVEL.LOG,
|
||||
messageText: message,
|
||||
timeStamp,
|
||||
});
|
||||
}
|
||||
|
||||
function transformEvaluationResultPacket(packet) {
|
||||
let {
|
||||
exceptionMessage,
|
||||
|
|
|
@ -187,6 +187,7 @@ class WebConsoleUI {
|
|||
resourceCommand.TYPES.DOCUMENT_EVENT,
|
||||
resourceCommand.TYPES.LAST_PRIVATE_CONTEXT_EXIT,
|
||||
resourceCommand.TYPES.JSTRACER_TRACE,
|
||||
resourceCommand.TYPES.JSTRACER_STATE,
|
||||
],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
|
@ -339,6 +340,7 @@ class WebConsoleUI {
|
|||
resourceCommand.TYPES.DOCUMENT_EVENT,
|
||||
resourceCommand.TYPES.LAST_PRIVATE_CONTEXT_EXIT,
|
||||
resourceCommand.TYPES.JSTRACER_TRACE,
|
||||
resourceCommand.TYPES.JSTRACER_STATE,
|
||||
],
|
||||
{ onAvailable: this._onResourceAvailable }
|
||||
);
|
||||
|
|
|
@ -61,6 +61,7 @@ class TracingStateWatcher {
|
|||
logMethod == LOG_METHODS.PROFILER && !enabled
|
||||
? tracerActor.getProfile()
|
||||
: undefined,
|
||||
timeStamp: ChromeUtils.dateNow(),
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче