Created attachment 456025 [details] HTML test case When no element is focused in a document, the element to which keyboard events are dispatched is different in XHTML vs HTML documents. Steps to reproduce: 1. Open attached test.html 2. Focus the document, press some keys and note the `target` property of events logged in the browser console 3. Repeat steps 1 and 2 with attached test.xhtml Ideally the keyboard events would be fired at the same element in both HTML and XHTML documents. In Safari and Chrome the keyboard events are fired at the body element for HTML documents and the document element for XHTML documents. In Firefox the keyboard events are fired at the document body for both document types. For XHTML documents that do not have a body element, Firefox fires events at the document element instead, which seems like reasonable fallback behavior. We encountered this issue when investigating a bug in our web app where a keyboard shortcut handler, installed on the document body, didn't work when the code was loaded in an XHTML document.
Created attachment 456026 [details] XHTML test case
Related Chrome issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1311257#c1
<rdar://problem/91294819>