Truly independent web browser
LibWeb: Import focus-visible checkbox label coverage
Andreas Kling1685cd411c08
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-026.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-026.txtnew file mode 100644index 00000000000..c58b573ba2c--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-026.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Pass ":focus-visible" should be a valid selector+Fail :focus-visible does NOT match when a checkbox is focused via click on the associated label\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-026.html b/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-026.htmlnew file mode 100644index 00000000000..c73fc974f41--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/selectors/focus-visible-026.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<meta charset="utf-8" />+<title>CSS Test (Selectors): Checkbox doesn't match :focus-visiblel after click on label</title>+<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />+<meta name="assert" content="This test checks that :focus-visible does NOT match when a checkbox is focused because an associated label has been clicked.">+<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>+<script src="../../resources/accesskey.js"></script>+<script src="../../css/support/parsing-testcommon.js"></script>+<style>+ :focus-visible {+ outline: red solid 5px;+ }+</style>+<input type="checkbox" id="checkbox">+<label for="checkbox" id="label">label</label>+<script>+ // Check that :focus-visible is supported.+ test_valid_selector(':focus-visible');++ promise_test(async t => {+ await test_driver.click(label);+ assert_equals(getComputedStyle(checkbox).outlineStyle, "none", `outline-style for ${checkbox.tagName}#${checkbox.id} should be none`);+ t.done();+ }, ":focus-visible does NOT match when a checkbox is focused via click on the associated label");+</script>+diff --git a/Tests/LibWeb/Text/input/wpt-import/resources/accesskey.js b/Tests/LibWeb/Text/input/wpt-import/resources/accesskey.jsnew file mode 100644index 00000000000..e95c9d21e58--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/resources/accesskey.js@@ -0,0 +1,34 @@+/*+ * Function that sends an accesskey using the proper key combination depending on the browser and OS.+ *+ * This needs that the test imports the following scripts:+ * <script src="/resources/testdriver.js"></script>+ * <script src="/resources/testdriver-actions.js"></script>+ * <script src="/resources/testdriver-vendor.js"></script>+*/+function pressAccessKey(accessKey){+ let controlKey = '\uE009'; // left Control key+ let altKey = '\uE00A'; // left Alt key+ let optionKey = altKey; // left Option key+ let shiftKey = '\uE008'; // left Shift key+ // There are differences in using accesskey across browsers and OS's.+ // See: // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey+ let isMacOSX = navigator.userAgent.indexOf("Mac") != -1;+ let osAccessKey = isMacOSX ? [controlKey, optionKey] : [shiftKey, altKey];+ let actions = new test_driver.Actions();+ // Press keys.+ for (let key of osAccessKey) {+ actions = actions.keyDown(key);+ }+ actions = actions+ .keyDown(accessKey)+ .addTick()+ .keyUp(accessKey);+ osAccessKey.reverse();+ for (let key of osAccessKey) {+ actions = actions.keyUp(key);+ }+ return actions.send();+}++