summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/perf/accessibility-title-ui-element.html
blob: 87af52f609015613082d4285488115e700cf42ac (plain)
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
<!DOCTYPE html>
<html>
<body>
<script src="../resources/magnitude-perf.js"></script>
<script>

var parentContainer;
var axControl;

function endsWith(str, suffix) {
    return str.substr(str.length - suffix.length) == suffix;
}

function setup(magnitude) {
    if (parentContainer)
        document.body.removeChild(parentContainer);
    parentContainer = document.createElement('div');
    document.body.appendChild(parentContainer);

    var junkContainer = document.createElement('div');
    parentContainer.appendChild(junkContainer);

    var label = document.createElement('label');
    label.setAttribute('for', 'control');
    label.innerText = 'Label';
    parentContainer.appendChild(label);

    var control = document.createElement('input');
    control.type = 'text';
    control.id = 'control';
    parentContainer.appendChild(control);

    parentContainer.offsetLeft;
    axControl = accessibilityController.accessibleElementById('control');

    for (var i = 0; i < 10 * magnitude; ++i) {
        var div = document.createElement('div');
        div.innerHTML = "<p></p><p></p><p></p><p></p><p></p>";
        junkContainer.appendChild(div);
    }
    parentContainer.offsetLeft;
}

function test(magnitude) {
    for (var i = 0; i < 100; i++) {
        axControl.titleUIElement();
    }
}

Magnitude.description("Tests that titleUIElement on an accessibility element runs in amortized constant time.");
Magnitude.numTrials = 5;
Magnitude.successThreshold = 0.40; // 2 out of 5
Magnitude.tolerance = 0.40;
Magnitude.trim = 2;
Magnitude.run(setup, test, Magnitude.CONSTANT);
</script>
</body>
</html>