OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <script src=../../resources/testharness.js></script> |
| 4 <script src=../../resources/testharnessreport.js></script> |
| 5 <iframe id="frame" srcdoc=" |
| 6 <!DOCTYPE html> |
| 7 <style> |
| 8 input { |
| 9 background-color: rgb(50, 150, 200); |
| 10 } |
| 11 input:focus-within { |
| 12 background-color: rgb(250, 200, 150); |
| 13 } |
| 14 </style> |
| 15 <input id='input' /> |
| 16 "></iframe> |
| 17 <script> |
| 18 test(() => assert_not_equals(window.internals, undefined), |
| 19 "Check window.internals is available"); |
| 20 |
| 21 const frame = document.getElementById("frame"); |
| 22 frame.addEventListener("load", () => { |
| 23 const input = frame.contentDocument.getElementById("input"); |
| 24 input.focus(); |
| 25 |
| 26 test(() => assert_equals(frame.contentWindow.getComputedStyle(input).backgro
undColor, "rgb(250, 200, 150)"), |
| 27 "Check ':focus-within' is applied after focusing the input"); |
| 28 |
| 29 frame.contentWindow.internals.setFocused(false); |
| 30 test(() => assert_equals(frame.contentWindow.getComputedStyle(input).backgro
undColor, "rgb(50, 150, 200)"), |
| 31 "Check ':focus-within' is not applied when the frame is unfocused"); |
| 32 |
| 33 frame.contentWindow.internals.setFocused(true); |
| 34 test(() => assert_equals(frame.contentWindow.getComputedStyle(input).backgro
undColor, "rgb(250, 200, 150)"), |
| 35 "Check ':focus-within' is applied when the frame is focsued again"); |
| 36 }); |
| 37 </script> |
OLD | NEW |