Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / label / labels-contenteditable.html
blobdc3fa9b14c29f522011993eabdabc1492696fcde
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.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. ');
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();
49 </script>
50 </body>
51 </html>