summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg-expressions-focus.js
blob: ad6bfae662b743da6a0f6f2be56a38185c789b04 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

// Ensures the input is displayed and focused when "+" is clicked

"use strict";

add_task(async function () {
  // Start with the watch expression panel open
  await pushPref("devtools.debugger.expressions-visible", true);
  const dbg = await initDebugger("doc-script-switching.html");

  const watchExpressionHeaderEl = findElement(dbg, "watchExpressionsHeader");
  is(
    watchExpressionHeaderEl.tagName,
    "BUTTON",
    "The accordion toggle is a proper button"
  );
  is(
    watchExpressionHeaderEl.getAttribute("aria-expanded"),
    "true",
    "The accordion toggle is properly marked as expanded"
  );

  info("Close the panel");
  clickDOMElement(dbg, watchExpressionHeaderEl);
  await waitFor(() =>
    watchExpressionHeaderEl.getAttribute("aria-expanded", "false")
  );
  ok(true, "The accordion toggle is properly marked as collapsed");

  info("Click + to add the new expression");
  await waitForElement(dbg, "watchExpressionsAddButton");
  clickElement(dbg, "watchExpressionsAddButton");

  await waitFor(() =>
    watchExpressionHeaderEl.getAttribute("aria-expanded", "true")
  );
  ok(true, "The accordion toggle is properly marked as expanded again");

  info("Check that the input element gets focused");
  await waitForElementWithSelector(dbg, ".expression-input-container.focused");
  ok(true, "Found the expression input container, with the focused class");
  is(
    dbg.win.document.activeElement.classList.contains("input-expression"),
    true,
    "The active element is the watch expression input"
  );
});