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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
<!DOCTYPE html>
<html>
<head>
<title>Test accessible recreation</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
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="../events.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
// Invokers
function recreateAccessible(aID, aWontBeAccessible)
{
this.node = getNode(aID);
this.accessible =
isAccessible(this.node) ? getAccessible(this.node) : null;
this.eventSeq = [ ];
if (this.accessible)
this.eventSeq.push(new invokerChecker(EVENT_HIDE,
this.accessible));
if (!aWontBeAccessible)
this.eventSeq.push(new invokerChecker(EVENT_SHOW, getAccessible,
this.node));
this.eventSeq.push(new invokerChecker(EVENT_REORDER,
getContainerAccessible(this.node)));
if (this.accessible) {
this.unexpectedEventSeq = [
new invokerChecker(EVENT_SHOW, this.accessible)
];
}
}
function changeAttr(aID, aAttr, aValue)
{
this.__proto__ = new recreateAccessible(aID);
this.invoke = function changeAttr_invoke()
{
this.node.setAttribute(aAttr, aValue);
}
this.getID = function changeAttr_getID()
{
return "change " + aAttr + "attribute for " + aID;
}
}
function removeAttr(aID, aAttr)
{
this.__proto__ = new recreateAccessible(aID, true);
this.invoke = function remvoeAttr_invoke()
{
this.node.removeAttribute(aAttr);
}
this.getID = function remvoeAttr_getID()
{
return "remove " + aAttr + "attribute for " + aID;
}
}
function changeRole(aID, aHasAccessible)
{
this.__proto__ = new changeAttr(aID, "role", "button");
}
function removeRole(aID)
{
this.__proto__ = new removeAttr(aID, "role");
}
function changeHref(aID)
{
this.__proto__ = new changeAttr(aID, "href", "www");
}
function changeMultiselectable(aID)
{
this.__proto__ = new changeAttr(aID, "aria-multiselectable", "true");
}
////////////////////////////////////////////////////////////////////////////
// Test
//gA11yEventDumpID = "eventdump"; // debug stuff
//gA11yEventDumpToConsole = true;
var gQueue = null;
function doTest()
{
gQueue = new eventQueue();
// make the accessible an inaccessible
gQueue.push(new changeRole("span"));
// make the inaccessible an accessible
gQueue.push(new removeRole("span"));
// recreate an accessible by role change
gQueue.push(new changeRole("div1"));
// recreate an accessible by href change
gQueue.push(new changeHref("anchor"));
// recreate an accessible by aria-multiselectable change
gQueue.push(new changeMultiselectable("div3"));
gQueue.invoke(); // SimpleTest.finish() will be called in the end
}
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>
<span id="span">span</span>
<div id="div1">div</div>
<a id="anchor">anchor</a>
<div id="div3" role="listbox">list</div>
<div id="eventdump"></div>
</body>
</html>
|