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
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* eslint-disable camelcase */
const RowOrColumnMajor_RowMajor = 0;
/* eslint-enable camelcase */
const SNIPPET = `
<table id="table">
<tr><th id="a">a</th><th id="b">b</th><th id="c">c</th></tr>
<tr><th id="dg" rowspan="2">dg</th><td id="ef" colspan="2" headers="b c">ef</td></tr>
<tr><th id="h">h</th><td id="i" headers="dg h">i</td></tr>
<tr><td id="jkl" colspan="3" headers="a b c">jkl</td></tr>
</table>
<button id="button">button</button>
`;
async function testGridGetItem(row, col, cellId) {
is(
await runPython(`pattern.GetItem(${row}, ${col}).CurrentAutomationId`),
cellId,
`GetItem with row ${row} and col ${col} returned ${cellId}`
);
}
async function testGridItemProps(id, row, col, rowSpan, colSpan, gridId) {
await assignPyVarToUiaWithId(id);
await definePyVar("pattern", `getUiaPattern(${id}, "GridItem")`);
ok(await runPython(`bool(pattern)`), `${id} has GridItem pattern`);
is(await runPython(`pattern.CurrentRow`), row, `${id} has correct Row`);
is(await runPython(`pattern.CurrentColumn`), col, `${id} has correct Column`);
is(
await runPython(`pattern.CurrentRowSpan`),
rowSpan,
`${id} has correct RowSpan`
);
is(
await runPython(`pattern.CurrentColumnSpan`),
colSpan,
`${id} has correct ColumnSpan`
);
is(
await runPython(`pattern.CurrentContainingGrid.CurrentAutomationId`),
gridId,
`${id} ContainingGridItem is ${gridId}`
);
}
async function testTableItemProps(id, rowHeaders, colHeaders) {
await assignPyVarToUiaWithId(id);
await definePyVar("pattern", `getUiaPattern(${id}, "TableItem")`);
ok(await runPython(`bool(pattern)`), `${id} has TableItem pattern`);
await isUiaElementArray(
`pattern.GetCurrentRowHeaderItems()`,
rowHeaders,
`${id} has correct RowHeaderItems`
);
await isUiaElementArray(
`pattern.GetCurrentColumnHeaderItems()`,
colHeaders,
`${id} has correct ColumnHeaderItems`
);
}
/**
* Test the Grid pattern.
*/
addUiaTask(SNIPPET, async function testGrid() {
await definePyVar("doc", `getDocUia()`);
await assignPyVarToUiaWithId("table");
await definePyVar("pattern", `getUiaPattern(table, "Grid")`);
ok(await runPython(`bool(pattern)`), "table has Grid pattern");
is(
await runPython(`pattern.CurrentRowCount`),
4,
"table has correct RowCount"
);
is(
await runPython(`pattern.CurrentColumnCount`),
3,
"table has correct ColumnCount"
);
await testGridGetItem(0, 0, "a");
await testGridGetItem(0, 1, "b");
await testGridGetItem(0, 2, "c");
await testGridGetItem(1, 0, "dg");
await testGridGetItem(1, 1, "ef");
await testGridGetItem(1, 2, "ef");
await testGridGetItem(2, 0, "dg");
await testGridGetItem(2, 1, "h");
await testGridGetItem(2, 2, "i");
await testPatternAbsent("button", "Grid");
});
/**
* Test the GridItem pattern.
*/
addUiaTask(SNIPPET, async function testGridItem() {
await definePyVar("doc", `getDocUia()`);
await testGridItemProps("a", 0, 0, 1, 1, "table");
await testGridItemProps("b", 0, 1, 1, 1, "table");
await testGridItemProps("c", 0, 2, 1, 1, "table");
await testGridItemProps("dg", 1, 0, 2, 1, "table");
await testGridItemProps("ef", 1, 1, 1, 2, "table");
await testGridItemProps("jkl", 3, 0, 1, 3, "table");
await testPatternAbsent("button", "GridItem");
});
/**
* Test the Table pattern.
*/
addUiaTask(
SNIPPET,
async function testTable() {
await definePyVar("doc", `getDocUia()`);
await assignPyVarToUiaWithId("table");
await definePyVar("pattern", `getUiaPattern(table, "Table")`);
ok(await runPython(`bool(pattern)`), "table has Table pattern");
await isUiaElementArray(
`pattern.GetCurrentRowHeaders()`,
["dg", "h"],
"table has correct RowHeaders"
);
await isUiaElementArray(
`pattern.GetCurrentColumnHeaders()`,
["a", "b", "c"],
"table has correct ColumnHeaders"
);
is(
await runPython(`pattern.CurrentRowOrColumnMajor`),
RowOrColumnMajor_RowMajor,
"table has correct RowOrColumnMajor"
);
await testPatternAbsent("button", "Table");
},
// The IA2 -> UIA proxy doesn't support the Row/ColumnHeaders properties.
{ uiaEnabled: true, uiaDisabled: false }
);
/**
* Test the TableItem pattern.
*/
addUiaTask(SNIPPET, async function testTableItem() {
await definePyVar("doc", `getDocUia()`);
await testTableItemProps("a", [], []);
await testTableItemProps("b", [], []);
await testTableItemProps("c", [], []);
await testTableItemProps("dg", [], ["a"]);
await testTableItemProps("ef", ["dg"], ["b", "c"]);
await testTableItemProps("h", ["dg"], ["b"]);
await testTableItemProps("i", ["dg", "h"], ["c"]);
await testTableItemProps("jkl", [], ["a", "b", "c"]);
await testPatternAbsent("button", "TableItem");
});
|