summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/test_bug1250010.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /editor/libeditor/tests/test_bug1250010.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'editor/libeditor/tests/test_bug1250010.html')
-rw-r--r--editor/libeditor/tests/test_bug1250010.html93
1 files changed, 93 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_bug1250010.html b/editor/libeditor/tests/test_bug1250010.html
new file mode 100644
index 000000000..d1e0154dc
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1250010.html
@@ -0,0 +1,93 @@
+<!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("VK_RETURN", {});
+ synthesizeKey("VK_RETURN", {});
+ synthesizeKey("b", {});
+ synthesizeKey("VK_UP", {});
+ synthesizeKey("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("VK_RIGHT", {});
+ synthesizeKey("VK_RIGHT", {});
+ synthesizeKey("VK_RETURN", {});
+ synthesizeKey("A", {});
+
+ // The resulting HTML is sadly less than optimal:
+ // A <br> gets inserted after the image and the "A" is followed by an empty <tt></tt>.
+ var newHTML = div.innerHTML;
+ var expectedHTML;
+ // Existing part with additional <br> inserted.
+ expectedHTML = "<p><tt>xyz</tt></p><p><tt><img src=\"" + getImageDataURI() + "\"><br></tt></p>" +
+ // New part caused by pressing enter after the image and typing an "A".
+ "<p><tt>A</tt><br><tt></tt></p>";
+ is(newHTML, expectedHTML, "unexpected HTML");
+
+ // In case the empty tag gets deleted some day, let them know that something improved.
+ expectedHTML = "<p><tt>xyz</tt></p><p><tt><img src=\"" + getImageDataURI() + "\"><br></tt></p>" +
+ "<p><tt>A</tt><br></p>";
+ todo_is(newHTML, expectedHTML, "unexpected HTML");
+
+ SimpleTest.finish();
+
+});
+
+</script>
+</body>
+
+</html>