tor-browser

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

browser_rules_class_panel_toggle.js (2199B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that the class panel can be toggled.
      7 
      8 add_task(async function () {
      9  await addTab("data:text/html;charset=utf-8,<body class='class1 class2'>");
     10  const { inspector, view } = await openRuleView();
     11 
     12  info("Check that the toggle button exists");
     13  const button = inspector.panelDoc.querySelector("#class-panel-toggle");
     14  ok(button, "The class panel toggle button exists");
     15  is(view.classToggle, button, "The rule-view refers to the right element");
     16 
     17  info("Check that the panel exists and is hidden by default");
     18  const panel = inspector.panelDoc.querySelector("#ruleview-class-panel");
     19  ok(panel, "The class panel exists");
     20  is(view.classPanel, panel, "The rule-view refers to the right element");
     21  ok(panel.hasAttribute("hidden"), "The panel is hidden");
     22  is(
     23    button.getAttribute("aria-pressed"),
     24    "false",
     25    "The button is not pressed by default"
     26  );
     27  is(
     28    inspector.panelDoc.getElementById(button.getAttribute("aria-controls")),
     29    panel,
     30    "The class panel toggle button has valid aria-controls attribute"
     31  );
     32 
     33  info("Click on the button to show the panel");
     34  button.click();
     35  ok(!panel.hasAttribute("hidden"), "The panel is shown");
     36  is(button.getAttribute("aria-pressed"), "true", "The button is pressed");
     37 
     38  info("Click again to hide the panel");
     39  button.click();
     40  ok(panel.hasAttribute("hidden"), "The panel is hidden");
     41  is(button.getAttribute("aria-pressed"), "false", "The button is not pressed");
     42 
     43  info("Open the pseudo-class panel first, then the class panel");
     44  view.pseudoClassToggle.click();
     45  ok(
     46    !view.pseudoClassPanel.hasAttribute("hidden"),
     47    "The pseudo-class panel is shown"
     48  );
     49  button.click();
     50  ok(!panel.hasAttribute("hidden"), "The panel is shown");
     51  ok(
     52    view.pseudoClassPanel.hasAttribute("hidden"),
     53    "The pseudo-class panel is hidden"
     54  );
     55 
     56  info("Click again on the pseudo-class button");
     57  view.pseudoClassToggle.click();
     58  ok(panel.hasAttribute("hidden"), "The panel is hidden");
     59  ok(
     60    !view.pseudoClassPanel.hasAttribute("hidden"),
     61    "The pseudo-class panel is shown"
     62  );
     63 });