-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
html: Update autofocus tests in cases of documents with fragments
Specification change: whatwg/html#6204 Issue: whatwg/html#5252
- Loading branch information
1 parent
009fb03
commit 0bc38db
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
html/interaction/focus/the-autofocus-attribute/document-with-fragment-empty.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,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#"></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 empty fragments should work.'); | ||
|
||
promise_test(async () => { | ||
let w = window.open('resources/frame-with-autofocus-element.html#'); | ||
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 empty fragments should work.'); | ||
</script> |
31 changes: 31 additions & 0 deletions
31
html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent.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,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_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> |
31 changes: 31 additions & 0 deletions
31
html/interaction/focus/the-autofocus-attribute/document-with-fragment-top.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,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#top"></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 "top" fragments should work.'); | ||
|
||
promise_test(async () => { | ||
let w = window.open('resources/frame-with-autofocus-element.html#top'); | ||
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 "top" fragments should work.'); | ||
</script> |
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