Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/selectors/focus-within-iframe.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/selectors/focus-within-iframe.html b/third_party/WebKit/LayoutTests/fast/selectors/focus-within-iframe.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..702ea67a300be7816585153775ad3a49aecb021f |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/selectors/focus-within-iframe.html |
| @@ -0,0 +1,39 @@ |
| +<!DOCTYPE html> |
| +<meta charset="utf-8"> |
| +<script src=../../resources/testharness.js></script> |
| +<script src=../../resources/testharnessreport.js></script> |
| +<iframe id="frame"></iframe> |
| +<script> |
| + test(() => assert_not_equals(window.internals, undefined), |
| + "Check window.internals is available"); |
| + |
| + const frame = document.getElementById("frame"); |
| + frame.contentDocument.open(); |
| + frame.contentDocument.write(` |
| + <!DOCTYPE html> |
| + <style> |
| + input { |
| + background-color: rgb(50, 150, 200); |
| + } |
| + input:focus-within { |
| + background-color: rgb(250, 200, 150); |
| + } |
| + </style> |
| + <input id="input" /> |
| + `); |
| + frame.contentDocument.close(); |
|
rune
2017/04/28 13:00:03
You could probably just use the srcdoc attribute o
Manuel Rego
2017/05/02 07:53:35
Done.
|
| + |
| + const input = frame.contentDocument.getElementById("input"); |
| + input.focus(); |
| + |
| + test(() => assert_equals(frame.contentWindow.getComputedStyle(input).backgroundColor, "rgb(250, 200, 150)"), |
| + "Check ':focus-within' is applied after focusing the input"); |
| + |
| + frame.contentWindow.internals.setFocused(false); |
| + test(() => assert_equals(frame.contentWindow.getComputedStyle(input).backgroundColor, "rgb(50, 150, 200)"), |
| + "Check ':focus-within' is not applied when the frame is unfocused"); |
| + |
| + frame.contentWindow.internals.setFocused(true); |
| + test(() => assert_equals(frame.contentWindow.getComputedStyle(input).backgroundColor, "rgb(250, 200, 150)"), |
| + "Check ':focus-within' is applied when the frame is focsued again"); |
| +</script> |