accessible/tests/mochitest/treeupdate/test_recreation.html

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:a34b0ee6e232
1 <!DOCTYPE html>
2 <html>
3
4 <head>
5 <title>Test accessible recreation</title>
6
7 <link rel="stylesheet" type="text/css"
8 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
9
10 <script type="application/javascript"
11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
12
13 <script type="application/javascript"
14 src="../common.js"></script>
15 <script type="application/javascript"
16 src="../role.js"></script>
17 <script type="application/javascript"
18 src="../events.js"></script>
19
20 <script type="application/javascript">
21
22 ////////////////////////////////////////////////////////////////////////////
23 // Invokers
24
25 function recreateAccessible(aID, aWontBeAccessible)
26 {
27 this.node = getNode(aID);
28 this.accessible =
29 isAccessible(this.node) ? getAccessible(this.node) : null;
30
31 this.eventSeq = [ ];
32
33 if (this.accessible)
34 this.eventSeq.push(new invokerChecker(EVENT_HIDE,
35 this.accessible));
36
37 if (!aWontBeAccessible)
38 this.eventSeq.push(new invokerChecker(EVENT_SHOW, getAccessible,
39 this.node));
40
41 this.eventSeq.push(new invokerChecker(EVENT_REORDER,
42 getContainerAccessible(this.node)));
43
44 if (this.accessible) {
45 this.unexpectedEventSeq = [
46 new invokerChecker(EVENT_SHOW, this.accessible)
47 ];
48 }
49 }
50
51 function changeAttr(aID, aAttr, aValue)
52 {
53 this.__proto__ = new recreateAccessible(aID);
54
55 this.invoke = function changeAttr_invoke()
56 {
57 this.node.setAttribute(aAttr, aValue);
58 }
59
60 this.getID = function changeAttr_getID()
61 {
62 return "change " + aAttr + "attribute for " + aID;
63 }
64 }
65
66 function removeAttr(aID, aAttr)
67 {
68 this.__proto__ = new recreateAccessible(aID, true);
69
70 this.invoke = function remvoeAttr_invoke()
71 {
72 this.node.removeAttribute(aAttr);
73 }
74
75 this.getID = function remvoeAttr_getID()
76 {
77 return "remove " + aAttr + "attribute for " + aID;
78 }
79 }
80
81 function changeRole(aID, aHasAccessible)
82 {
83 this.__proto__ = new changeAttr(aID, "role", "button");
84 }
85
86 function removeRole(aID)
87 {
88 this.__proto__ = new removeAttr(aID, "role");
89 }
90
91 function changeOnclick(aID)
92 {
93 this.__proto__ = new changeAttr(aID, "onclick", "alert(3);");
94 }
95
96 function changeHref(aID)
97 {
98 this.__proto__ = new changeAttr(aID, "href", "www");
99 }
100
101 function changeMultiselectable(aID)
102 {
103 this.__proto__ = new changeAttr(aID, "aria-multiselectable", "true");
104 }
105
106 ////////////////////////////////////////////////////////////////////////////
107 // Test
108
109 //gA11yEventDumpID = "eventdump"; // debug stuff
110 //gA11yEventDumpToConsole = true;
111
112 var gQueue = null;
113
114 function doTest()
115 {
116 gQueue = new eventQueue();
117
118 // make the accessible an inaccessible
119 gQueue.push(new changeRole("span"));
120
121 // make the inaccessible an accessible
122 gQueue.push(new removeRole("span"));
123
124 // recreate an accessible by role change
125 gQueue.push(new changeRole("div1"));
126
127 // recreate an accessible by onclick change
128 gQueue.push(new changeOnclick("div2"));
129
130 // recreate an accessible by href change
131 gQueue.push(new changeHref("anchor"));
132
133 // recreate an accessible by aria-multiselectable change
134 gQueue.push(new changeMultiselectable("div3"));
135
136 gQueue.invoke(); // SimpleTest.finish() will be called in the end
137 }
138
139 SimpleTest.waitForExplicitFinish();
140 addA11yLoadEvent(doTest);
141 </script>
142 </head>
143 <body>
144
145 <a target="_blank"
146 title="Rework accessible tree update code"
147 href="https://bugzilla.mozilla.org/show_bug.cgi?id=570275">
148 Mozilla Bug 570275
149 </a>
150
151 <p id="display"></p>
152 <div id="content" style="display: none"></div>
153 <pre id="test">
154 </pre>
155
156 <span id="span">span</span>
157 <div id="div1">div</div>
158 <div id="div2">div</div>
159 <a id="anchor">anchor</a>
160 <div id="div3" role="listbox">list</div>
161
162 <div id="eventdump"></div>
163 </body>
164 </html>

mercurial