Files
ladybird/Tests/LibWeb/Text/input/wpt-import/html/dom/access-key-label.html
Johan Dahlin 9a34fb59aa LibWeb: Implement HTMLElement.accessKeyLabel
Implement the accessKeyLabel IDL attribute per the HTML spec.

We mimic Chromium's behavior and treat the accesskey attribute value as
a single key rather than splitting on whitespace, since no browser
besides IE/Edge implemented the spec's splitting approach.

See https://github.com/whatwg/html/issues/3769
2026-03-20 15:57:06 -05:00

28 lines
851 B
HTML

<!DOCTYPE html>
<meta charset="UTF-8">
<title>accessKeyLabel attribute</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
function createButtonWithAccessKey(accessKey) {
const button = document.createElement('button');
button.setAttribute('accesskey', accessKey);
return button;
}
// The modifiers are not the same across all browser vendors.
// Therefore, the test uses non empty.
test(() => {
const element = createButtonWithAccessKey('b');
assert_not_equals(element.accessKeyLabel, '');
}, 'Returns non empty string when accesskey is valid');
test(() => {
const element = createButtonWithAccessKey('s 0');
assert_equals(element.accessKeyLabel, '');
}, 'Returns empty string when accesskey is invalid');
</script>
</body>
</html>