Automatic update from web-platform-tests Add tests for autofocus content/IDL attribute on MathML elements. https://github.com/whatwg/html/pull/12416 https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute https://w3c.github.io/mathml-core/#dfn-autofocus -- wpt-commits: 4cc9a18629dffa80639bb996b56211ac13d5b29d wpt-pr: 59816
38 lines
1.4 KiB
HTML
38 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<title>MathML autofocus attribute</title>
|
|
<link rel="help" content="https://w3c.github.io/mathml-core/#dfn-autofocus">
|
|
<script src="/mathml/support/mathml-fragments.js"></script>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<div id="log"></div>
|
|
<script>
|
|
var t = async_test("dynamically set autofocus on element");
|
|
let div = document.createElement("div");
|
|
|
|
// Create the MathML element with dynamically set autofocus.
|
|
var element = FragmentHelper.createElement("math");
|
|
test(_ => {
|
|
assert_false(element.autofocus);
|
|
assert_false(element.hasAttribute("autofocus"));
|
|
element.autofocus = true;
|
|
assert_true(element.autofocus);
|
|
assert_true(element.hasAttribute("autofocus"));
|
|
}, "setting autofocus attribute");
|
|
element.tabIndex = 1;
|
|
element.innerHTML = "<mtext>math</mtext>";
|
|
element.addEventListener("focus", t.step_func_done(function(e) {
|
|
assert_true(document.activeElement == e.target, "<mrow> element is focused");
|
|
}, "focus() called on <mrow> element"));
|
|
div.appendChild(element);
|
|
|
|
// Create the input tag to finish early in case of failure.
|
|
let input = document.createElement("input");
|
|
input.autofocus = true;
|
|
input.value = "input";
|
|
input.addEventListener("focus",
|
|
t.unreached_func("focus() shouldn't be called on `<input>`"));
|
|
div.appendChild(input);
|
|
|
|
document.body.appendChild(div);
|
|
</script>
|