summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_sidebar_scroll.js
blob: 29fd3d491bc377debeae3720e7edbc1e4cba42be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Test that the sidebar can be scrolled.

"use strict";

const TEST_URI = `data:text/html;charset=utf8,<!DOCTYPE html>Test sidebar scroll`;

add_task(async function () {
  // Should be removed when sidebar work is complete
  await pushPref("devtools.webconsole.sidebarToggle", true);
  const isMacOS = Services.appinfo.OS === "Darwin";

  const hud = await openNewTabAndConsole(TEST_URI);

  const onMessage = waitForMessageByType(hud, "Document", ".console-api");
  SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
    content.wrappedJSObject.console.log(content.wrappedJSObject.document);
  });

  const { node } = await onMessage;
  const object = node.querySelector(".object-inspector .node");

  info("Ctrl+click on an object to put it in the sidebar");
  const onSidebarShown = waitFor(() =>
    hud.ui.document.querySelector(".sidebar")
  );
  AccessibilityUtils.setEnv({
    // Component that renders a node handles keyboard interactions on the
    // container level.
    focusableRule: false,
    interactiveRule: false,
    labelRule: false,
  });
  EventUtils.sendMouseEvent(
    {
      type: "click",
      [isMacOS ? "metaKey" : "ctrlKey"]: true,
    },
    object,
    hud.ui.window
  );
  AccessibilityUtils.resetEnv();
  await onSidebarShown;
  const sidebarContents = hud.ui.document.querySelector(".sidebar-contents");

  // Let's wait until the object is fully expanded.
  await waitFor(() => sidebarContents.querySelectorAll(".node").length > 1);
  Assert.greater(
    sidebarContents.scrollHeight,
    sidebarContents.clientHeight,
    "Sidebar overflows"
  );
});