tor-browser

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

browser_net_error-boundary-01.js (1521B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 /**
      6 * Test that top-level net monitor error boundary catches child errors.
      7 */
      8 add_task(async function () {
      9  await pushPref("devtools.netmonitor.persistlog", true);
     10  const { monitor } = await initNetMonitor(SIMPLE_URL, {
     11    requestCount: 1,
     12  });
     13 
     14  const { store, windowRequire, document } = monitor.panelWin;
     15  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     16 
     17  store.dispatch(Actions.batchEnable(false));
     18 
     19  // Intentionally damage the store to cause a child component error
     20  const state = store.getState();
     21 
     22  // Do NOT nullify state.ui as it is used by the App.js component which is not
     23  // wrapped in the AppErrorBoundary component.
     24  // Do NOT nullify state.requests as it will just bypass rendering the requests
     25  // list.
     26  // requestBlocking should make the RequestListContent.js component throw when
     27  // rendering the new request sent right after.
     28  // In general, this test is very much linked to the specific implementation of
     29  // the components and might break if said implementation changes.
     30  state.requestBlocking = null;
     31 
     32  await SpecialPowers.spawn(gBrowser.selectedBrowser, [SIMPLE_URL], url => {
     33    content.fetch(url);
     34  });
     35 
     36  // Wait for the panel to fall back to the error UI
     37  const errorPanel = await waitUntil(() =>
     38    document.querySelector(".app-error-panel")
     39  );
     40 
     41  is(errorPanel, !undefined);
     42  return teardown(monitor);
     43 });