diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /editor/libeditor/tests/test_bug1258085.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | editor/libeditor/tests/test_bug1258085.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_bug1258085.html b/editor/libeditor/tests/test_bug1258085.html new file mode 100644 index 0000000000..4d8e1ef888 --- /dev/null +++ b/editor/libeditor/tests/test_bug1258085.html @@ -0,0 +1,66 @@ +<!DOCTYPE html> +<title>Test for Bug 1258085</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +<div contenteditable></div> +<script> +var div = document.querySelector("div"); + +function reset() { + div.innerHTML = "x<br> y"; + div.focus(); + synthesizeKey("KEY_ArrowDown"); +} + +function checks(msg) { + is(div.innerHTML, "x<br><br>", + msg + ": Should add a second <br> to prevent collapse of first"); + is(div.childNodes.length, 3, msg + ": No empty text nodes allowed"); + ok(getSelection().isCollapsed, msg + ": Selection must be collapsed"); + is(getSelection().focusNode, div, msg + ": Focus must be in div"); + is(getSelection().focusOffset, 2, + msg + ": Focus must be between the two <br>s"); +} + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(function() { + // Put selection after the "y" and backspace + reset(); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Backspace"); + checks("Collapsed backspace"); + + // Now do the same with delete + reset(); + synthesizeKey("KEY_Delete"); + checks("Collapsed delete"); + + // Forward selection + reset(); + synthesizeKey("KEY_ArrowRight", {shiftKey: true}); + synthesizeKey("KEY_Backspace"); + checks("Forward-selected backspace"); + + // Backward selection + reset(); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowLeft", {shiftKey: true}); + synthesizeKey("KEY_Backspace"); + checks("Backward-selected backspace"); + + // Make sure we're not deleting if the whitespace isn't actually collapsed + div.style.whiteSpace = "pre-wrap"; + reset(); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Backspace"); + is(div.innerHTML, "x<br> ", "pre-wrap: Don't delete uncollapsed space"); + ok(getSelection().isCollapsed, "pre-wrap: Selection must be collapsed"); + is(getSelection().focusNode, div.lastChild, + "pre-wrap: Focus must be in final text node"); + is(getSelection().focusOffset, 1, "pre-wrap: Focus must be at end of node"); + + SimpleTest.finish(); +}); +</script> |