4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
6 <script src=
"../resources/label-test-util.js"></script>
9 <p id=
"description"></p>
10 <div id=
"console"></div>
12 description('Test that labels with contenteditable attribute send focus and key events. ');
14 var parent
= document
.createElement('div');
16 parent
.innerHTML
= '<label id="label1" for="input1">text</label><input id="input1"> <label id="label2" contenteditable for="input2">text</label><input id="input2">';
17 document
.body
.appendChild(parent
);
18 var label1
= document
.getElementById('label1');
19 var input1
= document
.getElementById('input1');
20 var label2
= document
.getElementById('label2');
21 var input2
= document
.getElementById('input2');
23 label1
.addEventListener('keydown', function () { alert("FAIL: keydown should not be sent if the label does not have contenteditable attribute"); });
24 label1
.addEventListener('keypress', function () { alert("FAIL: keypress should not be sent if the label does not have contenteditable attribute"); });
25 label1
.addEventListener('keyup', function () { alert("FAIL: keyup should not be sent if the label does not have contenteditable attribute"); });
26 label1
.addEventListener('focus', function () { alert("FAIL: focus should not be sent if the label does not have contenteditable attribute"); });
27 label1
.addEventListener('blur', function () { alert("FAIL: blur should not be sent if the label does not have contenteditable attribute"); });
28 input1
.addEventListener('focus', function () { alert("PASS: label passed the focus to the corresponding control"); });
29 label2
.addEventListener('keydown', function () { alert("PASS: keydown should be sent if the label has contenteditable attribute"); });
30 label2
.addEventListener('keypress', function () { alert("PASS: keypress should be sent if the label has contenteditable attribute"); });
31 label2
.addEventListener('keyup', function () { alert("PASS: keyup should be sent if the label has contenteditable attribute"); });
32 label2
.addEventListener('focus', function () { alert("PASS: focus should be sent if the label has contenteditable attribute"); });
33 label2
.addEventListener('blur', function () { alert("PASS: blur should be sent if the label has contenteditable attribute"); });
34 input2
.addEventListener('focus', function () { alert("PASS: label passed the focus to the corresponding control"); });
36 if (window
.eventSender
) {
37 eventSender
.dragMode
= false;
38 mouseMoveToLabel("label1");
39 eventSender
.mouseDown();
40 eventSender
.keyDown("A");
41 eventSender
.mouseUp();
43 mouseMoveToLabel("label2");
44 eventSender
.mouseDown();
45 eventSender
.keyDown("A");
46 eventSender
.mouseUp();