accessible/tests/mochitest/treeupdate/test_textleaf.html

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:754c0df078ac
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 textLeafUpdate(aID, aIsTextLeafLinkable)
26 {
27 this.node = getNode(aID);
28
29 this.eventSeq = [
30 new invokerChecker(EVENT_REORDER, this.node.parentNode)
31 ];
32
33 this.finalCheck = function textLeafUpdate_finalCheck()
34 {
35 var textLeaf = getAccessible(this.node).firstChild;
36 is(textLeaf.actionCount, (aIsTextLeafLinkable ? 1 : 0),
37 "Wrong action numbers!");
38 }
39 }
40
41 function setOnClickAttr(aID)
42 {
43 this.__proto__ = new textLeafUpdate(aID, true);
44
45 this.invoke = function setOnClickAttr_invoke()
46 {
47 this.node.setAttribute("onclick", "alert(3);");
48 }
49
50 this.getID = function setOnClickAttr_getID()
51 {
52 return "make " + prettyName(aID) + " linkable";
53 }
54 }
55
56 function removeOnClickAttr(aID)
57 {
58 this.__proto__ = new textLeafUpdate(aID, false);
59
60 this.invoke = function removeOnClickAttr_invoke()
61 {
62 this.node.removeAttribute("onclick");
63 }
64
65 this.getID = function removeOnClickAttr_getID()
66 {
67 return "unmake " + prettyName(aID) + " linkable";
68 }
69 }
70
71 function setOnClickNRoleAttrs(aID)
72 {
73 this.__proto__ = new textLeafUpdate(aID, true);
74
75 this.invoke = function setOnClickAttr_invoke()
76 {
77 this.node.setAttribute("role", "link");
78 this.node.setAttribute("onclick", "alert(3);");
79 }
80
81 this.getID = function setOnClickAttr_getID()
82 {
83 return "make " + prettyName(aID) + " linkable";
84 }
85 }
86
87 function removeTextData(aID)
88 {
89 this.containerNode = getNode(aID);
90 this.textNode = this.containerNode.firstChild;
91
92 this.eventSeq = [
93 new invokerChecker(EVENT_REORDER, this.containerNode)
94 ];
95
96 this.invoke = function removeTextData_invoke()
97 {
98 var tree = {
99 role: ROLE_PARAGRAPH,
100 children: [
101 {
102 role: ROLE_TEXT_LEAF,
103 name: "text"
104 }
105 ]
106 };
107 testAccessibleTree(this.containerNode, tree);
108
109 this.textNode.data = "";
110 }
111
112 this.finalCheck = function removeTextData_finalCheck()
113 {
114 var tree = {
115 role: ROLE_PARAGRAPH,
116 children: []
117 };
118 testAccessibleTree(this.containerNode, tree);
119 }
120
121 this.getID = function removeTextData_finalCheck()
122 {
123 return "remove text data of text node inside '" + aID + "'.";
124 }
125 }
126
127 ////////////////////////////////////////////////////////////////////////////
128 // Test
129
130 //gA11yEventDumpID = "eventdump"; // debug stuff
131 //gA11yEventDumpToConsole = true;
132
133 var gQueue = null;
134
135 function doTest()
136 {
137 gQueue = new eventQueue();
138
139 // adds onclick on element, text leaf should inherit its action
140 gQueue.push(new setOnClickAttr("div"));
141
142 // remove onclick attribute, text leaf shouldn't have any action
143 gQueue.push(new removeOnClickAttr("div"));
144
145 // set onclick attribute making span accessible, it's inserted into tree
146 // and adopts text leaf accessible, text leaf should have an action
147 gQueue.push(new setOnClickNRoleAttrs("span"));
148
149 // text data removal of text node should remove its text accessible
150 gQueue.push(new removeTextData("p"));
151 gQueue.push(new removeTextData("pre"));
152
153 gQueue.invoke(); // SimpleTest.finish() will be called in the end
154 }
155
156 SimpleTest.waitForExplicitFinish();
157 addA11yLoadEvent(doTest);
158 </script>
159 </head>
160 <body>
161
162 <a target="_blank"
163 title="Clean up the code of accessible initialization and binding to the tree"
164 href="https://bugzilla.mozilla.org/show_bug.cgi?id=545465">
165 Mozilla Bug 545465
166 </a>
167 <a target="_blank"
168 title="Make sure accessible tree is correct when rendered text is changed"
169 href="https://bugzilla.mozilla.org/show_bug.cgi?id=625652">
170 Mozilla Bug 625652
171 </a>
172 <a target="_blank"
173 title="Remove text accesible getting no text inside a preformatted area"
174 href="https://bugzilla.mozilla.org/show_bug.cgi?id=706335">
175 Mozilla Bug 706335
176 </a>
177
178 <p id="display"></p>
179 <div id="content" style="display: none"></div>
180 <pre id="test">
181 </pre>
182
183 <div id="container">
184 <div id="div">div</div>
185 <span id="span">span</span>
186 </div>
187
188 <p id="p">text</p>
189 <pre id="pre">text</pre>
190
191 <div id="eventdump"></div>
192 </body>
193 </html>

mercurial