tor-browser

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

browser_computedARIARole.js (4444B)


      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 "use strict";
      6 
      7 addAccessibleTask(
      8  `
      9 <div id="ariaButton" role="button">ARIA button</div>
     10 <div id="ariaLog" role="log">ARIA log</div>
     11 <div id="ariaMain" role="main">ARIA main</div>
     12 <div id="ariaRegion" role="region" aria-label="ARIA region">ARIA region</div>
     13 <nav id="ariaUnnamedRegion" role="region">ARIA unnamed region</nav>
     14 <div id="ariaDirectory" role="directory">ARIA directory</div>
     15 <div id="ariaAlertdialog" role="alertdialog">ARIA alertdialog</div>
     16 <div id="ariaFeed" role="feed">ARIA feed</div>
     17 <div role="table">
     18  <div id="ariaRowgroup" role="rowgroup">ARIA rowgroup</div>
     19 </div>
     20 <div id="ariaSearchbox" role="searchbox">ARIA searchbox</div>
     21 <div id="ariaUnknown" role="unknown">unknown ARIA role</div>
     22 <div id="ariaFallbackUpperCase" role="REGION GROUP">unlabelled region with fallback to group, upper case</div>
     23 <button id="htmlButton">HTML button</button>
     24 <button id="toggleButton" aria-pressed="true">toggle button</button>
     25 <main id="htmlMain">HTML main</main>
     26 <header id="htmlHeader">HTML header</header>
     27 <section id="htmlSection">
     28  <header id="htmlSectionHeader">HTML header inside section</header>
     29 </section>
     30 <section id="htmlRegion" aria-label="HTML region">HTML region</section>
     31 <fieldset id="htmlFieldset">HTML fieldset</fieldset>
     32 <table>
     33  <tbody id="htmlTbody" tabindex="-1"><tr><th>HTML tbody</th></tr></tbody>
     34 </table>
     35 <table role="grid">
     36  <tr>
     37    <td id="htmlGridcell">HTML implicit gridcell</td>
     38  </tr>
     39 </table>
     40 <div id="htmlDiv">HTML div</div>
     41 <span id="htmlSpan" aria-label="HTML span">HTML span</span>
     42 <iframe id="iframe"></iframe>
     43  `,
     44  async function (browser, docAcc) {
     45    function testComputedARIARole(id, role) {
     46      const acc = findAccessibleChildByID(docAcc, id);
     47      is(acc.computedARIARole, role, `computedARIARole for ${id} is correct`);
     48    }
     49 
     50    testComputedARIARole("ariaButton", "button");
     51    testComputedARIARole("ariaLog", "log");
     52    // Landmarks map to a single Gecko role.
     53    testComputedARIARole("ariaMain", "main");
     54    testComputedARIARole("ariaRegion", "region");
     55    // Unnamed ARIA regions should ignore the ARIA role.
     56    testComputedARIARole("ariaUnnamedRegion", "navigation");
     57    // The directory ARIA role is an alias of list.
     58    testComputedARIARole("ariaDirectory", "list");
     59    // alertdialog, feed and rowgroupmap to a Gecko role, but it isn't unique.
     60    testComputedARIARole("ariaAlertdialog", "alertdialog");
     61    testComputedARIARole("ariaFeed", "feed");
     62    testComputedARIARole("ariaRowgroup", "rowgroup");
     63    testComputedARIARole("ariaSearchbox", "searchbox");
     64    testComputedARIARole("ariaUnknown", "generic");
     65    // XXX Ideally, ariaFallbackUpperCase would be tested in
     66    // testing/web-platform/tests/wai-aria/role/fallback-roles.html
     67    // However, it's unclear in the spec whether ARIA roles are intended to be
     68    // case insensitive or not, so we can't reasonably assume that in WPT until
     69    // that's cleared up. See https://github.com/w3c/aria/issues/2548.
     70    testComputedARIARole("ariaFallbackUpperCase", "group");
     71    testComputedARIARole("htmlButton", "button");
     72    // There is only a single ARIA role for buttons, but Gecko uses different
     73    // roles depending on states.
     74    testComputedARIARole("toggleButton", "button");
     75    testComputedARIARole("htmlMain", "main");
     76    testComputedARIARole("htmlHeader", "banner");
     77    // <section> only maps to the region ARIA role if it has a label.
     78    testComputedARIARole("htmlSection", "generic");
     79    // <header> only maps to the banner role if it is not a child of a
     80    // sectioning element.
     81    testComputedARIARole("htmlSectionHeader", "generic");
     82    testComputedARIARole("htmlRegion", "region");
     83    // Gecko doesn't have a rowgroup role. Ensure we differentiate for
     84    // computedARIARole.
     85    testComputedARIARole("htmlFieldset", "group");
     86    testComputedARIARole("htmlTbody", "rowgroup");
     87    // <td> inside <table role="grid"> implicitly maps to ARIA gridcell.
     88    testComputedARIARole("htmlGridcell", "gridcell");
     89    // Test generics.
     90    testComputedARIARole("htmlDiv", "generic");
     91    testComputedARIARole("htmlSpan", "generic");
     92    // Some roles can't be mapped to ARIA role tokens.
     93    testComputedARIARole("iframe", "");
     94  },
     95  { chrome: true, topLevel: true }
     96 );