tor-browser

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

browser_inspector_pane-toggle-03.js (2117B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests that the 3 pane inspector toggle can render the middle and right panels of equal
      7 // sizes when the original sidebar can be doubled in width and be smaller than half the
      8 // toolbox's width in the BOTTOM host.
      9 
     10 const SIDEBAR_WIDTH = 200;
     11 
     12 add_task(async function () {
     13  info("Switch to 2 pane inspector to test the 3 pane toggle button behavior");
     14  await pushPref("devtools.inspector.three-pane-enabled", false);
     15 
     16  const { inspector } = await openInspectorForURL("about:blank");
     17  const { panelDoc: doc } = inspector;
     18  const button = doc.querySelector(".sidebar-toggle");
     19  const toolboxWidth = doc.getElementById("inspector-splitter-box").clientWidth;
     20 
     21  if (toolboxWidth < 600) {
     22    ok(true, "Can't run the full test because the toolbox width is too small.");
     23  } else {
     24    info("Set the sidebar width to 200px");
     25    inspector.splitBox.setState({ width: SIDEBAR_WIDTH });
     26 
     27    info("Click on the toggle button to toggle ON 3 pane inspector");
     28    let onRuleViewAdded = inspector.once("ruleview-added");
     29    EventUtils.synthesizeMouseAtCenter(
     30      button,
     31      {},
     32      inspector.panelDoc.defaultView
     33    );
     34    await onRuleViewAdded;
     35 
     36    info("Checking the sizes of the 3 pane inspector");
     37    let sidebarWidth = inspector.splitBox.state.width;
     38    const sidebarSplitBoxWidth =
     39      inspector.sidebarSplitBoxRef.current.state.width;
     40    is(sidebarWidth, SIDEBAR_WIDTH * 2, "Got correct main split box width");
     41    is(
     42      sidebarSplitBoxWidth,
     43      SIDEBAR_WIDTH,
     44      "Got correct sidebar split box width"
     45    );
     46 
     47    info("Click on the toggle button to toggle OFF the 3 pane inspector");
     48    onRuleViewAdded = inspector.once("ruleview-added");
     49    EventUtils.synthesizeMouseAtCenter(
     50      button,
     51      {},
     52      inspector.panelDoc.defaultView
     53    );
     54    await onRuleViewAdded;
     55 
     56    info("Checking the sidebar size of the 2 pane inspector");
     57    sidebarWidth = inspector.splitBox.state.width;
     58    is(sidebarWidth, SIDEBAR_WIDTH, "Got correct sidebar width");
     59  }
     60 });