From d27ee059ffa4db943e9f3666511f4123bac912d0 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 17 Aug 2022 16:13:35 +0000 Subject: [PATCH] Bug 1783813 - [devtools] Unify debugger initialization and thread selection. r=bomsy We are updating more things when selecting a thread than when opening the debugger. Let's use a unique codepath when it comes to handle a new top level target. Differential Revision: https://phabricator.services.mozilla.com/D151552 --- .../client/debugger/src/actions/navigation.js | 16 +--------------- devtools/client/debugger/src/client/firefox.js | 11 ++++++----- devtools/client/debugger/src/reducers/pause.js | 5 ----- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/devtools/client/debugger/src/actions/navigation.js b/devtools/client/debugger/src/actions/navigation.js index 8cf194376725..afc33d9d1163 100644 --- a/devtools/client/debugger/src/actions/navigation.js +++ b/devtools/client/debugger/src/actions/navigation.js @@ -5,10 +5,8 @@ import { clearDocuments } from "../utils/editor"; import sourceQueue from "../utils/source-queue"; -import { evaluateExpressions } from "./expressions"; - import { clearWasmStates } from "../utils/wasm"; -import { getMainThread, getThreadContext } from "../selectors"; +import { getMainThread } from "../selectors"; /** * Redux actions for the navigation state @@ -35,18 +33,6 @@ export function willNavigate(event) { }; } -export function connect(url, actor) { - return async function({ dispatch, getState }) { - dispatch({ - type: "CONNECT", - mainThreadActorID: actor, - }); - - const cx = getThreadContext(getState()); - dispatch(evaluateExpressions(cx)); - }; -} - /** * @memberof actions/navigation * @static diff --git a/devtools/client/debugger/src/client/firefox.js b/devtools/client/debugger/src/client/firefox.js index 7c3736174ae6..c39b036bf7b3 100644 --- a/devtools/client/debugger/src/client/firefox.js +++ b/devtools/client/debugger/src/client/firefox.js @@ -8,6 +8,7 @@ import { features } from "../utils/prefs"; import { recordEvent } from "../utils/telemetry"; import sourceQueue from "../utils/source-queue"; +import { getContext } from "../selectors"; let actions; let commands; @@ -60,11 +61,11 @@ export async function onConnect(_commands, _resourceCommand, _actions, store) { }; await commands.threadConfigurationCommand.updateConfiguration(options); - // We should probably only pass descriptor informations from here - // so only pass if that's a WebExtension toolbox. - // And let actions.willNavigate/NAVIGATE pass the current/selected thread - // from onTargetAvailable - await actions.connect(targetFront.url, targetFront.threadFront.actor); + // Select the top level target by default + await actions.selectThread( + getContext(store.getState()), + targetFront.threadFront.actor + ); await targetCommand.watchTargets({ types: targetCommand.ALL_TYPES, diff --git a/devtools/client/debugger/src/reducers/pause.js b/devtools/client/debugger/src/reducers/pause.js index 944129dfa942..615d0c2b79e1 100644 --- a/devtools/client/debugger/src/reducers/pause.js +++ b/devtools/client/debugger/src/reducers/pause.js @@ -236,11 +236,6 @@ function update(state = initialPauseState(), action) { case "SELECT_FRAME": return updateThreadState({ selectedFrameId: action.frame.id }); - case "CONNECT": - return { - ...initialPauseState(action.mainThreadActorID), - }; - case "PAUSE_ON_EXCEPTIONS": { const { shouldPauseOnExceptions, shouldPauseOnCaughtExceptions } = action;