OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Selector: pseudo-classes (:focus)</title> |
| 4 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org" id=link1> |
| 5 <link rel=help href="https://html.spec.whatwg.org/multipage/#pseudo-classes" id=
link2> |
| 6 <script src="../../../../../../resources/testharness.js"></script> |
| 7 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 8 <script src="utils.js"></script> |
| 9 <body id=body tabindex=0> |
| 10 <div id="log"></div> |
| 11 <button id=button1 type=submit>button1</button> |
| 12 <input id=input1> |
| 13 <input id=input2 disabled> |
| 14 <input id=input3 autofocus> |
| 15 <textarea id=textarea1>textarea1</textarea> |
| 16 <input type=checkbox id=checkbox1 checked> |
| 17 <input type=radio id=radio1 checked> |
| 18 <div tabindex=0 id=div1>hello</div> |
| 19 <div contenteditable id=div2>content</div> |
| 20 <iframe src="focus-iframe.html" id=iframe onload="load()"></iframe> |
| 21 |
| 22 <script> |
| 23 testSelector(":focus", ["input3"], "input3 has the attribute autofocus"); |
| 24 |
| 25 document.getElementById("input1").focus(); // set the focus on input1 |
| 26 testSelector(":focus", ["input1"], "input1 has the focus"); |
| 27 |
| 28 document.getElementById("div1").focus(); |
| 29 testSelector(":focus", ["div1"], "tabindex attribute makes the element focus
able"); |
| 30 |
| 31 document.getElementById("div2").focus(); |
| 32 testSelector(":focus", ["div2"], "editable elements are focusable"); |
| 33 |
| 34 function load() { |
| 35 document.getElementById("iframe").contentDocument.getElementById("inputifr
ame").focus(); |
| 36 testSelector(":focus", [], "':focus' doesn't match focused elements in ifr
ame"); |
| 37 } |
| 38 |
| 39 document.body.focus(); |
| 40 testSelector(":focus", ["body"], "':focus' matches focussed body with tabind
ex"); |
| 41 </script> |
| 42 </body> |
OLD | NEW |