tor-browser

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

browser_inspector_pane-toggle-02.js (2639B)


      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 toggle button can toggle on and off the inspector's 3 pane mode,
      7 // and the 3 panes rendered are all of equal widths in the BOTTOM host.
      8 
      9 add_task(async function () {
     10  info("Switch to 2 pane inspector to test the 3 pane toggle button behavior");
     11  await pushPref("devtools.inspector.three-pane-enabled", false);
     12 
     13  const { inspector } = await openInspectorForURL("about:blank");
     14  const { panelDoc: doc } = inspector;
     15  const button = doc.querySelector(".sidebar-toggle");
     16  const ruleViewSidebar =
     17    inspector.sidebarSplitBoxRef.current.startPanelContainer;
     18  const toolboxWidth = doc.getElementById("inspector-splitter-box").clientWidth;
     19 
     20  ok(
     21    button.classList.contains("pane-collapsed"),
     22    "The button is in collapsed state"
     23  );
     24 
     25  info("Click on the toggle button to toggle ON 3 pane inspector");
     26  let onRuleViewAdded = inspector.once("ruleview-added");
     27  EventUtils.synthesizeMouseAtCenter(
     28    button,
     29    {},
     30    inspector.panelDoc.defaultView
     31  );
     32  await onRuleViewAdded;
     33 
     34  info("Checking the state of the 3 pane inspector");
     35  let sidebarWidth = inspector.splitBox.state.width;
     36  const sidebarSplitBoxWidth = inspector.sidebarSplitBoxRef.current.state.width;
     37  ok(
     38    !button.classList.contains("pane-collapsed"),
     39    "The button is in expanded state"
     40  );
     41  ok(doc.getElementById("ruleview-panel"), "The rule view panel exist");
     42  is(
     43    inspector.sidebar.getCurrentTabID(),
     44    "layoutview",
     45    "Layout view is shown in the sidebar"
     46  );
     47  is(
     48    ruleViewSidebar.style.display,
     49    "block",
     50    "The split rule view sidebar is displayed"
     51  );
     52  is(sidebarWidth, (toolboxWidth * 2) / 3, "Got correct main split box width");
     53  is(
     54    sidebarSplitBoxWidth,
     55    toolboxWidth / 3,
     56    "Got correct sidebar split box width"
     57  );
     58 
     59  info("Click on the toggle button to toggle OFF the 3 pane inspector");
     60  onRuleViewAdded = inspector.once("ruleview-added");
     61  EventUtils.synthesizeMouseAtCenter(
     62    button,
     63    {},
     64    inspector.panelDoc.defaultView
     65  );
     66  await onRuleViewAdded;
     67 
     68  info("Checking the state of the 2 pane inspector");
     69  sidebarWidth = inspector.splitBox.state.width;
     70  ok(
     71    button.classList.contains("pane-collapsed"),
     72    "The button is in collapsed state"
     73  );
     74  is(
     75    inspector.sidebar.getCurrentTabID(),
     76    "ruleview",
     77    "Rule view is shown in the sidebar"
     78  );
     79  is(
     80    ruleViewSidebar.style.display,
     81    "none",
     82    "The split rule view sidebar is hidden"
     83  );
     84  is(sidebarWidth, sidebarSplitBoxWidth, "Got correct sidebar width");
     85 });