OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../fast/js/resources/js-test-pre.js"></script> |
| 5 <script src="../resources/common.js"></script> |
| 6 <script src="../resources/label-test-util.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <p id="description"></p> |
| 10 <div id="console"></div> |
| 11 <script> |
| 12 description('Test that labels with contenteditable attribute send focus and key
events. '); |
| 13 |
| 14 var parent = document.createElement('div'); |
| 15 |
| 16 parent.innerHTML = '<label id="label1" for="input1">text</label><input id="input
1"> <label id="label2" contenteditable for="input2">text</label><input id="input
2">'; |
| 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'); |
| 22 |
| 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 n
ot 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 se
nt if the label does not have contenteditable attribute"); }); |
| 28 input1.addEventListener('focus', function () { alert("PASS: label passed the foc
us 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 b
e 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 i
f the label has contenteditable attribute"); }); |
| 34 input2.addEventListener('focus', function () { alert("PASS: label passed the foc
us to the corresponding control"); }); |
| 35 |
| 36 if (window.eventSender) { |
| 37 eventSender.dragMode = false; |
| 38 mouseMoveToLabel("label1"); |
| 39 eventSender.mouseDown(); |
| 40 eventSender.keyDown("A"); |
| 41 eventSender.mouseUp(); |
| 42 |
| 43 mouseMoveToLabel("label2"); |
| 44 eventSender.mouseDown(); |
| 45 eventSender.keyDown("A"); |
| 46 eventSender.mouseUp(); |
| 47 } |
| 48 |
| 49 </script> |
| 50 <script src="../../../fast/js/resources/js-test-post.js"></script> |
| 51 </body> |
| 52 </html> |
OLD | NEW |