Revision control

1
<!DOCTYPE html>
2
<html>
3
<body>
4
<script src="../resources/magnitude-perf.js"></script>
5
<script>
6
7
var parentContainer;
8
var axControl;
9
10
function endsWith(str, suffix) {
11
return str.substr(str.length - suffix.length) == suffix;
12
}
13
14
function setup(magnitude) {
15
if (parentContainer)
16
document.body.removeChild(parentContainer);
17
parentContainer = document.createElement('div');
18
document.body.appendChild(parentContainer);
19
20
var junkContainer = document.createElement('div');
21
parentContainer.appendChild(junkContainer);
22
23
var label = document.createElement('label');
24
label.setAttribute('for', 'control');
25
label.innerText = 'Label';
26
parentContainer.appendChild(label);
27
28
var control = document.createElement('input');
29
control.type = 'text';
30
control.id = 'control';
31
parentContainer.appendChild(control);
32
33
parentContainer.offsetLeft;
34
axControl = accessibilityController.accessibleElementById('control');
35
36
for (var i = 0; i < 10 * magnitude; ++i) {
37
var div = document.createElement('div');
38
div.innerHTML = "<p></p><p></p><p></p><p></p><p></p>";
39
junkContainer.appendChild(div);
40
}
41
parentContainer.offsetLeft;
42
}
43
44
function test(magnitude) {
45
for (var i = 0; i < 100; i++) {
46
axControl.titleUIElement();
47
}
48
}
49
50
Magnitude.description("Tests that titleUIElement on an accessibility element runs in amortized constant time.");
51
Magnitude.run(setup, test, Magnitude.CONSTANT);
52
</script>
53
</body>
54
</html>