Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created October 3, 2019 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonLaster/b763d594202c2ac0a10cad37a62b15de to your computer and use it in GitHub Desktop.
Save jasonLaster/b763d594202c2ac0a10cad37a62b15de to your computer and use it in GitHub Desktop.
diff --git a/devtools/client/debugger/src/actions/navigation.js b/devtools/client/debugger/src/actions/navigation.js
index a6ed37c7b03d..3e519cd071c2 100644
--- a/devtools/client/debugger/src/actions/navigation.js
+++ b/devtools/client/debugger/src/actions/navigation.js
@@ -48,7 +48,7 @@ export function willNavigate(event: Object) {
export function connect(
url: string,
actor: string,
- canRewind: boolean,
+ traits,
isWebExtension: boolean
) {
return async function({ dispatch }: ThunkArgs) {
@@ -62,7 +62,7 @@ export function connect(
type: "mainThread",
name: L10N.getStr("mainThread"),
},
- canRewind,
+ traits,
isWebExtension,
}: Action)
);
diff --git a/devtools/client/debugger/src/actions/sources/newSources.js b/devtools/client/debugger/src/actions/sources/newSources.js
index f10bbcf7aa3f..6fe2dd473605 100644
--- a/devtools/client/debugger/src/actions/sources/newSources.js
+++ b/devtools/client/debugger/src/actions/sources/newSources.js
@@ -291,7 +291,6 @@ export function newGeneratedSources(sourceInfo: Array<GeneratedSourceData>) {
getState,
client,
}: ThunkArgs): Promise<Array<Source>> => {
- const supportsWasm = client.hasWasmSupport();
const resultIds = [];
const newSourcesObj = {};
@@ -310,7 +309,7 @@ export function newGeneratedSources(sourceInfo: Array<GeneratedSourceData>) {
introductionUrl: source.introductionUrl,
introductionType: source.introductionType,
isBlackBoxed: false,
- isWasm: !!supportsWasm && source.introductionType === "wasm",
+ isWasm: !!supportsWasm(getState()) && source.introductionType === "wasm",
isExtension: (source.url && isUrlExtension(source.url)) || false,
};
}
diff --git a/devtools/client/debugger/src/client/firefox.js b/devtools/client/debugger/src/client/firefox.js
index d79c76f2b797..24db2e5033d5 100644
--- a/devtools/client/debugger/src/client/firefox.js
+++ b/devtools/client/debugger/src/client/firefox.js
@@ -25,14 +25,10 @@ export async function onConnect(connection: any, actions: Object) {
return;
}
- const supportsWasm =
- features.wasm && !!debuggerClient.mainRoot.traits.wasmBinarySource;
-
setupCommands({
threadFront,
tabTarget,
debuggerClient,
- supportsWasm,
});
setupEvents({ threadFront, tabTarget, actions, supportsWasm });
@@ -59,7 +55,7 @@ export async function onConnect(connection: any, actions: Object) {
await actions.connect(
tabTarget.url,
threadFront.actor,
- traits && traits.canRewind,
+ traits,
tabTarget.isWebExtension
);
diff --git a/devtools/client/debugger/src/client/firefox/commands.js b/devtools/client/debugger/src/client/firefox/commands.js
index 7daea96bc12e..0c7fe3b256b0 100644
--- a/devtools/client/debugger/src/client/firefox/commands.js
+++ b/devtools/client/debugger/src/client/firefox/commands.js
@@ -48,29 +48,22 @@ let debuggerClient: DebuggerClient;
let sourceActors: { [ActorId]: SourceId };
let breakpoints: { [string]: Object };
let eventBreakpoints: ?EventListenerActiveList;
-let supportsWasm: boolean;
type Dependencies = {
threadFront: ThreadFront,
tabTarget: Target,
debuggerClient: DebuggerClient,
- supportsWasm: boolean,
};
function setupCommands(dependencies: Dependencies) {
currentThreadFront = dependencies.threadFront;
currentTarget = dependencies.tabTarget;
debuggerClient = dependencies.debuggerClient;
- supportsWasm = dependencies.supportsWasm;
targets = { worker: {}, contentProcess: {} };
sourceActors = {};
breakpoints = {};
}
-function hasWasmSupport() {
- return supportsWasm;
-}
-
function createObjectClient(grip: Grip) {
return debuggerClient.createObjectClient(grip);
}
@@ -589,7 +582,6 @@ const clientCommands = {
setEventListenerBreakpoints,
getEventListenerBreakpointTypes,
detachWorkers,
- hasWasmSupport,
lookupTarget,
};
diff --git a/devtools/client/debugger/src/reducers/pause.js b/devtools/client/debugger/src/reducers/pause.js
index 226e20ca2881..ce271243e89b 100644
--- a/devtools/client/debugger/src/reducers/pause.js
+++ b/devtools/client/debugger/src/reducers/pause.js
@@ -91,7 +91,6 @@ type ThreadPauseState = {
export type PauseState = {
cx: Context,
threadcx: ThreadContext,
- canRewind: boolean,
threads: { [ThreadId]: ThreadPauseState },
skipPausing: boolean,
mapScopes: boolean,
@@ -113,7 +112,6 @@ function createPauseState(thread: ThreadId = "UnknownThread") {
},
previewLocation: null,
threads: {},
- canRewind: false,
skipPausing: prefs.skipPausing,
mapScopes: prefs.mapScopes,
shouldPauseOnExceptions: prefs.pauseOnExceptions,
@@ -136,7 +134,6 @@ const resumedPauseState = {
const createInitialPauseState = () => ({
...resumedPauseState,
isWaitingOnBreak: false,
- canRewind: false,
command: null,
lastCommand: null,
previousLocation: null,
@@ -279,7 +276,6 @@ function update(
case "CONNECT":
return {
...createPauseState(action.mainThread.actor),
- canRewind: action.canRewind,
};
case "PAUSE_ON_EXCEPTIONS": {
@@ -485,10 +481,6 @@ export function getShouldPauseOnCaughtExceptions(state: State) {
return state.pause.shouldPauseOnCaughtExceptions;
}
-export function getCanRewind(state: State) {
- return state.pause.canRewind;
-}
-
export function getFrames(state: State, thread: ThreadId) {
return getThreadPauseState(state.pause, thread).frames;
}
diff --git a/devtools/client/debugger/src/reducers/threads.js b/devtools/client/debugger/src/reducers/threads.js
index 4e2ae25635cd..b3bef6516f78 100644
--- a/devtools/client/debugger/src/reducers/threads.js
+++ b/devtools/client/debugger/src/reducers/threads.js
@@ -25,6 +25,7 @@ export type ThreadsState = {
export function initialThreadsState(): ThreadsState {
return {
threads: [],
+ traits: {},
mainThread: {
actor: "",
url: "",
@@ -44,6 +45,7 @@ export default function update(
return {
...state,
mainThread: action.mainThread,
+ traits, action.traits,
isWebExtension: action.isWebExtension,
};
case "INSERT_THREADS":
@@ -92,6 +94,16 @@ export const getAllThreads: Selector<Thread[]> = createSelector(
]
);
+
+export function getCanRewind(state: State) {
+ return state.threads.traits.canRewind;
+}
+
+export function supportsWasm(state: State) {
+ return features.wasm && state.threads.traits.wasmBinarySource;
+}
+
+
// checks if a path begins with a thread actor
// e.g "server1.conn0.child1/workerTarget22/context1/dbg-workers.glitch.me"
export function startsWithThreadActor(state: State, path: string) {
@@ -101,4 +113,8 @@ export function startsWithThreadActor(state: State, path: string) {
return match && match[1];
}
+
+
type OuterState = { threads: ThreadsState };
+
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment