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 return new Promise(function(resolve, reject) { |
| 11 if (!window.eventSender) |
| 12 reject(); |
| 13 |
| 14 var absoluteTop = 0; |
| 15 var absoluteLeft = 0; |
| 16 for (var parentNode = element; parentNode; parentNode = parentNode.offse
tParent) { |
| 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 var pointerActions = [{ |
| 24 source: "mouse", |
| 25 actions: [ |
| 26 { name: "pointerMove", x: x, y: y }, |
| 27 { name: "pointerDown", x: x, y: x }, |
| 28 { name: "pointerUp" }, |
| 29 { name: "pointerMove", x: 0, y: 0} |
| 30 ] |
| 31 }]; |
| 32 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); |
| 33 }); |
| 34 } |
| 35 |
| 36 document.querySelector('#text').focus(); |
| 37 |
| 38 test(function() { |
| 39 label = document.querySelector('label'); |
| 40 label.focus(); |
| 41 assert_equals(document.activeElement, document.querySelector('#submit')); |
| 42 }, 'Calling focus() on an inert label should still send focus to its target.'); |
| 43 |
| 44 test(function() { |
| 45 clickOn(label).then(() => { |
| 46 assert_equals(document.activeElement, document.body); |
| 47 }); |
| 48 }, 'Clicking on an inert label should send focus to document.body.'); |
| 49 </script> |
| 50 </html> |
OLD | NEW |