tor-browser

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

browser_dbg-expressions-focus.js (1768B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 // Ensures the input is displayed and focused when "+" is clicked
      6 
      7 "use strict";
      8 
      9 add_task(async function () {
     10  // Start with the watch expression panel open
     11  await pushPref("devtools.debugger.expressions-visible", true);
     12  const dbg = await initDebugger("doc-script-switching.html");
     13 
     14  const watchExpressionHeaderEl = findElement(dbg, "watchExpressionsHeader");
     15  is(
     16    watchExpressionHeaderEl.tagName,
     17    "BUTTON",
     18    "The accordion toggle is a proper button"
     19  );
     20  is(
     21    watchExpressionHeaderEl.getAttribute("aria-expanded"),
     22    "true",
     23    "The accordion toggle is properly marked as expanded"
     24  );
     25 
     26  info("Close the panel");
     27  clickDOMElement(dbg, watchExpressionHeaderEl);
     28  await waitFor(() =>
     29    watchExpressionHeaderEl.getAttribute("aria-expanded", "false")
     30  );
     31  ok(true, "The accordion toggle is properly marked as collapsed");
     32 
     33  info("Click + to add the new expression");
     34  await waitForElement(dbg, "watchExpressionsAddButton");
     35  clickElement(dbg, "watchExpressionsAddButton");
     36 
     37  await waitFor(() =>
     38    watchExpressionHeaderEl.getAttribute("aria-expanded", "true")
     39  );
     40  ok(true, "The accordion toggle is properly marked as expanded again");
     41 
     42  info("Check that the input element gets focused");
     43  await waitForElementWithSelector(
     44    dbg,
     45    ".expression-input-container:has(input:focus)"
     46  );
     47  ok(true, "Found the expression input container, with the input focused");
     48  is(
     49    dbg.win.document.activeElement.classList.contains("input-expression"),
     50    true,
     51    "The active element is the watch expression input"
     52  );
     53 });