Skip to content

Commit

Permalink
Bug 1593925 [wpt PR 20083] - autofocus: Add tests for delegatesFocus …
Browse files Browse the repository at this point in the history
…and <area>., a=testonly

Automatic update from web-platform-tests
autofocus: Add tests for delegatesFocus and <area>

Follows whatwg/html#5059.
--

wpt-commits: 4cfddceea40940f2d8290bb92d081824fe781942
wpt-pr: 20083
  • Loading branch information
tkent-google authored and moz-wptsync-bot committed Nov 29, 2019
1 parent 857ec79 commit d5913b2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE html>
<body>
<img src="/media/poster.png" usemap="#map">
<map name="map"></map>
</body>
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,50 @@
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement.tagName, 'BODY');
}, 'Non-HTMLElement should not support autofocus');

promise_test(async t => {
let w = window.open('/common/blank.html');
await waitForLoad(w);
t.add_cleanup(() => { w.close(); });
const host = w.document.createElement('div');
host.autofocus = true;
const shadow = host.attachShadow({mode:'closed', delegatesFocus:true});
shadow.appendChild(w.document.createElement('input'));
w.document.body.appendChild(host);
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement, host);
assert_equals(shadow.activeElement.tagName, 'INPUT');
}, 'Host element with delegatesFocus should support autofocus');

promise_test(async t => {
let w = window.open('/common/blank.html');
await waitForLoad(w);
t.add_cleanup(() => { w.close(); });
const host = w.document.createElement('div');
host.autofocus = true;
host.attachShadow({mode:'closed', delegatesFocus:true});
w.document.body.appendChild(host);
const next = w.document.createElement('input');
next.autofocus = true;
w.document.body.appendChild(next);
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement, next);
}, 'Host element with delegatesFocus including no focusable descendants should be skipped');

promise_test(async t => {
let w = window.open('./resources/imagemap.html');
await waitForLoad(w);
t.add_cleanup(() => { w.close(); });
const area = w.document.createElement('area');
area.autofocus = true;
area.shape = 'rect';
area.coords = '1,1,99,99';
area.href = '/common/blank.html';
w.document.querySelector('map').appendChild(area);
await waitUntilStableAutofocusState(w);
// According to the specification, DOM anchor for an AREA shape is an IMG
// element, but major browsers don't follow it.
// See https://github.com/whatwg/html/issues/5054
assert_equals(w.document.activeElement, area);
}, 'Area element should support autofocus');
</script>

0 comments on commit d5913b2

Please sign in to comment.