summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/actions/pause/selectFrame.js
blob: f97be42787d4e70133dc8fbac5faf6dd8115ec95 (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
38
39
/* 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";
import { evaluateExpressions } from "../expressions";
import { fetchScopes } from "./fetchScopes";
import assert from "../../utils/assert";

/**
 * @memberof actions/pause
 * @static
 */
export function selectFrame(cx, frame) {
  return async ({ dispatch, getState }) => {
    assert(cx.thread == frame.thread, "Thread mismatch");

    // 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(cx, frame.location));
      return;
    }

    dispatch({
      type: "SELECT_FRAME",
      cx,
      thread: cx.thread,
      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(cx, frame.location));

    dispatch(evaluateExpressions(cx));
    dispatch(fetchScopes(cx));
  };
}