summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/actions/pause/selectFrame.js
blob: 49ebacffe541d9e417132e831ecdabdde5f8bc1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

import { selectLocation } from "../sources/index";
import { evaluateExpressions } from "../expressions";
import { fetchScopes } from "./fetchScopes";
import { validateSelectedFrame } from "../../utils/context";

/**
 * @memberof actions/pause
 * @static
 */
export function selectFrame(frame) {
  return async ({ dispatch, getState }) => {
    // Frames that aren't on-stack do not support evalling and may not
    // have live inspectable scopes, so we do not allow selecting them.
    if (frame.state !== "on-stack") {
      dispatch(selectLocation(frame.location));
      return;
    }

    dispatch({
      type: "SELECT_FRAME",
      frame,
    });

    // It's important that we wait for selectLocation to finish because
    // we rely on the source being loaded and symbols fetched below.
    await dispatch(selectLocation(frame.location));
    validateSelectedFrame(getState(), frame);

    await dispatch(evaluateExpressions(frame));

    await dispatch(fetchScopes(frame));
  };
}