Bug 1681800 - Don't notify of refocus when element is non focusable root. r=masayuki

It is unnecessary to notify of IME re-focus when element is root element and
not focusable.

Differential Revision: https://phabricator.services.mozilla.com/D103980
This commit is contained in:
Makoto Kato 2021-02-04 04:52:49 +00:00
parent 7067bbd819
commit b84c89bda5
3 changed files with 30 additions and 0 deletions

View File

@ -4888,6 +4888,9 @@ void nsFocusManager::NotifyOfReFocus(nsIContent& aContent) {
if (!window || window != mFocusedWindow) {
return;
}
if (!aContent.IsInComposedDoc() || IsNonFocusableRoot(&aContent)) {
return;
}
nsIDocShell* docShell = window->GetDocShell();
if (!docShell) {
return;

View File

@ -236,6 +236,7 @@ support-files = file_bug1484371.html
skip-if = toolkit == 'android' # Bug 1312791
[test_bug1581192.html]
[test_bug1673434.html]
[test_bug1681800.html]
[test_dnd_with_modifiers.html]
[test_hover_mouseleave.html]
[test_marquee_events.html]

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<!--
bugzilla.mozilla.org/show_bug.cgi?id=1681800
-->
<head>
<title>Test for bug 1681800</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1681800">Mozilla Bug 1681800</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script>
add_task(function() {
document.documentElement.focus({})
document.documentElement.focus({})
ok(true, "no crash");
})
</script>
</pre>
</body>
</html>