-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
224 lines (160 loc) · 8.24 KB
/
index.html
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en">
<head>
<title>ARIA live region tests</title>
<style>
.hidden { display: none; }
.notification { margin: 1em 0; padding: 1em; border: 1px solid #555; background: #eee; }
body { font-family: Helvetica, Arial, sans; }
h2 { margin-top: 1em; padding-top: 1em; border-top: 1px solid #bbb; }
h3 { margin-top: 0.5em; padding-top: 0.5em; }
</style>
</head>
<body>
<h1>ARIA live region tests</h1>
<p>Test page to verify current browser/screen reader behaviour for live regions - see <a href="https://github.com/w3c/aria/issues/2154" target=_blank>w3c/aria/issues/2154</a> for context.</p>
<p>Note that <code>role="alert"</code> is slightly "magic" and triggers an announcement even in cases where you generally don't expect it - see <a href="https://github.com/w3c/aria/issues/2153" target=_blank>w3c/aria/issues/2153</a>.</p>
<p>Does <em>not</em> include <code>role="marquee"</code> and <code>role="timer"</code> at this stage, as they have an intrinsic <code>aria-live="off"</code> and will require a different type of test - see <a href="https://github.com/w3c/aria/issues/2144" target=_blank>w3c/aria/issues/2144</a>.</p>
<p><small>Ported over from <a href="https://codepen.io/patrickhlauke/pen/zYbgvdL">codepen</a></small></p>
<p><a href="results.html">Test results 27/04/2024</a>.</p>
<h2>Already present on page load</h2>
<p>Load/reload codepen to verify if any of these get announced on page load.</p>
<div aria-live="polite" class="notification">
This is the <code><div aria-live="polite"></code> already present and populated on page load.
</div>
<div aria-live="assertive" class="notification">
This is the <code><div aria-live="assertive"></code> already present and populated on page load.
</div>
<div role="status" class="notification">
This is the <code><div role="status"></code> already present and populated on page load.
</div>
<div role="alert" class="notification">
This is the <code><div role="alert"></code> already present and populated on page load.
</div>
<div role="log" class="notification">
This is the <code><div role="log"></code> already present and populated on page load.
</div>
<h2>Flipping <code>display:none</code> on a fully-populated live region container</h2>
<h3>Fully populated generic <code><div aria-live="polite"></code></h3>
<button class="displayflip">Toggle</button>
<div aria-live="polite" class="notification hidden">
This is the <code><div aria-live="polite"></code> made visible.
</div>
<h3>Fully populated generic <code><div aria-live="assertive"></code></h3>
<button class="displayflip">Toggle</button>
<div aria-live="assertive" class="notification hidden">
This is the <code><div aria-live="assertive"></code> made visible.
</div>
<h3>Fully populated <code><div role="status"></code></h3>
<button class="displayflip">Toggle</button>
<div role="status" class="notification hidden">
This is the <code><div role="status"></code> made visible.
</div>
<h3>Fully populated <code><div role="alert"></code></h3>
<button class="displayflip">Toggle</button>
<div role="alert" class="notification hidden">
This is the <code><div role="alert"></code> made visible.
</div>
<h3>Fully populated <code><div role="log"></code></h3>
<button class="displayflip">Toggle</button>
<div role="log" class="notification hidden">
This is the <code><div role="log"></code> made visible.
</div>
<h2>Dynamically generating a fully-populated live region container</h2>
<h3>Fully populated generic <code><div aria-live="polite"></code></h3>
<button class="generate" data-live="polite">Generate</button>
<h3>Fully populated generic <code><div aria-live="assertive"></code></h3>
<button class="generate" data-live="assertive">Generate</button>
<h3>Fully populated <code><div role="status"></code></h3>
<button class="generate" data-role="status">Generate</button>
<h3>Fully populated <code><div role="alert"></code></h3>
<button class="generate" data-role="alert">Generate</button>
<h3>Fully populated <code><div role="log"></code></h3>
<button class="generate" data-role="log">Generate</button>
<h2>Injecting message dynamically into existing live region container</h2>
<h3>Existing generic <code><div aria-live="polite"></code></h3>
<button class="inject">Inject</button>
<div aria-live="polite" class="notification"></div>
<h3>Existing generic <code><div aria-live="assertive"></code></h3>
<button class="inject">Inject</button>
<div aria-live="assertive" class="notification"></div>
<h3>Existing <code><div role="status"></code></h3>
<button class="inject">Inject</button>
<div role="status" class="notification"></div>
<h3>Existing <code><div role="alert"></code></h3>
<button class="inject">Inject</button>
<div role="alert" class="notification"></div>
<h3>Existing <code><div role="log"></code></h3>
<button class="inject">Inject</button>
<div role="log" class="notification"></div>
<h2>Dynamically generating live region, then after delay injecting message</h2>
<p>Using a <code>150ms</code> delay.</p>
<h3>Generate generic <code><div aria-live="polite"></code>, then inject</h3>
<button class="generateInject" data-live="polite">Generate then inject</button>
<h3>Generate generic <code><div aria-live="assertive"></code>, then inject</h3>
<button class="generateInject" data-live="assertive">Generate then inject</button>
<h3>Generate <code><div role="status"></code>, then inject</h3>
<button class="generateInject" data-role="status">Generate then inject</button>
<h3>Generate <code><div role="alert"></code>, then inject</h3>
<button class="generateInject" data-role="alert">Generate then inject</button>
<h3>Generate <code><div role="log"></code>, then inject</h3>
<button class="generateInject" data-role="log">Generate then inject</button>
<script>
const displayFlipButtons = document.querySelectorAll("button.displayflip");
displayFlipButtons.forEach((button) => {
button.addEventListener('click', () => {
button.nextElementSibling.classList.toggle('hidden');
});
});
const generateButtons = document.querySelectorAll("button.generate");
generateButtons.forEach((button) => {
button.addEventListener('click', () => {
const newLiveRegion= document.createElement("div");
newLiveRegion.classList.add("notification");
if (button.dataset.live) {
newLiveRegion.setAttribute("aria-live",button.dataset.live);
var message = document.createTextNode("Generated "+button.dataset.live+" already containing a message");
}
if (button.dataset.role) {
newLiveRegion.setAttribute("role",button.dataset.role);
var message = document.createTextNode("Generated "+button.dataset.role+" already containing a message");
}
newLiveRegion.appendChild(message);
button.after(newLiveRegion);
});
});
const injectExistingButtons = document.querySelectorAll("button.inject");
injectExistingButtons.forEach((button) => {
button.addEventListener('click', () => {
const liveRegion = button.nextElementSibling;
if (liveRegion.getAttribute("aria-live")) {
var message = document.createTextNode("Injecting message into existing "+liveRegion.getAttribute("aria-live")+" container");
}
if (liveRegion.getAttribute("role")) {
var message = document.createTextNode("Injecting message into existing "+liveRegion.getAttribute("role")+" container");
}
liveRegion.appendChild(message);
});
});
const generateInjectButtons = document.querySelectorAll("button.generateInject");
generateInjectButtons.forEach((button) => {
button.addEventListener('click', () => {
const newLiveRegion= document.createElement("div");
newLiveRegion.classList.add("notification");
if (button.dataset.live) {
newLiveRegion.setAttribute("aria-live",button.dataset.live);
var message = document.createTextNode("Generated "+button.dataset.live+" then injected a message");
}
if (button.dataset.role) {
newLiveRegion.setAttribute("role",button.dataset.role);
var message = document.createTextNode("Generated "+button.dataset.role+" then injected a message");
}
button.after(newLiveRegion);
setTimeout(() => {
newLiveRegion.appendChild(message);
}, 150);
});
});
</script>
</body>
</html>