Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/editing/focus/focus-management/focusing-disconnected-noop.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Focusing a disconnected node is a no-op</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
test(() => {
const button = document.createElement("button");
let handleFocusCallCount = 0;
button.addEventListener("focus", () => {
handleFocusCallCount += 1;
});
button.focus();
assert_equals(handleFocusCallCount, 0);
assert_equals(document.activeElement, document.body);
}, "focusing a focused element must not dispatch focus events or change activeElement");
</script>