-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See whatwg/html#3987
- Loading branch information
Showing
9 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
html/semantics/interactive-elements/commands/common/accesskey.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
setup({explicit_done: true, explicit_timeout: true}); | ||
|
||
const NOTRUN = 3; | ||
let status = NOTRUN; | ||
function notrun() { | ||
return status === NOTRUN; | ||
} | ||
add_completion_callback(tests => { | ||
status = tests[0].status; | ||
}); | ||
|
||
function pass() { | ||
// Wait a couple of frames in case fail() is also called. | ||
requestAnimationFrame(() => { | ||
requestAnimationFrame(() => { | ||
if (notrun()) { | ||
test(() => {}); | ||
done(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function fail(msg) { | ||
if (notrun()) { | ||
test(() => { assert_unreached(msg); }); | ||
done(); | ||
} | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const accessKeyElement = document.querySelector('[accesskey]'); | ||
if (accessKeyElement.accessKeyLabel) { | ||
document.querySelector('kbd').textContent = accessKeyElement.accessKeyLabel; | ||
} | ||
}); |
10 changes: 10 additions & 0 deletions
10
html/semantics/interactive-elements/commands/legend/first-input-after-legend-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!doctype html> | ||
<title>First input after the legend</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=../common/accesskey.js></script> | ||
<p>Press the access key combination for "a". <kbd></kbd></p> | ||
<fieldset> | ||
<legend accesskey=a>legend</legend> | ||
<input onfocus="pass()"> | ||
</fieldset> |
13 changes: 13 additions & 0 deletions
13
html/semantics/interactive-elements/commands/legend/first-input-before-legend-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<title>First input before the legend</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=../common/accesskey.js></script> | ||
<p>Press the access key combination for "a". <kbd></kbd></p> | ||
<fieldset> | ||
<input onfocus="pass()"> | ||
<legend accesskey=a>legend | ||
<input onfocus="fail('input in legend was focused')"> | ||
</legend> | ||
<input onfocus="fail('input after legend was focused')"> | ||
</fieldset> |
12 changes: 12 additions & 0 deletions
12
html/semantics/interactive-elements/commands/legend/first-input-inside-legend-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<title>First input inside the legend</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=../common/accesskey.js></script> | ||
<p>Press the access key combination for "a". <kbd></kbd></p> | ||
<fieldset> | ||
<legend accesskey=a>legend | ||
<input onfocus="pass()"> | ||
</legend> | ||
<input onfocus="fail('input after legend was focused')"> | ||
</fieldset> |
14 changes: 14 additions & 0 deletions
14
html/semantics/interactive-elements/commands/legend/focusable-legend-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<title>Focusable legend</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=../common/accesskey.js></script> | ||
<p>Press the access key combination for "a". <kbd></kbd></p> | ||
<fieldset> | ||
<legend tabindex=0 onclick="fail('unexpected click event on legend')" | ||
onfocus="fail('legend was focused')" accesskey=a> | ||
legend | ||
<input onfocus="pass()"> | ||
</legend> | ||
<input onfocus="fail('input after legend was focused')"> | ||
</fieldset> |
17 changes: 17 additions & 0 deletions
17
html/semantics/interactive-elements/commands/legend/focusable-legend-sibling-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!doctype html> | ||
<title>Focusable legend sibling</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=../common/accesskey.js></script> | ||
<p>Press the access key combination for "a". <kbd></kbd></p> | ||
<fieldset> | ||
<legend accesskey=a>first legend</legend> | ||
<legend tabindex=0 onfocus="fail('sibling legend was focused')">second legend</legend> | ||
</fieldset> | ||
<script> | ||
onkeyup = e => { | ||
if (e.keyCode === 65) { | ||
pass(); | ||
} | ||
} | ||
</script> |
17 changes: 17 additions & 0 deletions
17
html/semantics/interactive-elements/commands/legend/input-outside-fieldset-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!doctype html> | ||
<title>Input outside fieldset</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=../common/accesskey.js></script> | ||
<p>Press the access key combination for "a". <kbd></kbd></p> | ||
<fieldset> | ||
<legend accesskey=a>legend</legend> | ||
</fieldset> | ||
<input onfocus="fail('input outside fieldset was focused')"> | ||
<script> | ||
onkeyup = e => { | ||
if (e.keyCode === 65) { | ||
pass(); | ||
} | ||
} | ||
</script> |
18 changes: 18 additions & 0 deletions
18
html/semantics/interactive-elements/commands/legend/label-sibling-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!doctype html> | ||
<title>Label sibling</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=../common/accesskey.js></script> | ||
<p>Press the access key combination for "a". <kbd></kbd></p> | ||
<input id=x onfocus="fail('input associated with the label was focused')"> | ||
<fieldset> | ||
<legend accesskey=a>legend</legend> | ||
<label for=x onclick="fail('label received a click event')">label</label> | ||
</fieldset> | ||
<script> | ||
onkeyup = e => { | ||
if (e.keyCode === 65) { | ||
pass(); | ||
} | ||
} | ||
</script> |
18 changes: 18 additions & 0 deletions
18
html/semantics/interactive-elements/commands/legend/no-fieldset-parent-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!doctype html> | ||
<title>No fieldset parent</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=../common/accesskey.js></script> | ||
<p>Press the access key combination for "a". <kbd></kbd></p> | ||
<legend accesskey=a> | ||
legend | ||
<input onfocus="fail('input in legend was focused')"> | ||
</legend> | ||
<input onfocus="fail('input after legend was focused')"> | ||
<script> | ||
onkeyup = e => { | ||
if (e.keyCode === 65) { | ||
pass(); | ||
} | ||
} | ||
</script> |