summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/label/labels-set-htmlFor-attribute.html
blob: 7dbcd307780bbdae3eb5b32066daf66188d61064 (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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../resources/common.js"></script>
<script src="../resources/label-test-util.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Test that the labels list of a form control is dynamically updated when the htmlFor attribute of a label changes to point to that control. ');

var tester = setupLabelsTest(withNoLabel, '<label id="labelId"></label>');
for (var name in tester.dataSet) {
    var data = tester.getLabelableElementData(name);
    if (data == null)
        continue;

    debug('Check ' + data.name);
    var element = data.element;
    shouldBe('element.labels.length', '0');

    var label = document.getElementById("labelId");
    label.htmlFor = element.id;
    shouldBe('element.labels.length', '1');
}
</script>
</body>
</html>