Skip to content

Commit 524a064

Browse files
soosungp33chromium-wpt-export-bot
authored andcommitted
Implement HTMLElement accessKeyLabel
This patch implements accessKeyLabel API, matching the HTMLElement specification [1]. This CL helps solve the problem where users find it hard to know which accesskey modifier to press. This also improves interoperability with Safari and Firefox, which have already shipped this API. FYI, This implementation is currently behind a runtime flag. Intent to Prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/uzx6kTcS3hY [1] https://html.spec.whatwg.org/multipage/interaction.html#dom-accesskeylabel Bug: 41119923 Change-Id: I5d8dff04189baea410656fed3096a0c876f417fb
1 parent 49d8dc0 commit 524a064

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

html/dom/access-key-label.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<meta charset="UTF-8">
3+
<title>accessKeyLabel attribute</title>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<body>
7+
<script>
8+
function createButtonWithAccessKey(accessKey) {
9+
const button = document.createElement('button');
10+
button.setAttribute('accesskey', accessKey);
11+
return button;
12+
}
13+
14+
// The modifiers are not the same across all browser vendors.
15+
// Therefore, the test uses non empty.
16+
test(() => {
17+
const element = createButtonWithAccessKey('b');
18+
assert_not_equals(element.accessKeyLabel, '');
19+
}, 'Returns non empty string when accesskey is valid');
20+
21+
test(() => {
22+
const element = createButtonWithAccessKey('s 0');
23+
assert_equals(element.accessKeyLabel, '');
24+
}, 'Returns empty string when accesskey is invalid');
25+
</script>
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)