tor-browser

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

browser_inspector_pane-toggle-04.js (1810B)


      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 button can render the bottom-left and
      7 // bottom-right panels of equal sizes in the SIDE 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, toolbox } = await openInspectorForURL("about:blank");
     14  const { panelDoc: doc } = inspector;
     15 
     16  info("Switch the host to the right");
     17  await toolbox.switchHost("right");
     18 
     19  // Switching hosts is not correctly waiting when DevTools run in content frame
     20  // See Bug 1571421.
     21  await wait(1000);
     22 
     23  const button = doc.querySelector(".sidebar-toggle");
     24  const toolboxWidth = doc.getElementById("inspector-splitter-box").clientWidth;
     25 
     26  info("Click on the toggle button to toggle ON 3 pane inspector");
     27  let onRuleViewAdded = inspector.once("ruleview-added");
     28  EventUtils.synthesizeMouseAtCenter(
     29    button,
     30    {},
     31    inspector.panelDoc.defaultView
     32  );
     33  await onRuleViewAdded;
     34 
     35  info("Checking the sizes of the 3 pane inspector");
     36  const sidebarSplitBoxWidth = inspector.sidebarSplitBoxRef.current.state.width;
     37  is(
     38    sidebarSplitBoxWidth,
     39    toolboxWidth / 2,
     40    "Got correct sidebar split box width"
     41  );
     42 
     43  info("Click on the toggle button to toggle OFF the 3 pane inspector");
     44  onRuleViewAdded = inspector.once("ruleview-added");
     45  EventUtils.synthesizeMouseAtCenter(
     46    button,
     47    {},
     48    inspector.panelDoc.defaultView
     49  );
     50  await onRuleViewAdded;
     51 
     52  info("Checking the sidebar size of the 2 pane inspector");
     53  const sidebarWidth = inspector.splitBox.state.width;
     54  is(sidebarWidth, toolboxWidth, "Got correct sidebar width");
     55 });