diff options
Diffstat (limited to 'testing/web-platform/tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent.html')
-rw-r--r-- | testing/web-platform/tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent.html | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent.html b/testing/web-platform/tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent.html new file mode 100644 index 0000000000..3f2dcc4167 --- /dev/null +++ b/testing/web-platform/tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent.html @@ -0,0 +1,31 @@ +<!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#non-existent"></iframe> + +<script> +'use strict'; + +promise_test(async () => { + await waitForLoad(window); + await waitUntilStableAutofocusState(); + assert_equals(document.activeElement, document.querySelector('iframe'), + 'Autofocus elements in iframes should be focused.'); + + let input = document.createElement('input'); + input.autofocus = true; + document.body.appendChild(input); + await waitUntilStableAutofocusState(); + assert_not_equals(document.activeElement, input); +}, 'Autofocus elements in iframed documents with non-existent fragments should work.'); + +promise_test(async () => { + let w = window.open('resources/frame-with-autofocus-element.html#non-existent'); + await waitForLoad(w); + await waitUntilStableAutofocusState(w); + assert_not_equals(w.document.activeElement, w.document.body); + w.close(); +}, 'Autofocus elements in top-level browsing context\'s documents with non-existent fragments should work.'); +</script> |