forked from mykmelez/gecko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1569133 [wpt PR 17929] - html: Update tests for an autofocus algo…
…rithm update, a=testonly Automatic update from web-platform-tests html: Update tests for an autofocus algorithm update (#17929) whatwg/html#4763 -- wpt-commits: 08e6411a9cb36e4e7987d24ddb31e1d62690e1cb wpt-pr: 17929
- Loading branch information
1 parent
8b4cbec
commit f79b0bd
Showing
20 changed files
with
315 additions
and
36 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
testing/web-platform/tests/html/semantics/forms/autofocus/autofocus-on-stable-document.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,21 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
|
||
<body> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test(async t => { | ||
await waitForLoad(window); | ||
await timeOut(t, 1000); | ||
let element = document.createElement('input'); | ||
element.autofocus = true; | ||
document.body.appendChild(element); | ||
await waitUntilStableAutofocusState(); | ||
assert_equals(document.activeElement, element); | ||
}, 'Autofocus should work if an element with autofocus is inserted into a ' + | ||
'document which was loaded some time ago.'); | ||
</script> | ||
</body> |
22 changes: 22 additions & 0 deletions
22
testing/web-platform/tests/html/semantics/forms/autofocus/first-reconnected.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,22 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
|
||
<input autofocus id="i1"> | ||
<input autofocus id="i2"> | ||
<script> | ||
"use strict"; | ||
|
||
promise_test(async () => { | ||
const input1 = document.querySelector("#i1"); | ||
const input2 = document.querySelector("#i2"); | ||
input1.remove(); | ||
input2.parentNode.insertBefore(input1, input2); | ||
|
||
await waitUntilStableAutofocusState(); | ||
assert_equals(document.activeElement, input2); | ||
}, 'The second autofocus element wins if the first autofocus element was ' + | ||
'disconnected and reconnected before flushing the autofocus candidates.'); | ||
</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
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
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
24 changes: 24 additions & 0 deletions
24
...ing/web-platform/tests/html/semantics/forms/autofocus/focusable-area-in-top-document.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,24 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
|
||
<iframe srcdoc="<input><script>document.querySelector('input').focus();</script>"></iframe> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
await waitForLoad(window); | ||
let iframe = document.querySelector('iframe'); | ||
assert_equals(document.activeElement, iframe, 'Prereq: IFRAME should be focused'); | ||
|
||
let input = document.createElement('input'); | ||
input.autofocus = true; | ||
document.body.appendChild(input); | ||
|
||
await waitUntilStableAutofocusState(); | ||
assert_equals(document.activeElement, iframe, 'activeElement should not be changed'); | ||
assert_not_equals(document.activeElement, input); | ||
}, 'If topDocument\'s focused area is not topDocument, autofocus is not processed.'); | ||
</script> |
17 changes: 17 additions & 0 deletions
17
...ng/web-platform/tests/html/semantics/forms/autofocus/no-sandboxed-automatic-features.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,17 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
|
||
<iframe sandbox srcdoc="<input autofocus>"></iframe> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
await waitForLoad(window); | ||
await waitUntilStableAutofocusState(); | ||
assert_not_equals(document.activeElement, document.querySelector('iframe')); | ||
}, 'If the sandboxed automatic features browsing context flag is set, ' + | ||
'autofocus in the browsing context should not be handled.'); | ||
</script> |
20 changes: 20 additions & 0 deletions
20
testing/web-platform/tests/html/semantics/forms/autofocus/queue-non-focusable.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,20 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
|
||
<textarea autofocus disabled></textarea> | ||
<select autofocus></select> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
const [textarea, select] = document.querySelectorAll('[autofocus]'); | ||
textarea.disabled = false; | ||
|
||
await waitUntilStableAutofocusState(); | ||
assert_equals(document.activeElement, textarea); | ||
assert_not_equals(document.activeElement, select); | ||
}, 'If the first autofocus element is not focusable, but becomes focusable before a frame, it should be focused.'); | ||
</script> |
3 changes: 3 additions & 0 deletions
3
testing/web-platform/tests/html/semantics/forms/autofocus/resources/erase-first.css
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,3 @@ | ||
#first { | ||
display: none; | ||
} |
5 changes: 5 additions & 0 deletions
5
...platform/tests/html/semantics/forms/autofocus/resources/frame-with-autofocus-element.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,5 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<div id="anchor1"></div> | ||
<input autofocus> | ||
</body> |
10 changes: 10 additions & 0 deletions
10
...b-platform/tests/html/semantics/forms/autofocus/resources/moving-autofocus-to-parent.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,10 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script> | ||
const input = document.createElement('input'); | ||
input.autofocus = true; | ||
document.body.appendChild(input); | ||
input.autofocus = false; | ||
window.opener.document.body.appendChild(input); | ||
</script> | ||
</body> |
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
17 changes: 17 additions & 0 deletions
17
...latform/tests/html/semantics/forms/autofocus/skip-another-top-level-browsing-context.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,17 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
let w = window.open('resources/moving-autofocus-to-parent.html'); | ||
await waitForLoad(w); | ||
await waitUntilStableAutofocusState(w); | ||
assert_equals(w.document.activeElement, w.document.body); | ||
assert_equals(document.activeElement, document.body); | ||
w.close(); | ||
}, 'Autofocus elements queued in another top-level browsing context\'s ' + | ||
'documents should be skipped.'); | ||
</script> |
32 changes: 32 additions & 0 deletions
32
testing/web-platform/tests/html/semantics/forms/autofocus/skip-document-with-fragment.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,32 @@ | ||
<!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> |
19 changes: 19 additions & 0 deletions
19
testing/web-platform/tests/html/semantics/forms/autofocus/skip-non-focusable.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,19 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
|
||
<textarea autofocus disabled></textarea> | ||
<select autofocus></select> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
const [textarea, select] = document.querySelectorAll('[autofocus]'); | ||
|
||
await waitUntilStableAutofocusState(); | ||
assert_not_equals(document.activeElement, textarea); | ||
assert_equals(document.activeElement, select); | ||
}, 'Non-focusable autofocus element is skipped.'); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
testing/web-platform/tests/html/semantics/forms/autofocus/skip-not-fully-active.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,18 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
|
||
<iframe srcdoc="<input autofocus><script>window.frameElement.remove();</script>"></iframe> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
let iframe = document.querySelector('iframe'); | ||
let iframeDocument = iframe.contentDocument; | ||
await waitForLoad(window); | ||
assert_not_equals(document.activeElement, iframe); | ||
assert_equals(iframeDocument.activeElement, iframeDocument.body); | ||
}, 'Autofocus element in not-fully-active document should be skipped.'); | ||
</script> |
17 changes: 17 additions & 0 deletions
17
testing/web-platform/tests/html/semantics/forms/autofocus/spin-by-blocking-style-sheet.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,17 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
<link rel="stylesheet" href="resources/erase-first.css?pipe=trickle(d1)"> | ||
|
||
<input id="first" autofocus> | ||
<input id="second" autofocus> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
await waitForEvent(document.body, 'focus', {capture:true}); | ||
assert_equals(document.activeElement.id, 'second'); | ||
}, 'Script-blocking style sheet should pause flushing autofocus candidates.'); | ||
</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
Oops, something went wrong.