mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update web-platform-tests to revision 1ac959f3e6198767fecf67740d3e1687b184265f
This commit is contained in:
parent
4f4e219e54
commit
33079866c1
61 changed files with 1114 additions and 284 deletions
|
@ -0,0 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
function waitForEvent(target, type, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
target.addEventListener(type, resolve, options);
|
||||
});
|
||||
}
|
||||
|
||||
function waitForLoad(target) {
|
||||
return waitForEvent(target, 'load');
|
||||
}
|
||||
|
||||
function timeOut(test, ms) {
|
||||
return new Promise((resolve, reject) => {
|
||||
test.step_timeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
|
||||
// If an element with autofocus is connected to a document and this function
|
||||
// is called, the autofocus result is deterministic after returning from the
|
||||
// function.
|
||||
// Exception: If the document has script-blocking style sheets, this function
|
||||
// doesn't work well.
|
||||
async function waitUntilStableAutofocusState(test) {
|
||||
// TODO: Update this for https://github.com/web-platform-tests/wpt/pull/17929
|
||||
await timeOut(test, 100);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/utils.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
promise_test(async t => {
|
||||
let w = window.open('/common/blank.html');
|
||||
await waitForLoad(w);
|
||||
t.add_cleanup(() => { w.close(); });
|
||||
w.document.body.innerHTML = '<div contenteditable=true autofocus></div>';
|
||||
await waitUntilStableAutofocusState(t);
|
||||
assert_equals(w.document.activeElement.tagName, 'DIV');
|
||||
}, 'Contenteditable element should support autofocus');
|
||||
|
||||
promise_test(async t => {
|
||||
let w = window.open('/common/blank.html');
|
||||
await waitForLoad(w);
|
||||
t.add_cleanup(() => { w.close(); });
|
||||
w.document.body.innerHTML = '<span tabindex=0></span>';
|
||||
await waitUntilStableAutofocusState(t);
|
||||
assert_equals(w.document.activeElement.tagName, 'SPAN');
|
||||
}, 'Element with tabindex should support autofocus');
|
||||
|
||||
promise_test(async t => {
|
||||
let w = window.open('/common/blank.html');
|
||||
await waitForLoad(w);
|
||||
t.add_cleanup(() => { w.close(); });
|
||||
let element = w.document.createElementNS('uri1', 'prefix:local');
|
||||
element.setAttribute('autofocus', '');
|
||||
w.document.body.appendChild(element);
|
||||
await waitUntilStableAutofocusState(t);
|
||||
assert_equals(w.document.activeElement.tagName, 'BODY');
|
||||
}, 'Non-HTMLElement should not support autofocus');
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue