| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <script src="../../../resources/js-test.js"></script> | |
| 4 <label for="submit">Label for Submit</label> | |
| 5 <dialog> | |
| 6 <input id="text" type="text"> | |
| 7 <input id="submit" type="submit"> | |
| 8 </dialog> | |
| 9 <script> | |
| 10 function clickOn(element) { | |
| 11 if (!window.eventSender) | |
| 12 return; | |
| 13 | |
| 14 var absoluteTop = 0; | |
| 15 var absoluteLeft = 0; | |
| 16 for (var parentNode = element; parentNode; parentNode = parentNode.offsetPar
ent) { | |
| 17 absoluteLeft += parentNode.offsetLeft; | |
| 18 absoluteTop += parentNode.offsetTop; | |
| 19 } | |
| 20 | |
| 21 var x = absoluteLeft + element.offsetWidth / 2; | |
| 22 var y = absoluteTop + element.offsetHeight / 2; | |
| 23 eventSender.mouseMoveTo(x, y); | |
| 24 eventSender.mouseDown(); | |
| 25 eventSender.mouseUp(); | |
| 26 eventSender.mouseMoveTo(0, 0); | |
| 27 } | |
| 28 | |
| 29 description('Tests focusing of an inert label for a non-inert target. label.focu
s() should send focus ' + | |
| 30 'to the target, but clicking the label should be the same as clickin
g on the document body.'); | |
| 31 | |
| 32 document.querySelector('dialog').showModal(); | |
| 33 document.querySelector('#text').focus(); | |
| 34 | |
| 35 debug('Testing that calling focus() on label sends focus to its target.'); | |
| 36 label = document.querySelector('label'); | |
| 37 label.focus(); | |
| 38 shouldBe('document.activeElement', "document.querySelector('#submit')"); | |
| 39 | |
| 40 debug('Testing that clicking on the label sends focus to document.body.'); | |
| 41 clickOn(label); | |
| 42 shouldBe('document.activeElement', 'document.body'); | |
| 43 </script> | |
| 44 </html> | |
| OLD | NEW |