summaryrefslogtreecommitdiffstats
path: root/accessible/tests/browser/mac/browser_aria_current.js
blob: 02c7a71b67b7d451862da791c5d33b09f5592dbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

/* import-globals-from ../../mochitest/role.js */
/* import-globals-from ../../mochitest/states.js */
loadScripts(
  { name: "role.js", dir: MOCHITESTS_DIR },
  { name: "states.js", dir: MOCHITESTS_DIR }
);

/**
 * Test aria-current
 */
addAccessibleTask(
  `<a id="one" href="%23" aria-current="page">One</a><a id="two" href="%23">Two</a>`,
  async (browser, accDoc) => {
    let one = getNativeInterface(accDoc, "one");
    let two = getNativeInterface(accDoc, "two");

    is(
      one.getAttributeValue("AXARIACurrent"),
      "page",
      "Correct aria-current for #one"
    );
    is(
      two.getAttributeValue("AXARIACurrent"),
      null,
      "Correct aria-current for #two"
    );

    await SpecialPowers.spawn(browser, [], () => {
      content.document
        .getElementById("one")
        .setAttribute("aria-current", "step");
    });

    is(
      one.getAttributeValue("AXARIACurrent"),
      "step",
      "Correct aria-current for #one"
    );

    let stateChanged = waitForEvent(EVENT_STATE_CHANGE, "one");
    await SpecialPowers.spawn(browser, [], () => {
      content.document.getElementById("one").removeAttribute("aria-current");
    });
    await stateChanged;

    is(
      one.getAttributeValue("AXARIACurrent"),
      null,
      "Correct aria-current for #one"
    );
  }
);