Bug 1566850 - Remove target.activeConsole usage in Debugger. r=jlast.

Differential Revision: https://phabricator.services.mozilla.com/D56690

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Chevobbe 2019-12-13 09:13:02 +00:00
parent 684b113226
commit 6865c4f4be
2 changed files with 33 additions and 31 deletions

View File

@ -230,13 +230,11 @@ function maybeGenerateLogGroupId(options) {
return options;
}
function maybeClearLogpoint(location: BreakpointLocation) {
async function maybeClearLogpoint(location: BreakpointLocation) {
const bp = breakpoints[locationKey(location)];
if (bp && bp.options.logGroupId && currentTarget.activeConsole) {
currentTarget.activeConsole.emit(
"clearLogpointMessages",
bp.options.logGroupId
);
if (bp && bp.options.logGroupId && currentTarget) {
const consoleFront = await currentTarget.getFront("console");
consoleFront.emit("clearLogpointMessages", bp.options.logGroupId);
}
}
@ -275,34 +273,39 @@ async function evaluateExpressions(scripts: Script[], options: EvaluateParam) {
type EvaluateParam = { thread: string, frameId: ?FrameId };
function evaluate(
async function evaluate(
script: ?Script,
{ thread, frameId }: EvaluateParam = {}
): Promise<{ result: ExpressionResult }> {
const params = { thread, frameActor: frameId };
if (!currentTarget || !script) {
return Promise.resolve({ result: null });
return { result: null };
}
const target = thread ? lookupTarget(thread) : currentTarget;
const consoleFront = target.activeConsole;
const consoleFront = await target.getFront("console");
if (!consoleFront) {
return Promise.resolve({ result: null });
return { result: null };
}
return consoleFront.evaluateJSAsync(script, params);
}
function autocomplete(
async function autocomplete(
input: string,
cursor: number,
frameId: ?string
): Promise<mixed> {
if (!currentTarget || !currentTarget.activeConsole || !input) {
return Promise.resolve({});
if (!currentTarget || !input) {
return {};
}
const consoleFront = await currentTarget.getFront("console");
if (!consoleFront) {
return {};
}
return new Promise(resolve => {
currentTarget.activeConsole.autocomplete(
consoleFront.autocomplete(
input,
cursor,
result => resolve(result),

View File

@ -178,21 +178,6 @@ export type TabPayload = {
webExtensionInspectedWindowActor: ActorId,
};
type ConsoleClient = {
evaluateJSAsync: (
script: Script,
func: Function,
params?: { frameActor: ?FrameId }
) => Promise<{ result: ExpressionResult }>,
autocomplete: (
input: string,
cursor: number,
func: Function,
frameId: ?string
) => void,
emit: (string, any) => void,
};
/**
* Tab Target gives access to the browser tabs
* @memberof firefox
@ -201,6 +186,7 @@ type ConsoleClient = {
export type Target = {
on: (string, Function) => void,
emit: (string, any) => void,
getFront: string => Promise<ConsoleFront>,
form: { consoleActor: any },
root: any,
navigateTo: ({ url: string }) => Promise<*>,
@ -208,8 +194,6 @@ export type Target = {
reload: () => Promise<*>,
destroy: () => void,
threadFront: ThreadFront,
activeConsole: ConsoleClient,
name: string,
isBrowsingContext: boolean,
isContentProcess: boolean,
@ -224,6 +208,21 @@ export type Target = {
debuggerServiceWorkerStatus: string,
};
type ConsoleFront = {
evaluateJSAsync: (
script: Script,
func: Function,
params?: { frameActor: ?FrameId }
) => Promise<{ result: ExpressionResult }>,
autocomplete: (
input: string,
cursor: number,
func: Function,
frameId: ?string
) => void,
emit: (string, any) => void,
};
/**
* Clients for accessing the Firefox debug server and browser
* @memberof firefox/clients