mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1523386 - [release 121] [flow] Fix types with firefox commands (#7751). r=dwalsh
This commit is contained in:
parent
c2bb783f96
commit
d6ea402092
@ -9,7 +9,6 @@
|
||||
* @module actions/breakpoints
|
||||
*/
|
||||
|
||||
import { isOriginalId } from "devtools-source-map";
|
||||
import { PROMISE } from "../utils/middleware/promise";
|
||||
import {
|
||||
getBreakpoint,
|
||||
@ -283,12 +282,7 @@ export function setBreakpointOptions(
|
||||
await dispatch(enableBreakpoint(bp));
|
||||
}
|
||||
|
||||
await client.setBreakpointOptions(
|
||||
bp.id,
|
||||
location,
|
||||
options,
|
||||
isOriginalId(bp.location.sourceId)
|
||||
);
|
||||
await client.setBreakpointOptions(bp.id, location, options);
|
||||
|
||||
const newBreakpoint = { ...bp, disabled: false, options };
|
||||
|
||||
|
@ -39,13 +39,15 @@ export function selectThread(thread: string) {
|
||||
*/
|
||||
export function command(type: Command) {
|
||||
return async ({ dispatch, getState, client }: ThunkArgs) => {
|
||||
const thread = getCurrentThread(getState());
|
||||
return dispatch({
|
||||
type: "COMMAND",
|
||||
command: type,
|
||||
thread,
|
||||
[PROMISE]: client[type](thread)
|
||||
});
|
||||
if (type) {
|
||||
const thread = getCurrentThread(getState());
|
||||
return dispatch({
|
||||
type: "COMMAND",
|
||||
command: type,
|
||||
thread,
|
||||
[PROMISE]: client[type](thread)
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ export function setPreview(
|
||||
thread: source.thread
|
||||
});
|
||||
|
||||
if (result === undefined) {
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ describe("toolbox", () => {
|
||||
|
||||
expect(threadClient.evaluate).toBeCalledWith(
|
||||
'console.log("foo"); console.log(foo)',
|
||||
{ frameId: null }
|
||||
{ frameId: null, thread: "UnknownThread" }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -5,7 +5,7 @@
|
||||
// @flow
|
||||
|
||||
const { isDevelopment } = require("devtools-environment");
|
||||
const { getSelectedFrameId } = require("../selectors");
|
||||
const { getSelectedFrameId, getCurrentThread } = require("../selectors");
|
||||
|
||||
import type { ThunkArgs } from "./types";
|
||||
import type { Worker, Grip } from "../types";
|
||||
@ -41,9 +41,10 @@ export function openWorkerToolbox(worker: Worker) {
|
||||
export function evaluateInConsole(inputString: string) {
|
||||
return async ({ client, getState }: ThunkArgs) => {
|
||||
const frameId = getSelectedFrameId(getState());
|
||||
const thread = getCurrentThread(getState());
|
||||
client.evaluate(
|
||||
`console.log("${inputString}"); console.log(${inputString})`,
|
||||
{ frameId }
|
||||
{ frameId, thread }
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import type { SourceAction } from "./SourceAction";
|
||||
import type { UIAction } from "./UIAction";
|
||||
import type { PauseAction } from "./PauseAction";
|
||||
import type { ASTAction } from "./ASTAction";
|
||||
import { clientCommands } from "../../client/firefox";
|
||||
|
||||
/**
|
||||
* Flow types
|
||||
@ -38,7 +39,7 @@ import type { ASTAction } from "./ASTAction";
|
||||
export type ThunkArgs = {
|
||||
dispatch: (action: any) => Promise<any>,
|
||||
getState: () => State,
|
||||
client: any,
|
||||
client: typeof clientCommands,
|
||||
sourceMaps: any,
|
||||
openLink: (url: string) => void,
|
||||
openWorkerToolbox: (worker: Worker) => void,
|
||||
|
@ -149,7 +149,9 @@ function breakOnNext(thread: string): Promise<*> {
|
||||
return lookupThreadClient(thread).breakOnNext();
|
||||
}
|
||||
|
||||
function sourceContents(sourceId: SourceId): Source {
|
||||
function sourceContents(
|
||||
sourceId: SourceId
|
||||
): {| source: Source, contentType: string |} {
|
||||
const sourceThreadClient = sourceThreads[sourceId];
|
||||
const sourceClient = sourceThreadClient.source({ actor: sourceId });
|
||||
return sourceClient.source();
|
||||
@ -261,22 +263,22 @@ async function evaluateExpressions(scripts: Script[], options: EvaluateParam) {
|
||||
return Promise.all(scripts.map(script => evaluate(script, options)));
|
||||
}
|
||||
|
||||
type EvaluateParam = { thread?: string, frameId?: FrameId };
|
||||
type EvaluateParam = { thread: string, frameId: ?FrameId };
|
||||
|
||||
function evaluate(
|
||||
script: ?Script,
|
||||
{ thread, frameId }: EvaluateParam = {}
|
||||
): Promise<mixed> {
|
||||
): Promise<{ result: ?Object }> {
|
||||
const params = { thread, frameActor: frameId };
|
||||
if (!tabTarget || !script) {
|
||||
return Promise.resolve({});
|
||||
return Promise.resolve({ result: null });
|
||||
}
|
||||
|
||||
const console = thread
|
||||
? lookupConsoleClient(thread)
|
||||
: tabTarget.activeConsole;
|
||||
if (!console) {
|
||||
return Promise.resolve({});
|
||||
return Promise.resolve({ result: null });
|
||||
}
|
||||
|
||||
return console.evaluateJSAsync(script, params);
|
||||
@ -285,7 +287,7 @@ function evaluate(
|
||||
function autocomplete(
|
||||
input: string,
|
||||
cursor: number,
|
||||
frameId: string
|
||||
frameId: ?string
|
||||
): Promise<mixed> {
|
||||
if (!tabTarget || !tabTarget.activeConsole || !input) {
|
||||
return Promise.resolve({});
|
||||
|
@ -221,7 +221,7 @@ export type TabTarget = {
|
||||
evaluateJS: (
|
||||
script: Script,
|
||||
func: Function,
|
||||
params?: { frameActor?: FrameId }
|
||||
params?: { frameActor: ?FrameId }
|
||||
) => void,
|
||||
evaluateJSAsync: (
|
||||
script: Script,
|
||||
@ -232,7 +232,7 @@ export type TabTarget = {
|
||||
input: string,
|
||||
cursor: number,
|
||||
func: Function,
|
||||
frameId: string
|
||||
frameId: ?string
|
||||
) => void
|
||||
},
|
||||
form: { consoleActor: any },
|
||||
@ -322,7 +322,7 @@ export type SourceClient = {
|
||||
setBreakpoint: ({
|
||||
line: number,
|
||||
column: ?number,
|
||||
condition: boolean,
|
||||
condition: ?string,
|
||||
noSliding: boolean
|
||||
}) => Promise<BreakpointResponse>,
|
||||
prettyPrint: number => Promise<*>,
|
||||
|
@ -37,8 +37,7 @@ export type Command =
|
||||
| "rewind"
|
||||
| "reverseStepOver"
|
||||
| "reverseStepIn"
|
||||
| "reverseStepOut"
|
||||
| "expression";
|
||||
| "reverseStepOut";
|
||||
|
||||
// Pause state associated with an individual thread.
|
||||
type ThreadPauseState = {
|
||||
|
Loading…
Reference in New Issue
Block a user