tor-browser

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

browser_webconsole_sidebar_scroll.js (1713B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Test that the sidebar can be scrolled.
      5 
      6 "use strict";
      7 
      8 const TEST_URI = `data:text/html;charset=utf8,<!DOCTYPE html>Test sidebar scroll`;
      9 
     10 add_task(async function () {
     11  // Should be removed when sidebar work is complete
     12  await pushPref("devtools.webconsole.sidebarToggle", true);
     13  const isMacOS = Services.appinfo.OS === "Darwin";
     14 
     15  const hud = await openNewTabAndConsole(TEST_URI);
     16 
     17  const onMessage = waitForMessageByType(hud, "Document", ".console-api");
     18  SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
     19    content.wrappedJSObject.console.log(content.wrappedJSObject.document);
     20  });
     21 
     22  const { node } = await onMessage;
     23  const object = node.querySelector(".object-inspector .node");
     24 
     25  info("Ctrl+click on an object to put it in the sidebar");
     26  const onSidebarShown = waitFor(() =>
     27    hud.ui.document.querySelector(".sidebar")
     28  );
     29  AccessibilityUtils.setEnv({
     30    // Component that renders a node handles keyboard interactions on the
     31    // container level.
     32    focusableRule: false,
     33    interactiveRule: false,
     34    labelRule: false,
     35  });
     36  EventUtils.sendMouseEvent(
     37    {
     38      type: "click",
     39      [isMacOS ? "metaKey" : "ctrlKey"]: true,
     40    },
     41    object,
     42    hud.ui.window
     43  );
     44  AccessibilityUtils.resetEnv();
     45  await onSidebarShown;
     46  const sidebarContents = hud.ui.document.querySelector(".sidebar-contents");
     47 
     48  // Let's wait until the object is fully expanded.
     49  await waitFor(() => sidebarContents.querySelectorAll(".node").length > 1);
     50  Assert.greater(
     51    sidebarContents.scrollHeight,
     52    sidebarContents.clientHeight,
     53    "Sidebar overflows"
     54  );
     55 });