forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1755104 - Make
EditorEventListener::Focus
check whether the eve…
…nt target still has focus even after flushing the pending things r=m_kato When the `focus` event listener of editors which is in the system group runs, a preceding `focus` event listener may have already blurred the focused element, but it may have not been applied to the DOM tree yet. In this case, checking whether the editor still has focus or has already blurred without flushing the pending things does not make sense. Therefore, this patch makes the `Focus` do it first. Note that this patch adds 3 crash tests, but only the `<textarea>` case crashes without this patch. The others are only for detecting new regressions. Differential Revision: https://phabricator.services.mozilla.com/D139089
- Loading branch information
1 parent
f9fa9e0
commit 9874524
Showing
5 changed files
with
112 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...orm/tests/editing/crashtests/contenteditable-will-be-blurred-by-focus-event-listener.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html class="test-wait"> | ||
<meta charset="utf-8"> | ||
<script> | ||
addEventListener("load", () => { | ||
const editingHost = document.querySelector("div[contenteditable]"); | ||
editingHost.addEventListener("focus", () => { | ||
document.execCommand("insertText", false, "def"); | ||
editingHost.parentElement.setAttribute("hidden", "hidden"); | ||
setTimeout(() => document.documentElement.removeAttribute("class"), 0); | ||
}); | ||
editingHost.focus(); | ||
}); | ||
</script> | ||
<div><div contenteditable>abc</div></div> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
...tests/editing/crashtests/designMode-document-will-be-blurred-by-focus-event-listener.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html class="test-wait"> | ||
<meta charset="utf-8"> | ||
<script> | ||
addEventListener("load", () => { | ||
const parentDocument = document; | ||
const iframe = parentDocument.querySelector("iframe"); | ||
iframe.contentDocument.designMode = "on"; | ||
iframe.contentWindow.addEventListener("focus", () => { | ||
iframe.contentDocument.execCommand("insertText", false, "def"); | ||
iframe.parentElement.setAttribute("hidden", "hidden"); | ||
setTimeout(() => parentDocument.documentElement.removeAttribute("class"), 0); | ||
}); | ||
iframe.contentWindow.focus(); | ||
}); | ||
</script> | ||
<div><iframe srcdoc="<div>abc</div>"></iframe></div> | ||
</html> |
16 changes: 16 additions & 0 deletions
16
...b-platform/tests/editing/crashtests/textarea-will-be-blurred-by-focus-event-listener.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html class="test-wait"> | ||
<meta charset="utf-8"> | ||
<script> | ||
addEventListener("load", () => { | ||
const textarea = document.querySelector("textarea"); | ||
textarea.addEventListener("focus", () => { | ||
textarea.select(); | ||
textarea.parentElement.setAttribute("hidden", "hidden"); | ||
setTimeout(() => document.documentElement.removeAttribute("class"), 0); | ||
}); | ||
textarea.focus(); | ||
}); | ||
</script> | ||
<div><textarea>abc</textarea></div> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters