summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/focus-with-display-block.html
blob: 1307988834063fcba3f7d3b4de762a18dda4d187 (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
59
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
<style>
output, meter, progress {
    display: block;
}
</style>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('This test ensures that &lt;output&gt;, &lt;meter&gt; and &lt;progress&gt; are not focused.');

function moveFocus(element) {
    if (window.testRunner)
        eventSender.keyDown('\t');
    else
        element.focus();
}

function checkFocus() {
    var active = document.activeElement.nodeName;
    if (active == "OUTPUT" || active == "METER" || active == "PROGRESS") {
        debug(active + ' should not have focus.');
        return false;
    }
    return true;
}

var input = document.createElement('input');
var output = document.createElement('output');
var progress = document.createElement('progress');
var meter = document.createElement('meter');

// Set a placeholder text to the output element to display the element.
output.innerHTML = 'Text in output element';

document.body.appendChild(input);
document.body.appendChild(output);
document.body.appendChild(progress);
document.body.appendChild(meter);

debug('- Moves the focus by using keyDown() in DRT, otherwise using element.focus().');
debug('- checkFocus() returns true when &lt;output&gt;, &lt;meter&gt; and &lt;progress&gt; do not have focus.');

moveFocus(input);
shouldBeTrue('checkFocus()');
moveFocus(output);
shouldBeTrue('checkFocus()');
moveFocus(progress);
shouldBeTrue('checkFocus()');
moveFocus(meter);
shouldBeTrue('checkFocus()');
</script>
</body>
</html>