Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Add windowless workers UI (#7525)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhackett1024 authored and Jason Laster committed Dec 20, 2018
1 parent 81c191d commit 54bd024
Show file tree
Hide file tree
Showing 42 changed files with 621 additions and 221 deletions.
1 change: 1 addition & 0 deletions assets/panel/prefs.js
Expand Up @@ -68,3 +68,4 @@ pref("devtools.debugger.features.autocomplete-expressions", false);
pref("devtools.debugger.features.map-expression-bindings", true);
pref("devtools.debugger.features.xhr-breakpoints", true);
pref("devtools.debugger.features.origial-blackbox", false);
pref("devtools.debugger.features.windowless-workers", false);
2 changes: 1 addition & 1 deletion bin/copy-modules.js
Expand Up @@ -24,7 +24,7 @@ function ignoreFile(file) {
// We exclude worker files because they are bundled and we include
// worker/index.js files because are required by the debugger app in order
// to communicate with the worker.
if (file.match(/\/workers/) && !file.match(/index.js/)) {
if (file.match(/\/workers/) && !file.match(/workers.js/) && !file.match(/index.js/)) {
return true;
}

Expand Down
14 changes: 12 additions & 2 deletions src/actions/expressions.js
Expand Up @@ -5,6 +5,7 @@
// @flow

import {
getCurrentThread,
getExpression,
getExpressions,
getSelectedFrame,
Expand Down Expand Up @@ -117,7 +118,11 @@ export function evaluateExpressions() {
const expressions = getExpressions(getState()).toJS();
const inputs = expressions.map(({ input }) => input);
const frameId = getSelectedFrameId(getState());
const results = await client.evaluateExpressions(inputs, frameId);
const thread = getCurrentThread(getState());
const results = await client.evaluateExpressions(inputs, {
frameId,
thread
});
dispatch({ type: "EVALUATE_EXPRESSIONS", inputs, results });
};
}
Expand Down Expand Up @@ -147,11 +152,16 @@ function evaluateExpression(expression: Expression) {
}

const frameId = getSelectedFrameId(getState());
const thread = getCurrentThread(getState());

return dispatch({
type: "EVALUATE_EXPRESSION",
thread,
input: expression.input,
[PROMISE]: client.evaluateInFrame(wrapExpression(input), frameId)
[PROMISE]: client.evaluateInFrame(wrapExpression(input), {
frameId,
thread
})
});
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/actions/navigation.js
Expand Up @@ -54,10 +54,10 @@ export function navigate(url: string): Action {
};
}

export function connect(url: string, canRewind: boolean) {
export function connect(url: string, thread: string, canRewind: boolean) {
return async function({ dispatch }: ThunkArgs) {
await dispatch(updateWorkers());
dispatch(({ type: "CONNECT", url, canRewind }: Action));
dispatch(({ type: "CONNECT", url, thread, canRewind }: Action));
};
}

Expand Down
8 changes: 5 additions & 3 deletions src/actions/pause/breakOnNext.js
Expand Up @@ -5,6 +5,7 @@
// @flow

import type { ThunkArgs } from "../types";
import { getCurrentThread } from "../../selectors";

/**
* Debugger breakOnNext command.
Expand All @@ -15,8 +16,9 @@ import type { ThunkArgs } from "../types";
* @static
*/
export function breakOnNext() {
return async ({ dispatch, client }: ThunkArgs) => {
await client.breakOnNext();
return dispatch({ type: "BREAK_ON_NEXT" });
return async ({ dispatch, getState, client }: ThunkArgs) => {
const thread = getCurrentThread(getState());
await client.breakOnNext(thread);
return dispatch({ type: "BREAK_ON_NEXT", thread });
};
}
22 changes: 19 additions & 3 deletions src/actions/pause/commands.js
Expand Up @@ -5,7 +5,12 @@

// @flow

import { isPaused, getSource, getTopFrame } from "../../selectors";
import {
isPaused,
getCurrentThread,
getSource,
getTopFrame
} from "../../selectors";
import { PROMISE } from "../utils/middleware/promise";
import { getNextStep } from "../../workers/parser";
import { addHiddenBreakpoint } from "../breakpoints";
Expand All @@ -16,6 +21,15 @@ import type { Source } from "../../types";
import type { ThunkArgs } from "../types";
import type { Command } from "../../reducers/types";

export function selectThread(thread: string) {
return async ({ dispatch, client }: ThunkArgs) => {
return dispatch({
type: "SELECT_THREAD",
thread
});
};
}

/**
* Debugger commands like stepOver, stepIn, stepUp
*
Expand All @@ -24,11 +38,13 @@ import type { Command } from "../../reducers/types";
* @static
*/
export function command(type: Command) {
return async ({ dispatch, client }: ThunkArgs) => {
return async ({ dispatch, getState, client }: ThunkArgs) => {
const thread = getCurrentThread(getState());
return dispatch({
type: "COMMAND",
command: type,
[PROMISE]: client[type]()
thread,
[PROMISE]: client[type](thread)
});
};
}
Expand Down
18 changes: 16 additions & 2 deletions src/actions/pause/extra.js
Expand Up @@ -4,7 +4,12 @@

// @flow

import { inComponent, getSelectedFrame } from "../../selectors";
import {
getCurrentThread,
getSource,
inComponent,
getSelectedFrame
} from "../../selectors";
import { isImmutablePreview } from "../../utils/preview";

import type { ThunkArgs } from "../types";
Expand Down Expand Up @@ -77,6 +82,7 @@ export function fetchExtra() {
const extra = await dispatch(getExtra("this;", frame.this));
dispatch({
type: "ADD_EXTRA",
thread: getCurrentThread(getState()),
extra: extra
});
};
Expand All @@ -89,8 +95,16 @@ export function getExtra(expression: string, result: Object) {
return {};
}

const source = getSource(getState(), selectedFrame.location.sourceId);
if (!source) {
return {};
}

const extra = await getExtraProps(getState, expression, result, expr =>
client.evaluateInFrame(expr, selectedFrame.id)
client.evaluateInFrame(expr, {
frameId: selectedFrame.id,
thread: source.thread
})
);

return extra;
Expand Down
7 changes: 6 additions & 1 deletion src/actions/pause/fetchScopes.js
Expand Up @@ -4,7 +4,11 @@

// @flow

import { getSelectedFrame, getGeneratedFrameScope } from "../../selectors";
import {
getCurrentThread,
getSelectedFrame,
getGeneratedFrameScope
} from "../../selectors";
import { mapScopes } from "./mapScopes";
import { PROMISE } from "../utils/middleware/promise";
import { fetchExtra } from "./extra";
Expand All @@ -19,6 +23,7 @@ export function fetchScopes() {

const scopes = dispatch({
type: "ADD_SCOPES",
thread: getCurrentThread(getState()),
frame,
[PROMISE]: client.getFrameScopes(frame)
});
Expand Down
1 change: 1 addition & 0 deletions src/actions/pause/index.js
Expand Up @@ -10,6 +10,7 @@
*/

export {
selectThread,
stepIn,
stepOver,
stepOut,
Expand Down
3 changes: 3 additions & 0 deletions src/actions/pause/mapFrames.js
Expand Up @@ -5,6 +5,7 @@
// @flow

import {
getCurrentThread,
getFrames,
getSymbols,
getSource,
Expand Down Expand Up @@ -170,9 +171,11 @@ export function mapFrames() {
mappedFrames = await expandFrames(mappedFrames, sourceMaps, getState);
mappedFrames = mapDisplayNames(mappedFrames, getState);

const thread = getCurrentThread(getState());
const selectedFrameId = getSelectedFrameId(getState(), mappedFrames);
dispatch({
type: "MAP_FRAMES",
thread,
frames: mappedFrames,
selectedFrameId
});
Expand Down
3 changes: 2 additions & 1 deletion src/actions/pause/mapScopes.js
Expand Up @@ -4,7 +4,7 @@

// @flow

import { getSource } from "../../selectors";
import { getCurrentThread, getSource } from "../../selectors";
import { loadSourceText } from "../sources/loadSourceText";
import { PROMISE } from "../utils/middleware/promise";

Expand All @@ -28,6 +28,7 @@ export function mapScopes(scopes: Promise<Scope>, frame: Frame) {

await dispatch({
type: "MAP_SCOPES",
thread: getCurrentThread(getState()),
frame,
[PROMISE]: (async function() {
if (
Expand Down
6 changes: 5 additions & 1 deletion src/actions/pause/pauseOnExceptions.js
Expand Up @@ -7,6 +7,7 @@
import { PROMISE } from "../utils/middleware/promise";
import { recordEvent } from "../../utils/telemetry";
import type { ThunkArgs } from "../types";
import { getCurrentThread } from "../../selectors";

/**
*
Expand All @@ -17,7 +18,7 @@ export function pauseOnExceptions(
shouldPauseOnExceptions: boolean,
shouldPauseOnCaughtExceptions: boolean
) {
return ({ dispatch, client }: ThunkArgs) => {
return ({ dispatch, getState, client }: ThunkArgs) => {
/* eslint-disable camelcase */
recordEvent("pause_on_exceptions", {
exceptions: shouldPauseOnExceptions,
Expand All @@ -26,11 +27,14 @@ export function pauseOnExceptions(
});
/* eslint-enable camelcase */

const thread = getCurrentThread(getState());
return dispatch({
type: "PAUSE_ON_EXCEPTIONS",
thread,
shouldPauseOnExceptions,
shouldPauseOnCaughtExceptions,
[PROMISE]: client.pauseOnExceptions(
thread,
shouldPauseOnExceptions,
shouldPauseOnCaughtExceptions
)
Expand Down
3 changes: 2 additions & 1 deletion src/actions/pause/paused.js
Expand Up @@ -38,7 +38,7 @@ async function getOriginalSourceForFrame(state, frame: Frame) {
*/
export function paused(pauseInfo: Pause) {
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
const { frames, why, loadedObjects } = pauseInfo;
const { thread, frames, why, loadedObjects } = pauseInfo;
const topFrame = frames.length > 0 ? frames[0] : null;

// NOTE: do not step when leaving a frame or paused at a debugger statement
Expand All @@ -57,6 +57,7 @@ export function paused(pauseInfo: Pause) {

dispatch({
type: "PAUSED",
thread,
why,
frames,
selectedFrameId: topFrame ? topFrame.id : undefined,
Expand Down
5 changes: 3 additions & 2 deletions src/actions/pause/resumed.js
Expand Up @@ -4,7 +4,7 @@

// @flow

import { isStepping, getPauseReason } from "../../selectors";
import { getCurrentThread, isStepping, getPauseReason } from "../../selectors";
import { evaluateExpressions } from "../expressions";
import { inDebuggerEval } from "../../utils/pause";

Expand All @@ -21,8 +21,9 @@ export function resumed() {
const why = getPauseReason(getState());
const wasPausedInEval = inDebuggerEval(why);
const wasStepping = isStepping(getState());
const thread = getCurrentThread(getState());

dispatch({ type: "RESUME" });
dispatch({ type: "RESUME", thread });

if (!wasStepping && !wasPausedInEval) {
await dispatch(evaluateExpressions());
Expand Down
2 changes: 2 additions & 0 deletions src/actions/pause/selectFrame.js
Expand Up @@ -7,6 +7,7 @@
import { selectLocation } from "../sources";
import { evaluateExpressions } from "../expressions";
import { fetchScopes } from "./fetchScopes";
import { getCurrentThread } from "../../selectors";

import type { Frame } from "../../types";
import type { ThunkArgs } from "../types";
Expand All @@ -19,6 +20,7 @@ export function selectFrame(frame: Frame) {
return async ({ dispatch, client, getState, sourceMaps }: ThunkArgs) => {
dispatch({
type: "SELECT_FRAME",
thread: getCurrentThread(getState()),
frame
});

Expand Down
4 changes: 3 additions & 1 deletion src/actions/pause/setPopupObjectProperties.js
Expand Up @@ -4,7 +4,7 @@

// @flow

import { getPopupObjectProperties } from "../../selectors";
import { getCurrentThread, getPopupObjectProperties } from "../../selectors";
import type { ThunkArgs } from "../types";

/**
Expand All @@ -19,8 +19,10 @@ export function setPopupObjectProperties(object: any, properties: Object) {
return;
}

const thread = getCurrentThread(getState());
dispatch({
type: "SET_POPUP_OBJECT_PROPERTIES",
thread,
objectId,
properties
});
Expand Down
7 changes: 4 additions & 3 deletions src/actions/pause/skipPausing.js
Expand Up @@ -5,16 +5,17 @@
// @flow

import type { ThunkArgs } from "../types";
import { getSkipPausing } from "../../selectors";
import { getSkipPausing, getCurrentThread } from "../../selectors";

/**
* @memberof actions/pause
* @static
*/
export function toggleSkipPausing() {
return async ({ dispatch, client, getState, sourceMaps }: ThunkArgs) => {
const thread = getCurrentThread(getState());
const skipPausing = !getSkipPausing(getState());
await client.setSkipPausing(skipPausing);
dispatch({ type: "TOGGLE_SKIP_PAUSING", skipPausing });
await client.setSkipPausing(thread, skipPausing);
dispatch({ type: "TOGGLE_SKIP_PAUSING", thread, skipPausing });
};
}
1 change: 1 addition & 0 deletions src/actions/pause/tests/pause.spec.js
Expand Up @@ -76,6 +76,7 @@ function createPauseInfo(
frameOpts = {}
) {
return {
thread: "FakeThread",
frames: [
makeFrame(
{ id: mockFrameId, sourceId: frameLocation.sourceId },
Expand Down
8 changes: 4 additions & 4 deletions src/actions/preview.js
Expand Up @@ -100,10 +100,10 @@ export function setPreview(
return;
}

const { result } = await client.evaluateInFrame(
expression,
selectedFrame.id
);
const { result } = await client.evaluateInFrame(expression, {
frameId: selectedFrame.id,
thread: source.thread
});

if (result === undefined) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/actions/sources/newSources.js
Expand Up @@ -40,6 +40,7 @@ function createOriginalSource(
url: originalUrl,
relativeUrl: originalUrl,
id: generatedToOriginalId(generatedSource.id, originalUrl),
thread: "",
isPrettyPrinted: false,
isWasm: false,
isBlackBoxed: false,
Expand Down

0 comments on commit 54bd024

Please sign in to comment.