tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

selectFrame.js (1260B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 import { selectLocation } from "../sources/index";
      6 import { evaluateExpressions } from "../expressions";
      7 import { fetchScopes } from "./fetchScopes";
      8 import { validateSelectedFrame } from "../../utils/context";
      9 
     10 /**
     11 * @memberof actions/pause
     12 * @static
     13 */
     14 export function selectFrame(frame) {
     15  return async ({ dispatch, getState }) => {
     16    // Frames that aren't on-stack do not support evalling and may not
     17    // have live inspectable scopes, so we do not allow selecting them.
     18    if (frame.state !== "on-stack") {
     19      dispatch(selectLocation(frame.location));
     20      return;
     21    }
     22 
     23    dispatch({
     24      type: "SELECT_FRAME",
     25      frame,
     26    });
     27 
     28    // It's important that we wait for selectLocation to finish because
     29    // we rely on the source being loaded.
     30    await dispatch(selectLocation(frame.location));
     31    validateSelectedFrame(getState(), frame);
     32 
     33    await dispatch(evaluateExpressions(frame));
     34    validateSelectedFrame(getState(), frame);
     35 
     36    await dispatch(fetchScopes());
     37    validateSelectedFrame(getState(), frame);
     38  };
     39 }