-
Notifications
You must be signed in to change notification settings - Fork 0
/
rich_content_tests.js
80 lines (71 loc) · 2.41 KB
/
rich_content_tests.js
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
// These are the different permutations of ARIA attributes to try.
var attrs = [
'aria-live="polite" aria-relevant="text additions" (default)'];
build();
var live_region_counter = 0;
addTests(
'additions',
'append img with alt text',
'<div ARIA-ATTRS></div>',
function(region) {
var img = document.createElement('img');
img.src = 'http://google.com/favicon.ico';
img.setAttribute('alt', 'Live region succeeded ' + (++live_region_counter));
region.appendChild(img);
});
addTests(
'text',
'change img alt text where img is contained within live region',
'<div ARIA-ATTRS>' +
'<img src="http://google.com/favicon.ico" alt="Live region failed.">' +
'</div>',
function(region) {
region.firstChild.setAttribute('alt', 'Live region succeeded ' + (++live_region_counter));
});
addTests(
'text',
'change img alt text where aria-live is on img itself',
'<div>' +
'<img ARIA-ATTRS src="http://google.com/favicon.ico" alt="Live region failed.">' +
'</div>',
function(region) {
region.firstChild.setAttribute('alt', 'Live region succeeded ' + (++live_region_counter));
});
addTests(
'additions',
'append button with inner text',
'<div ARIA-ATTRS></div>',
function(region) {
var b = document.createElement('button');
b.tabIndex = -1;
b.textContent = 'Live region succeeded ' + (++live_region_counter);
region.appendChild(b);
});
addTests(
'additions',
'append button with aria-label',
'<div ARIA-ATTRS></div>',
function(region) {
var b = document.createElement('button');
b.tabIndex = -1;
b.textContent = 'Live region failed.';
b.setAttribute('aria-label', 'Live region succeeded ' + (++live_region_counter));
region.appendChild(b);
});
addTests(
'text',
'change button\'s aria-label',
'<div ARIA-ATTRS>' +
'<button tabindex="-1" aria-label="Fail 2.">Fail 1.</button>' +
'</div>',
function(region) {
region.firstChild.setAttribute('aria-label', 'Live region succeeded ' + (++live_region_counter));
});
addTests(
'text',
'button which is itself a life region (as opposed to being inside of one)',
'<div><input type="button" value="Live region failed" tabindex="-1" ARIA-ATTRS>' +
'</div>',
function(region) {
region.firstChild.setAttribute('value', 'Live region succeeded ' + (++live_region_counter));
});