OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <script src="../../../resources/testharness.js"></script> |
| 4 <script src="../../../resources/testharnessreport.js"></script> |
| 5 <label inert for="submit">Label for Submit</label> |
| 6 <input id="text" type="text"> |
| 7 <input id="submit" type="submit"> |
| 8 <script> |
| 9 function clickOn(element) { |
| 10 if (!window.eventSender) |
| 11 return; |
| 12 |
| 13 var absoluteTop = 0; |
| 14 var absoluteLeft = 0; |
| 15 for (var parentNode = element; parentNode; parentNode = parentNode.offsetPar
ent) { |
| 16 absoluteLeft += parentNode.offsetLeft; |
| 17 absoluteTop += parentNode.offsetTop; |
| 18 } |
| 19 |
| 20 var x = absoluteLeft + element.offsetWidth / 2; |
| 21 var y = absoluteTop + element.offsetHeight / 2; |
| 22 eventSender.mouseMoveTo(x, y); |
| 23 eventSender.mouseDown(); |
| 24 eventSender.mouseUp(); |
| 25 eventSender.mouseMoveTo(0, 0); |
| 26 } |
| 27 |
| 28 document.querySelector('#text').focus(); |
| 29 |
| 30 test(function() { |
| 31 label = document.querySelector('label'); |
| 32 label.focus(); |
| 33 assert_equals(document.activeElement, document.querySelector('#submit')); |
| 34 }, 'Calling focus() on an inert label should still send focus to its target.'); |
| 35 |
| 36 test(function() { |
| 37 clickOn(label); |
| 38 assert_equals(document.activeElement, document.body); |
| 39 }, 'Clicking on an inert label should send focus to document.body.'); |
| 40 </script> |
| 41 </html> |
OLD | NEW |