Truly independent web browser
LibWeb: Import pointer focus-visible input coverage
Andreas Kling558f5c4da0e9
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-003.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-003.txtnew file mode 100644index 00000000000..5264ff3264a--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-003.txt@@ -0,0 +1,18 @@+Harness status: OK++Found 12 tests++4 Pass+8 Fail+Pass Focus element SPAN#el-1 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element SPAN#el-2 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element SPAN#el-3 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Fail Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Fail Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Fail Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Fail Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Fail Focus element INPUT#el-9 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Fail Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Fail Focus element INPUT#el-12 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Fail Focus element INPUT#el-13 via mouse should NOT match :focus-visible as it does NOT support keyboard input\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-004.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-004.txtnew file mode 100644index 00000000000..11d0251aa58--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-004.txt@@ -0,0 +1,16 @@+Harness status: OK++Found 10 tests++4 Pass+6 Fail+Pass Focus element SPAN#el-1 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Pass Focus element SPAN#el-2 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Pass Focus element SPAN#el-3 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Pass Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Fail Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Fail Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Fail Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Fail Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Fail Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Fail Focus element INPUT#el-11 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-003.html b/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-003.htmlnew file mode 100644index 00000000000..f0063f42c8a--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-003.html@@ -0,0 +1,101 @@+<!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8" />+ <title>CSS Test (Selectors): :focus-visible does not match on non-texty inputs</title>+ <link rel="author" title="Alice Boxhall" href="[email protected]" />+ <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />+ <script src="../../resources/testharness.js"></script>+ <script src="../../resources/testharnessreport.js"></script>+ <script src="../../resources/testdriver.js"></script>+ <script src="../../resources/testdriver-actions.js"></script>+ <script src="../../resources/testdriver-vendor.js"></script>+ <style>+ @supports not selector(:focus-visible) {+ :focus {+ outline: red solid 5px;+ background-color: red;+ }+ }++ :focus-visible {+ outline: red solid 5px;+ }++ :focus:not(:focus-visible) {+ outline: 0;+ background-color: lime;+ }+ </style>+</head>+<body>+ This test checks that <code>:focus-visible</code> is <em>not</em> triggered by mouse focus on <code><input></code> elements which do not take text input.+ <ol id="instructions">+ <li>If the user-agent does not claim to support the <code>:focus-visible</code> pseudo-class then SKIP this test.</li>+ <li>Click each element element below to focus it.</li>+ <li>If the element has a red outline, then the test result is FAILURE. If the element has a green background, then the test result is SUCCESS.</li>+ </ol>+ <br />+ <div>+ <span class="check" id="el-1" tabindex="1">Focus me</span>+ </div>+ <div>+ <span class="check" id="el-2" tabindex="-1">Focus me</span>+ </div>+ <div>+ <span class="check" id="el-3" tabindex="0">Focus me</span>+ </div>+ <div>+ <button class="check" id="el-4">Focus me</button>+ </div>+ <div>+ <input class="check" id="el-5" type="button" value="Focus me">+ </div>+ <div>+ <input class="check" id="el-6" type="image" alt="Focus me.">+ </div>+ <div>+ <input class="check" id="el-7" type="reset" value="Focus me.">+ </div>+ <div>+ <input class="check" id="el-8" type="submit" value="Focus me.">+ </div>+ <div>+ <label><input class="check" id="el-9" type="checkbox"> Focus me.</label>+ </div>+ <div>+ <label><input class="check" id="el-10" type="radio"> Focus me.</label>+ </div>+ <div>+ <!-- Focusing file input triggers a modal, so only test manually -->+ <input id="el-11" type="file" value="Focus me.">+ </div>+ <div>+ <label><input class="check" id="el-12" type="range"> Focus me.</label>+ </div>+ <div>+ <!-- Ensure the color input is last, as it has a pop-up which obscures other elements -->+ <label><input class="check" id="el-13" type="color"> Focus me.</label>+ </div>+ <script>+ setup({ explicit_done: true });++ const elements = document.querySelectorAll(".check");+ for (let i = 0; i < elements.length; i++) {+ const target = elements[i];+ promise_test(() => {+ return new Promise(resolve => {+ target.addEventListener("focus", resolve);+ test_driver.click(target).then(() => {+ if (i == (elements.length - 1))+ done();+ });+ }).then(() => {+ assert_equals(getComputedStyle(target).backgroundColor, "rgb(0, 255, 0)", `backgroundColor for ${target.tagName}#${target.id} should be lime`);+ assert_not_equals(getComputedStyle(target).outlineColor, "rgb(255, 0, 0)", `outlineColor for ${target.tagName}#${target.id} should NOT be red`);+ });+ }, `Focus element ${target.tagName}#${target.id} via mouse should NOT match :focus-visible as it does NOT support keyboard input`);+ }+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-004.html b/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-004.htmlnew file mode 100644index 00000000000..b205f59fdb9--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-004.html@@ -0,0 +1,100 @@+<!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8" />+ <title>CSS Test (Selectors): :focus-visible does not match on non-texty inputs with appearance: none</title>+ <link rel="author" title="Alice Boxhall" href="[email protected]" />+ <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />+ <script src="../../resources/testharness.js"></script>+ <script src="../../resources/testharnessreport.js"></script>+ <script src="../../resources/testdriver.js"></script>+ <script src="../../resources/testdriver-actions.js"></script>+ <script src="../../resources/testdriver-vendor.js"></script>+ <style>+ @supports not selector(:focus-visible) {+ :focus {+ outline: red solid 5px;+ background-color: red;+ }+ }++ :focus-visible {+ outline: red solid 5px;+ }++ :focus:not(:focus-visible) {+ outline: 0;+ background-color: lime;+ }++ .check {+ -webkit-appearance: none;+ appearance: none;+ }+ </style>+</head>+<body>+ This test checks that <code>:focus-visible</code> is <em>not</em> triggered by mouse focus on <code><input></code> elements which do not take text input, even if <code>appearance: none</code> is used.+ <ol id="instructions">+ <li>If the user-agent does not claim to support the <code>:focus-visible</code> pseudo-class then SKIP this test.</li>+ <li>Click each element element below to focus it.</li>+ <li>If the element has a red outline, then the test result is FAILURE. If the element has a green background, then the test result is SUCCESS.</li>+ </ol>+ <br />+ <div>+ <span class="check" id="el-1" tabindex="1">Focus me</span>+ </div>+ <div>+ <span class="check" id="el-2" tabindex="-1">Focus me</span>+ </div>+ <div>+ <span class="check" id="el-3" tabindex="0">Focus me</span>+ </div>+ <div>+ <button class="check" id="el-4">Focus me</button>+ </div>+ <div>+ <input class="check" id="el-5" type="button" value="Focus me">+ </div>+ <div>+ <input class="check" id="el-6" type="image" alt="Focus me.">+ </div>+ <div>+ <input class="check" id="el-7" type="reset" value="Focus me.">+ </div>+ <div>+ <input class="check" id="el-8" type="submit" value="Focus me.">+ </div>+ <div>+ <!-- Focusing file input triggers a modal, so only test manually -->+ <input id="el-9" type="file" value="Focus me.">+ </div>+ <div>+ <label><input class="check" id="el-10" type="range"> Focus me.</label>+ </div>+ <div>+ <!-- Ensure the color input is last, as it has a pop-up which obscures other elements -->+ <label><input class="check" id="el-11" type="color"> Focus me.</label>+ </div>+ <script>+ setup({ explicit_done: true });++ const elements = document.querySelectorAll(".check");+ for (let i = 0; i < elements.length; i++) {+ const target = elements[i];+ promise_test(() => {+ return new Promise(resolve => {+ target.addEventListener("focus", resolve);+ test_driver.click(target).then(() => {+ if (i == (elements.length - 1))+ done();+ });+ }).then(() => {+ assert_equals(getComputedStyle(target).backgroundColor, "rgb(0, 255, 0)", `backgroundColor for ${target.tagName}#${target.id} should be lime`);+ assert_not_equals(getComputedStyle(target).outlineColor, "rgb(255, 0, 0)", `outlineColor for ${target.tagName}#${target.id} should NOT be red`);+ });+ }, `Focus element ${target.tagName}#${target.id} via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"`);+ }+ </script>+</body>+</html>