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_bug1250010.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_bug1250010.html | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_bug1250010.html b/editor/libeditor/tests/test_bug1250010.html new file mode 100644 index 0000000000..4113ecdb29 --- /dev/null +++ b/editor/libeditor/tests/test_bug1250010.html @@ -0,0 +1,87 @@ +<!DOCTYPE> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1250010 +--> +<head> + <title>Test for Bug 1250010</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"> + <script src="/tests/SimpleTest/EventUtils.js"></script> +</head> +<body> +<div id="display"> +</div> + +<div id="test1" contenteditable><p><b><font color="red">1234567890</font></b></p></div> +<div id="test2" contenteditable><p><tt>xyz</tt></p><p><tt><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAIAAABvrngfAAAAFklEQVQImWMwjWhCQwxECoW3oCHihAB0LyYv5/oAHwAAAABJRU5ErkJggg=="></tt></p></div> + +<pre id="test"> +</pre> + +<script class="testbody" type="application/javascript"> + +function getImageDataURI() { + return document.getElementsByTagName("img")[0].getAttribute("src"); +} + +/** Test for Bug 1250010 **/ +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(function() { + // First test: Empty paragraph is split correctly. + var div = document.getElementById("test1"); + div.focus(); + synthesizeMouseAtCenter(div, {}); + + var sel = window.getSelection(); + var selRange = sel.getRangeAt(0); + is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node"); + is(selRange.endOffset, 10, "offset should be 10"); + + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Enter"); + sendString("b"); + synthesizeKey("KEY_ArrowUp"); + sendString("a"); + + is(div.innerHTML, "<p><b><font color=\"red\">1234567890</font></b></p>" + + "<p><b><font color=\"red\">a<br></font></b></p>" + + "<p><b><font color=\"red\">b<br></font></b></p>", + "unexpected HTML"); + + // Second test: Since we modified the code path that splits non-text nodes, + // test that this works, if the split node is not empty. + div = document.getElementById("test2"); + div.focus(); + synthesizeMouseAtCenter(div, {}); + + selRange = sel.getRangeAt(0); + is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node"); + is(selRange.endOffset, 3, "offset should be 3"); + + // Move behind the image and press enter, insert an "A". + // That should insert a new empty paragraph with the "A" after what we have. + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Enter"); + sendString("A"); + + // TODO: The <br> in the new paragraph and the paragraph containing the <img> + // should be removed at typing "A" because they are not necessary + // anymore to make the paragraphs visible (bug 503838). + const expectedHTML = + "<p><tt>xyz</tt></p><p><tt><img src=\"" + getImageDataURI() + "\"><br></tt></p>" + + "<p><tt>A<br></tt></p>"; + is( + div.innerHTML, + expectedHTML, + "Pressing Enter after the <img> should create new paragraph and which contain <tt> and new text should be inserted in it" + ); + + SimpleTest.finish(); +}); + +</script> +</body> + +</html> |