Commit d6f98378 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

autofocus: Import recent test changes manually.

wpt-importer doesn't work well now.

TBR=rakina@chromium.org

Bug: 985637
Change-Id: I4aeedb0fcb5c144e8dc4fb1b8856af1fe9a7d942
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1910979
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714362}
parent 0b3919b8
<!DOCTYPE html>
<body>
<img src="/media/poster.png" usemap="#map">
<map name="map"></map>
</body>
This is a testharness.js-based test.
PASS Contenteditable element should support autofocus
PASS Element with tabindex should support autofocus
PASS Non-HTMLElement should not support autofocus
PASS Host element with delegatesFocus should support autofocus
FAIL Host element with delegatesFocus including no focusable descendants should be skipped assert_equals: expected Element node <input autofocus=""></input> but got Element node <body><div autofocus=""></div><input autofocus=""></body>
PASS Area element should support autofocus
Harness: the test ran to completion.
......@@ -34,4 +34,50 @@ promise_test(async t => {
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>
This is a testharness.js-based test.
FAIL An autofocus element in a dialog element should not try to get focus twice. assert_equals: Non-dialog autofocus processing should be skipped. expected Element node <body>
<dialog open="">
<input>
<input autofocus="">
</di... but got Element node <input autofocus=""></input>
Harness: the test ran to completion.
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script>
<body>
<dialog>
<input>
<input autofocus>
</dialog>
<script>
// https://github.com/whatwg/html/issues/4788
promise_test(async () => {
const dialog = document.querySelector('dialog');
dialog.show();
assert_equals(document.activeElement, dialog.querySelector('[autofocus]'),
'dialog.show() should set focus on a descendant element with an ' +
'autofocus attribute.');
document.activeElement.blur();
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, document.body,
'Non-dialog autofocus processing should be skipped.');
}, 'An autofocus element in a dialog element should not try to get focus twice.');
</script>
</body>
This is a testharness.js-based test.
FAIL After showing a dialog, non-dialog autofocus processing won't work. assert_equals: Non-dialog autofocus processing should be skipped. expected Element node <body>
<input autofocus=""><dialog></dialog>
<script>
// ... but got Element node <input autofocus=""></input>
Harness: the test ran to completion.
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script>
<body>
<dialog></dialog>
<script>
// https://github.com/whatwg/html/issues/4788
promise_test(async () => {
const dialog = document.querySelector('dialog');
dialog.show();
dialog.close();
const input = document.createElement('input');
input.autofocus = true;
document.body.insertBefore(input, dialog);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, document.body,
'Non-dialog autofocus processing should be skipped.');
}, 'After showing a dialog, non-dialog autofocus processing won\'t work.');
</script>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment