tor-browser

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

browser_accessibility_sidebar.js (2243B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_URI = `<html>
      7  <head>
      8    <meta charset="utf-8"/>
      9    <title>Accessibility Panel Test</title>
     10  </head>
     11  <body></body>
     12 </html>`;
     13 
     14 /**
     15 * Test data has the format of:
     16 * {
     17 *   desc     {String}    description for better logging
     18 *   setup   {Function}  An optional setup that needs to be performed before
     19 *                        the state of the tree and the sidebar can be checked.
     20 *   expected {JSON}      An expected states for the tree and the sidebar.
     21 * }
     22 */
     23 const tests = [
     24  {
     25    desc: "Test the initial accessibility sidebar state.",
     26    expected: {
     27      sidebar: {
     28        name: "Accessibility Panel Test",
     29        role: "document",
     30        actions: [],
     31        value: "",
     32        description: "",
     33        keyboardShortcut: "",
     34        childCount: 0,
     35        indexInParent: 0,
     36        states: [
     37          // The focused state is an outdated state, since the toolbox should now
     38          // have the focus and not the content page. See Bug 1702709.
     39          "focused",
     40          "readonly",
     41          "focusable",
     42          "selectable text",
     43          "opaque",
     44          "enabled",
     45          "sensitive",
     46        ],
     47      },
     48    },
     49  },
     50  {
     51    desc: "Mark document as disabled for accessibility.",
     52    setup: async ({ browser }) =>
     53      SpecialPowers.spawn(browser, [], () =>
     54        content.document.body.setAttribute("aria-disabled", true)
     55      ),
     56    expected: {
     57      sidebar: {
     58        states: [
     59          "unavailable",
     60          "readonly",
     61          "focusable",
     62          "selectable text",
     63          "opaque",
     64        ],
     65      },
     66    },
     67  },
     68  {
     69    desc: "Append a new child to the document.",
     70    setup: async ({ browser }) =>
     71      SpecialPowers.spawn(browser, [], () => {
     72        const doc = content.document;
     73        const button = doc.createElement("button");
     74        button.textContent = "Press Me!";
     75        doc.body.appendChild(button);
     76      }),
     77    expected: {
     78      sidebar: {
     79        childCount: 1,
     80      },
     81    },
     82  },
     83 ];
     84 
     85 /**
     86 * Test that checks the Accessibility panel sidebar.
     87 */
     88 addA11yPanelTestsTask(tests, TEST_URI, "Test Accessibility panel sidebar.");