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
|
<!DOCTYPE html>
<html>
<head>
<title>nsIAccessibleText getText related function tests for rich text</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style>
#listitemnone {
list-style-type: none;
}
h6.gencontent:before {
content: "aga"
}
</style>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../text.js"></script>
<script type="application/javascript">
function doTest() {
// ////////////////////////////////////////////////////////////////////////
// null getText
// ////////////////////////////////////////////////////////////////////////
var emptyTextAcc = getAccessible("nulltext", [nsIAccessibleText]);
is(emptyTextAcc.getText(0, -1), "", "getText() END_OF_TEXT with null string");
is(emptyTextAcc.getText(0, 0), "", "getText() Len==0 with null string");
// ////////////////////////////////////////////////////////////////////////
// hypertext
// ////////////////////////////////////////////////////////////////////////
// ! - embedded object char
// __h__e__l__l__o__ __!__ __s__e__e__ __!__
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13
var IDs = [ "hypertext", "hypertext2", "ht_displaycontents" ];
// //////////////////////////////////////////////////////////////////////
// characterCount
testCharacterCount(IDs, 13);
// //////////////////////////////////////////////////////////////////////
// getText
testText(IDs, 0, 1, "h");
testText(IDs, 5, 7, " " + kEmbedChar);
testText(IDs, 10, 13, "e " + kEmbedChar);
testText(IDs, 0, 13, "hello " + kEmbedChar + " see " + kEmbedChar);
// //////////////////////////////////////////////////////////////////////
// getTextAtOffset line boundary
testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5,
"hypertext3", kOk, kOk, kOk);
// XXX: see bug 634202.
testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5,
"hypertext4", kOk, kOk, kOk);
// ////////////////////////////////////////////////////////////////////////
// list
// ////////////////////////////////////////////////////////////////////////
IDs = [ "list" ];
testCharacterCount(IDs, 2);
testText(IDs, 0, 2, kEmbedChar + kEmbedChar);
IDs = [ "listitem" ];
testCharacterCount(IDs, 6);
testText(IDs, 0, 6, "1. foo");
IDs = [ "listitemnone" ];
testCharacterCount(IDs, 3);
testText(IDs, 0, 3, "bar");
testText(["testbr"], 0, 3, "foo");
testTextAtOffset(2, nsIAccessibleText.BOUNDARY_CHAR, "o", 2, 3, "testbr",
kOk, kOk, kOk);
testTextAtOffset(2, nsIAccessibleText.BOUNDARY_WORD_START, "foo\n", 0, 4,
"testbr", kOk, kOk, kOk);
testTextBeforeOffset(2, nsIAccessibleText.BOUNDARY_LINE_START, "foo\n",
0, 4, "testbr", kTodo, kOk, kTodo);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="Fix getText"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=630001">
Bug 630001, part3
</a>
<a target="_blank"
title="getTextAtOffset line boundary may return more than one line"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=638326">
Bug 638326
</a>
<a target="_blank"
title="getText(0, -1) fails with empty text"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=749810">
Bug 749810
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="nulltext"></div>
<div id="hypertext">hello <a>friend</a> see <img src="about:blank"></div>
<div id="hypertext2">hello <a>friend</a> see <input></div>
<div id="ht_displaycontents">hello <a>friend</a> see <ul id="ul" style="display: contents;">
<li>Supermarket 1</li>
<li>Supermarket 2</li>
</ul></div>
<ol id="list">
<li id="listitem">foo</li>
<li id="listitemnone">bar</li>
</ol>
<div id="hypertext3">line
<!-- haha -->
<!-- hahaha -->
<h6>heading</h6>
</div>
<div id="hypertext4">line
<!-- haha -->
<!-- hahaha -->
<h6 role="presentation" class="gencontent">heading</h6>
</div>
<div id="testbr">foo<br/></div>
<div></div>
</body>
</html>
|