Bug 1619852 - Fix the mistake in HTMLEditor::HandleDeleteCollapsedSelectionAtTextNode() r=m_kato

The check was written with `NS_ASSERTION`, but I realized that it's possible
case with mutation event listeners.  Therefore, I changed it to `if` and
`return`, but I forgot to revert the sign of inequality.

Differential Revision: https://phabricator.services.mozilla.com/D65280

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2020-03-04 06:22:23 +00:00
parent 65ea85a94c
commit 8bdbe3afd6
3 changed files with 36 additions and 1 deletions

View File

@ -2551,7 +2551,7 @@ EditActionResult HTMLEditor::HandleDeleteCollapsedSelectionAtTextNode(
NS_WARN_IF(!endToDelete.IsInTextNode()) || NS_WARN_IF(!endToDelete.IsInTextNode()) ||
NS_WARN_IF(startToDelete.ContainerAsText() != visibleTextNode) || NS_WARN_IF(startToDelete.ContainerAsText() != visibleTextNode) ||
NS_WARN_IF(endToDelete.ContainerAsText() != visibleTextNode) || NS_WARN_IF(endToDelete.ContainerAsText() != visibleTextNode) ||
NS_WARN_IF(startToDelete.Offset() <= endToDelete.Offset()))) { NS_WARN_IF(startToDelete.Offset() >= endToDelete.Offset()))) {
return EditActionHandled(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE); return EditActionHandled(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE);
} }
rv = DeleteTextWithTransaction(visibleTextNode, startToDelete.Offset(), rv = DeleteTextWithTransaction(visibleTextNode, startToDelete.Offset(),

View File

@ -226,6 +226,7 @@ skip-if = toolkit == 'android'
[test_bug1574596.html] [test_bug1574596.html]
skip-if = os == "android" #Bug 1575739 skip-if = os == "android" #Bug 1575739
[test_bug1581337.html] [test_bug1581337.html]
[test_bug1619852.html]
[test_abs_positioner_appearance.html] [test_abs_positioner_appearance.html]
[test_abs_positioner_positioning_elements.html] [test_abs_positioner_positioning_elements.html]
skip-if = os == 'android' # Bug 1525959 skip-if = os == 'android' # Bug 1525959

View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1619852
-->
<html>
<head>
<title>Test for Bug 1619852</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1619852">Bug 1619852</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
<div contenteditable>abcd</div>
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
let editor = document.querySelector("div[contenteditable]");
// Do nothing, but `HTMLEditor` may use different path to detect unexpected DOM tree or selection change.
editor.addEventListener("DOMNodeRemoved", () => {});
getSelection().collapse(editor.firstChild, 4);
synthesizeKey("KEY_Backspace");
is(editor.textContent, "abc", "The last character should've been removed by the Backspace");
getSelection().collapse(editor.firstChild, 1);
synthesizeKey("KEY_Backspace");
is(editor.textContent, "bc", "The first character should've been removed by the Backspace");
SimpleTest.finish();
});
</script>
</body>
</html>