summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/treeupdate/test_recreation.html
blob: d403b0890e0f80e7e6ee4af0b16b681d0b39db6f (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>

<head>
  <title>Test accessible recreation</title>

  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>
  <script type="application/javascript"
          src="../promisified-events.js"></script>

  <script type="application/javascript">

    async function doTest() {
      let events, msg;

      msg = "Assign a 'button' role to a span";
      events = waitForOrderedEvents(
        [[EVENT_HIDE], [EVENT_SHOW, "span"], [EVENT_REORDER, "container"]], msg);
      document.getElementById("span").setAttribute("role", "button");
      await events;

      msg = "Remove the 'button' role from a span";
      events = waitForOrderedEvents(
        [[EVENT_HIDE, "span"], [EVENT_SHOW], [EVENT_REORDER, "container"]], msg);
      document.getElementById("span").removeAttribute("role");
      await events;

      msg = "Assign a 'button' role to a div";
      events = waitForOrderedEvents(
        [[EVENT_HIDE, "div1"], [EVENT_SHOW, "div1"], [EVENT_REORDER, "container"]], msg);
      document.getElementById("div1").setAttribute("role", "button");
      await events;

      msg = "Change a password field to a text field";
      events = waitForOrderedEvents(
        [[EVENT_HIDE, "password"], [EVENT_SHOW, "password"], [EVENT_REORDER, "container"]], msg);
      document.getElementById("password").setAttribute("type", "text");
      await events;

      msg = "Change a text field to a password field";
      events = waitForOrderedEvents(
        [[EVENT_HIDE, "text"], [EVENT_SHOW, "text"], [EVENT_REORDER, "container"]], msg);
      document.getElementById("text").setAttribute("type", "password");
      await events;

      msg = "Add aria-label to a span";
      ok(!isAccessible("span2"), "span2 has no accessible");
      events = waitForOrderedEvents(
        [[EVENT_SHOW, "span2"], [EVENT_REORDER, "container"]], msg);
      document.getElementById("span2").setAttribute("aria-label", "label");
      await events;

      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>
</head>
<body>

  <a target="_blank"
     title="Rework accessible tree update code"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=570275">
    Mozilla Bug 570275
  </a>

  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <div id="container">
    <span id="span">span</span>
    <div id="div1">div</div>
    <a id="anchor">anchor</a>
    <div id="div3" role="listbox">list</div>
    <input type="password" id="password"/>
    <input type="text" id="text"/>
    <span id="span2"></span>
  </div>

  <div id="eventdump"></div>
</body>
</html>