tor-browser

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

navigation.js (1515B)


      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 sourceQueue from "../utils/source-queue";
      6 import { getMainThread } from "../selectors/index";
      7 import { evaluateExpressionsForCurrentContext } from "../actions/expressions";
      8 import { getEditor } from "../utils/editor/index";
      9 
     10 /**
     11 * Redux actions for the navigation state
     12 *
     13 * @module actions/navigation
     14 */
     15 
     16 /**
     17 * @memberof actions/navigation
     18 * @static
     19 */
     20 export function willNavigate(event) {
     21  return async function ({ dispatch, getState, sourceMapLoader }) {
     22    sourceQueue.clear();
     23    sourceMapLoader.clearSourceMaps();
     24    const editor = getEditor();
     25    editor.clearSources();
     26    const thread = getMainThread(getState());
     27 
     28    dispatch({
     29      type: "NAVIGATE",
     30      mainThread: { ...thread, url: event.url },
     31    });
     32  };
     33 }
     34 
     35 /**
     36 * @memberof actions/navigation
     37 * @static
     38 */
     39 export function navigated() {
     40  return async function ({ dispatch, panel }) {
     41    try {
     42      // Update the watched expressions once the page is fully loaded
     43      await dispatch(evaluateExpressionsForCurrentContext());
     44    } catch (e) {
     45      // This may throw if we resume during the page load.
     46      // browser_dbg-debugger-buttons.js highlights this, especially on MacOS or when ran many times
     47      console.error("Failed to update expression on navigation", e);
     48    }
     49 
     50    panel.emit("reloaded");
     51  };
     52 }