blob: a4301e13516634e9fc09d1b8084091a2697b1f24 [file] [log] [blame]
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<iframe src="resources/frame-with-autofocus-element.html#anchor1"></iframe>
<iframe src="resources/frame-with-autofocus-element.html#non-existent-anchor"></iframe>
<script>
'use strict';
promise_test(async () => {
await waitForLoad(window);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, document.body,
'Autofocus elements in iframes should not be focused.');
let input = document.createElement('input');
input.autofocus = true;
document.body.appendChild(input);
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, input);
}, 'Autofocus elements in iframed documents with URL fragments should be skipped.');
promise_test(async () => {
let w = window.open('resources/frame-with-autofocus-element.html#xpointer(//body)');
await waitForLoad(w);
await waitUntilStableAutofocusState(w);
assert_equals(w.document.activeElement, w.document.body);
w.close();
}, 'Autofocus elements in top-level browsing context\'s documents with URI fragments should be skipped.');
</script>