tor-browser

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

browser_invalid.js (1721B)


      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 /* import-globals-from ../../mochitest/states.js */
      8 loadScripts({ name: "states.js", dir: MOCHITESTS_DIR });
      9 
     10 /**
     11 * Test invalid state and aria-invalid attribute on a checkbox.
     12 */
     13 addAccessibleTask(
     14  `
     15  <form>
     16    <input type="checkbox" required id="box"><label for="box">I am required
     17  </form>
     18   `,
     19  async (browser, accDoc) => {
     20    // Check initial AXInvalid values are correct
     21    let box = getNativeInterface(accDoc, "box");
     22    // XXX: bug 1967000
     23    await untilCacheOk(() => {
     24      return box.getAttributeValue("AXInvalid") == "true";
     25    }, "Correct invalid value for box");
     26 
     27    // Remove required attr, verify AXInvalid is updated
     28    let stateChanged = waitForEvent(EVENT_STATE_CHANGE, "box");
     29    await SpecialPowers.spawn(browser, [], () => {
     30      content.document.getElementById("box").removeAttribute("required");
     31    });
     32    await stateChanged;
     33 
     34    await untilCacheOk(() => {
     35      return box.getAttributeValue("AXInvalid") == "false";
     36    }, "Correct invalid value after required attr removed");
     37 
     38    // Remove add aria-invliad attr, verify AXInvalid is updated
     39    stateChanged = waitForEvent(EVENT_STATE_CHANGE, "box");
     40    await SpecialPowers.spawn(browser, [], () => {
     41      content.document
     42        .getElementById("box")
     43        .setAttribute("aria-invalid", "true");
     44    });
     45    await stateChanged;
     46 
     47    await untilCacheOk(() => {
     48      return box.getAttributeValue("AXInvalid") == "true";
     49    }, "Correct invalid value after aria-invalid attr set to true");
     50  }
     51 );