tor-browser

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

browser_heading.js (2002B)


      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 /**
      8 * Test whether line break code in text content will be removed
      9 * and extra whitespaces will be trimmed.
     10 */
     11 addAccessibleTask(
     12  `
     13  <h1 id="single-line-content">We’re building a richer search experience</h1>
     14  <h1 id="multi-lines-content">
     15 We’re building a
     16 richest
     17 search experience
     18  </h1>
     19  `,
     20  async (browser, accDoc) => {
     21    const singleLineContentHeading = getNativeInterface(
     22      accDoc,
     23      "single-line-content"
     24    );
     25    is(
     26      singleLineContentHeading.getAttributeValue("AXTitle"),
     27      "We’re building a richer search experience"
     28    );
     29 
     30    const multiLinesContentHeading = getNativeInterface(
     31      accDoc,
     32      "multi-lines-content"
     33    );
     34    is(
     35      multiLinesContentHeading.getAttributeValue("AXTitle"),
     36      "We’re building a richest search experience"
     37    );
     38  }
     39 );
     40 
     41 /**
     42 * Test AXTitle/AXDescription attributes of heading elements
     43 */
     44 addAccessibleTask(
     45  `
     46  <h1 id="a">Hello <a href="#">world</a></h1>
     47  <h1 id="b">Hello</h1>
     48  <h1 id="c" aria-label="Goodbye">Hello</h1>
     49  `,
     50  async (browser, accDoc) => {
     51    const a = getNativeInterface(accDoc, "a");
     52    is(
     53      a.getAttributeValue("AXTitle"),
     54      "Hello world",
     55      "Correct AXTitle for 'a'"
     56    );
     57    ok(
     58      !a.getAttributeValue("AXDescription"),
     59      "'a' Should not have AXDescription"
     60    );
     61 
     62    const b = getNativeInterface(accDoc, "b");
     63    is(b.getAttributeValue("AXTitle"), "Hello", "Correct AXTitle for 'b'");
     64    ok(
     65      !b.getAttributeValue("AXDescription"),
     66      "'b' Should not have AXDescription"
     67    );
     68 
     69    const c = getNativeInterface(accDoc, "c");
     70    is(
     71      c.getAttributeValue("AXDescription"),
     72      "Goodbye",
     73      "Correct AXDescription for 'c'"
     74    );
     75    ok(!c.getAttributeValue("AXTitle"), "'c' Should not have AXTitle");
     76  }
     77 );