tor-browser

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

browser_accessibility_tree.js (1680B)


      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>
     12    <h1>Top level header</h1>
     13    <p>This is a paragraph.</p>
     14  </body>
     15 </html>`;
     16 
     17 /**
     18 * Test data has the format of:
     19 * {
     20 *   desc     {String}    description for better logging
     21 *   setup    {Function}  An optional setup that needs to be performed before
     22 *                        the state of the tree and the sidebar can be checked.
     23 *   expected {JSON}      An expected states for the tree and the sidebar.
     24 * }
     25 */
     26 const tests = [
     27  {
     28    desc: "Test the initial accessibility tree state.",
     29    expected: {
     30      tree: [
     31        {
     32          role: "document",
     33          name: `"Accessibility Panel Test"`,
     34        },
     35      ],
     36    },
     37  },
     38  {
     39    desc: "Expand first tree node.",
     40    setup: async ({ doc }) => toggleRow(doc, 0),
     41    expected: {
     42      tree: [
     43        {
     44          role: "document",
     45          name: `"Accessibility Panel Test"`,
     46        },
     47        {
     48          role: "heading",
     49          name: `"Top level header"`,
     50        },
     51        {
     52          role: "paragraph",
     53          name: `""`,
     54        },
     55      ],
     56    },
     57  },
     58  {
     59    desc: "Collapse first tree node.",
     60    setup: async ({ doc }) => toggleRow(doc, 0),
     61    expected: {
     62      tree: [
     63        {
     64          role: "document",
     65          name: `"Accessibility Panel Test"`,
     66        },
     67      ],
     68    },
     69  },
     70 ];
     71 
     72 /**
     73 * Simple test that checks content of the Accessibility panel tree.
     74 */
     75 addA11yPanelTestsTask(tests, TEST_URI, "Test Accessibility panel tree.");