[evolution/wip/mcrha/webkit-jsc-api] test-html-editor-units: Adapt few more /bug tests and fix found bugs in the new code



commit 74a00172311a4a826dcf2305a8a18ef0fb0b8409
Author: Milan Crha <mcrha redhat com>
Date:   Thu Mar 26 19:46:18 2020 +0100

    test-html-editor-units: Adapt few more /bug tests and fix found bugs in the new code

 data/webkit/e-convert.js                 |  31 +++-
 data/webkit/e-editor.js                  | 270 ++++++++++++++++++++++++-------
 data/webkit/e-undo-redo.js               |  14 +-
 src/e-util/test-html-editor-units-bugs.c | 181 +++++++++++++++------
 4 files changed, 380 insertions(+), 116 deletions(-)
---
diff --git a/data/webkit/e-convert.js b/data/webkit/e-convert.js
index 3ec213548d..d7d9cd9f93 100644
--- a/data/webkit/e-convert.js
+++ b/data/webkit/e-convert.js
@@ -467,7 +467,7 @@ EvoConvert.formatParagraph = function(str, ltr, align, indent, whiteSpace, wrapW
                                        worker.line = worker.line.substr(jj);
                                        worker.maybeRecalcIgnoreLineLetters();
                                        didWrap = true;
-                               } else if (worker.lastWasWholeLine && worker.line == "") {
+                               } else if (worker.collapseWhiteSpace && worker.lastWasWholeLine && 
worker.line == "") {
                                        worker.lastWasWholeLine = false;
                                } else {
                                        lines[lines.length] = worker.line;
@@ -698,6 +698,31 @@ EvoConvert.extractElemText = function(elem, normalDivWidth, quoteLevel)
        return str;
 }
 
+EvoConvert.mergeConsecutiveSpaces = function(str)
+{
+       if (str.indexOf("  ") >= 0) {
+               var words = str.split(" "), ii, word;
+
+               str = "";
+
+               for (ii = 0; ii < words.length; ii++) {
+                       word = words[ii];
+
+                       if (word) {
+                               if (ii)
+                                       str += " ";
+
+                               str += word;
+                       }
+               }
+
+               if (!words[words.length - 1])
+                       str += " ";
+       }
+
+       return str;
+}
+
 EvoConvert.processNode = function(node, normalDivWidth, quoteLevel)
 {
        var str = "";
@@ -715,12 +740,12 @@ EvoConvert.processNode = function(node, normalDivWidth, quoteLevel)
                                whiteSpace = window.getComputedStyle(node.parentElement).whiteSpace;
 
                        if (whiteSpace == "pre-line") {
-                               str = str.replace(/\t/g, " ").replace(/  /g, " ");
+                               str = EvoConvert.mergeConsecutiveSpaces(str.replace(/\t/g, " "));
                        } else if (!whiteSpace || whiteSpace == "normal" || whiteSpace == "nowrap") {
                                if (str == "\n" || str == "\r" || str == "\r\n")
                                        str = "";
                                else
-                                       str = str.replace(/\t/g, " ").replace(/\r/g, " ").replace(/\n/g, " 
").replace(/  /g, " ");
+                                       str = EvoConvert.mergeConsecutiveSpaces(str.replace(/\t/g, " 
").replace(/\r/g, " ").replace(/\n/g, " "));
                        }
                }
        } else if (node.nodeType == node.ELEMENT_NODE) {
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 31a3d5fc43..57523f7e21 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -1745,50 +1745,6 @@ EvoEditor.SetBodyFontName = function(name)
        }
 }
 
-EvoEditor.beforeInputCb = function(inputEvent)
-{
-       if (EvoUndoRedo.disabled ||
-           !inputEvent ||
-           inputEvent.inputType != "insertText" ||
-           !inputEvent.data ||
-           inputEvent.data.length != 1 ||
-           inputEvent.data == " " ||
-           inputEvent.data == "\t")
-               return;
-
-       var selection = document.getSelection();
-
-       // when writing at the end of the anchor, then write into the anchor, not out (WebKit writes out)
-       if (!selection ||
-           !selection.isCollapsed ||
-           !selection.anchorNode ||
-           selection.anchorNode.nodeType != selection.anchorNode.TEXT_NODE ||
-           selection.anchorOffset != selection.anchorNode.nodeValue.length ||
-           !selection.anchorNode.parentElement ||
-           selection.anchorNode.parentElement.tagName != "A")
-               return;
-
-       var node = selection.anchorNode;
-
-       EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_EVENT, "insertText", selection.anchorNode, 
selection.anchorNode,
-               EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML | EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE);
-
-       try {
-               node.nodeValue += inputEvent.data;
-               selection.setPosition(node, node.nodeValue.length);
-
-               if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT)
-                       node.parentElement.href = node.nodeValue;
-       } finally {
-               EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_EVENT, "insertText");
-       }
-
-       // it will add the text, if anything breaks before it gets here
-       inputEvent.stopImmediatePropagation();
-       inputEvent.stopPropagation();
-       inputEvent.preventDefault();
-}
-
 EvoEditor.emptyParagraphAsHtml = function()
 {
        if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT) {
@@ -1817,7 +1773,7 @@ EvoEditor.initializeContent = function()
                }
 
                // make sure there is a selection
-               if (!document.getSelection().anchorNode) {
+               if (!document.getSelection().anchorNode || document.getSelection().anchorNode.tagName == 
"HTML") {
                        document.getSelection().setPosition(document.body.firstChild ? 
document.body.firstChild : document.body, 0);
                }
        }
@@ -1838,7 +1794,7 @@ EvoEditor.getNextNodeInHierarchy = function(node, upToNode)
        if (!next) {
                next = node.parentElement;
 
-               if (next === document.body || next === upToNode)
+               if (next === upToNode || next === document.body)
                        next = null;
 
                while (next) {
@@ -1848,7 +1804,7 @@ EvoEditor.getNextNodeInHierarchy = function(node, upToNode)
                        } else {
                                next = next.parentElement;
 
-                               if (next === document.body || next === upToNode)
+                               if (next === upToNode || next === document.body)
                                        next = null;
                        }
                }
@@ -1970,7 +1926,7 @@ EvoEditor.quoteParagraph = function(paragraph, blockquoteLevel, wrapWidth)
        paragraph.insertAdjacentHTML("afterbegin", prefixHtml);
 }
 
-EvoEditor.reBlockquotePlainText = function(plainText)
+EvoEditor.reBlockquotePlainText = function(plainText, usePreTag)
 {
        var lines = plainText.replace(/\&/g, "&amp;").split("\n"), ii, html = "", level = 0;
 
@@ -1998,7 +1954,7 @@ EvoEditor.reBlockquotePlainText = function(plainText)
                        level--;
                }
 
-               html += "<div>";
+               html += usePreTag ? "<pre>" : "<div>";
 
                while (line[skip] == ' ') {
                        skip++;
@@ -2008,7 +1964,8 @@ EvoEditor.reBlockquotePlainText = function(plainText)
                if (skip)
                        line = line.substr(skip);
 
-               html += (line[0] ? line.replace(/</g, "&lt;").replace(/>/g, "&gt;") : "<br>") + "</div>";
+               html += (line[0] ? line.replace(/</g, "&lt;").replace(/>/g, "&gt;") : "<br>");
+               html += usePreTag ? "</pre>" : "</div>";
        }
 
        while (0 < level) {
@@ -2043,11 +2000,24 @@ EvoEditor.convertParagraphs = function(parent, blockquoteLevel, wrapWidth)
                } else if (child.tagName == "PRE") {
                        if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT && blockquoteLevel > 0) {
                                var prefixHtml = EvoEditor.getBlockquotePrefixHtml(blockquoteLevel);
-                               var lines = child.innerText.split("\n"), ii, text = "";
+                               var lines, jj, text;
 
-                               for (ii = 0; ii < lines.length; ii++) {
-                                       text += prefixHtml + lines[ii].replace(/\&/g, "&amp;").replace(/</g, 
"&lt;").replace(/>/g, "&gt;");
-                                       if (ii + 1 < lines.length)
+                               text = child.innerText;
+
+                               if (text == "\n" || text == "\r\n")
+                                       lines = [ "" ];
+                               else
+                                       lines = text.split("\n");
+
+                               text = "";
+
+                               for (jj = 0; jj < lines.length; jj++) {
+                                       text += prefixHtml + lines[jj].replace(/\&/g, "&amp;").replace(/</g, 
"&lt;").replace(/>/g, "&gt;");
+
+                                       if (!lines[jj])
+                                               text += "<BR>";
+
+                                       if (jj + 1 < lines.length)
                                                text += "\n";
                                }
 
@@ -2055,6 +2025,8 @@ EvoEditor.convertParagraphs = function(parent, blockquoteLevel, wrapWidth)
                                        text += prefixHtml;
 
                                child.innerHTML = text;
+                       } else {
+                               EvoEditor.convertParagraphs(child, blockquoteLevel, wrapWidth);
                        }
                } else if (child.tagName == "BLOCKQUOTE") {
                        var innerWrapWidth = wrapWidth;
@@ -2068,8 +2040,10 @@ EvoEditor.convertParagraphs = function(parent, blockquoteLevel, wrapWidth)
 
                        // replace blockquote content with pure plain text and then re-blockquote it
                        // and do it only on the top level, not recursively (nested citations)
-                       if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT && !blockquoteLevel)
-                               child.innerHTML = 
EvoEditor.reBlockquotePlainText(EvoConvert.ToPlainText(child, -1));
+                       if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT && !blockquoteLevel) {
+                               child.innerHTML = 
EvoEditor.reBlockquotePlainText(EvoConvert.ToPlainText(child, -1),
+                                       child.firstElementChild && child.firstElementChild.tagName == "PRE");
+                       }
 
                        EvoEditor.convertParagraphs(child, blockquoteLevel + 1, innerWrapWidth);
                } else if (child.tagName == "UL") {
@@ -3074,6 +3048,158 @@ EvoEditor.linkifyText = function(anchorNode, withUndo)
        return covered;
 }
 
+EvoEditor.maybeRemoveQuotationMark = function(node)
+{
+       if (!node || node.nodeType != node.ELEMENT_NODE || node.tagName != "SPAN" ||
+           node.className != "-x-evo-quoted")
+               return false;
+
+       EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, "removeQuotationMark", node, node,
+               EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML | EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE);
+       try {
+               node.remove();
+       } finally {
+               EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, "removeQuotationMark");
+       }
+
+       return true;
+}
+
+EvoEditor.removeEmptyElements = function(tagName)
+{
+       var nodes, node, ii, didRemove = 0;
+
+       nodes = document.querySelectorAll(tagName + ":empty");
+
+       for (ii = nodes.length - 1; ii >= 0; ii--) {
+               node = nodes[ii];
+
+               didRemove++;
+
+               EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, "removeEmptyElem::" + tagName, node, 
node,
+                       EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML | 
EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE);
+               try {
+                       node.remove();
+               } finally {
+                       EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, "removeEmptyElem::" + tagName);
+               }
+       }
+
+       return didRemove;
+}
+
+EvoEditor.beforeInputCb = function(inputEvent)
+{
+       if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT && inputEvent && (
+           inputEvent.inputType == "deleteContentForward" || inputEvent.inputType == 
"deleteContentBackward")) {
+               var selection = document.getSelection();
+
+               // workaround WebKit bug https://bugs.webkit.org/show_bug.cgi?id=209605
+               if (selection.anchorNode && selection.anchorNode.nodeType == 
selection.anchorNode.ELEMENT_NODE &&
+                   selection.isCollapsed && EvoEditor.IsBlockNode(selection.anchorNode) && 
selection.anchorNode.firstChild.tagName == "BR" &&
+                   !selection.anchorNode.firstChild.nextSibling) {
+                       EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_EVENT, inputEvent.inputType, 
selection.anchorNode, selection.anchorNode,
+                               EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML | 
EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE);
+                       try {
+                               var next = selection.anchorNode.nextSibling;
+
+                               if (!next)
+                                       next = selection.anchorNode.previousSibling;
+                               if (!next)
+                                       next = selection.anchorNode.parentElement;
+
+                               selection.anchorNode.parentElement.removeChild(selection.anchorNode);
+
+                               selection.setPosition(next, 0);
+                       } finally {
+                               EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_EVENT, inputEvent.inputType);
+                       }
+
+                       inputEvent.stopImmediatePropagation();
+                       inputEvent.stopPropagation();
+                       inputEvent.preventDefault();
+
+                       return;
+               }
+
+               var didRemove = 0;
+
+               if (selection.anchorNode && selection.anchorNode.previousSibling &&
+                   EvoEditor.maybeRemoveQuotationMark(selection.anchorNode.previousSibling))
+                       didRemove++;
+
+               if (selection.focusNode && selection.focusNode.previousSibling &&
+                   EvoEditor.maybeRemoveQuotationMark(selection.focusNode.previousSibling))
+                       didRemove++;
+
+               if (didRemove) {
+                       EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, inputEvent.inputType + 
"::selDeletion", selection.anchorNode, selection.focusNode,
+                               EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML | 
EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE);
+                       try {
+                               selection.deleteFromDocument();
+                       } finally {
+                               EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, inputEvent.inputType + 
"::selDeletion");
+                       }
+
+                       didRemove += EvoEditor.removeEmptyElements("DIV");
+                       didRemove += EvoEditor.removeEmptyElements("PRE");
+
+                       EvoUndoRedo.GroupTopRecords(didRemove + 1, inputEvent.inputType + "::grouped");
+                       EvoEditor.maybeUpdateFormattingState(EvoEditor.FORCE_MAYBE);
+                       EvoEditor.EmitContentChanged();
+
+                       inputEvent.stopImmediatePropagation();
+                       inputEvent.stopPropagation();
+                       inputEvent.preventDefault();
+
+                       return;
+               }
+       }
+
+       if (EvoUndoRedo.disabled ||
+           !inputEvent ||
+           inputEvent.inputType != "insertText" ||
+           !inputEvent.data ||
+           inputEvent.data.length != 1 ||
+           inputEvent.data == " " ||
+           inputEvent.data == "\t")
+               return;
+
+       var selection = document.getSelection();
+
+       // when writing at the end of the anchor, then write into the anchor, not out (WebKit writes out)
+       if (!selection ||
+           !selection.isCollapsed ||
+           !selection.anchorNode ||
+           selection.anchorNode.nodeType != selection.anchorNode.TEXT_NODE ||
+           selection.anchorOffset != selection.anchorNode.nodeValue.length ||
+           !selection.anchorNode.parentElement ||
+           selection.anchorNode.parentElement.tagName != "A")
+               return;
+
+       var node = selection.anchorNode;
+
+       EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_EVENT, "insertText", selection.anchorNode, 
selection.anchorNode,
+               EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML | EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE);
+
+       try {
+               node.nodeValue += inputEvent.data;
+               selection.setPosition(node, node.nodeValue.length);
+
+               if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT)
+                       node.parentElement.href = node.nodeValue;
+       } finally {
+               EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_EVENT, "insertText");
+               EvoEditor.maybeUpdateFormattingState(EvoEditor.FORCE_MAYBE);
+               EvoEditor.EmitContentChanged();
+       }
+
+       // it will add the text, if anything breaks before it gets here
+       inputEvent.stopImmediatePropagation();
+       inputEvent.stopPropagation();
+       inputEvent.preventDefault();
+}
+
 EvoEditor.AfterInputEvent = function(inputEvent, isWordDelim)
 {
        var isInsertParagraph = inputEvent.inputType == "insertParagraph";
@@ -3203,6 +3329,7 @@ EvoEditor.AfterInputEvent = function(inputEvent, isWordDelim)
                                        if (node && node.nextElementSibling) {
                                                var blockquoteLevel = (node.nextElementSibling.tagName == 
"BLOCKQUOTE" ? 1 : 0);
 
+                                               EvoEditor.removeQuoteMarks(node.nextElementSibling);
                                                EvoEditor.convertParagraphs(node.nextElementSibling, 
blockquoteLevel,
                                                        EvoEditor.NORMAL_PARAGRAPH_WIDTH - (blockquoteLevel * 
2));
                                        }
@@ -3210,6 +3337,7 @@ EvoEditor.AfterInputEvent = function(inputEvent, isWordDelim)
                                        if (node && node.previousElementSibling) {
                                                var blockquoteLevel = (node.previousElementSibling.tagName == 
"BLOCKQUOTE" ? 1 : 0);
 
+                                               EvoEditor.removeQuoteMarks(node.previousElementSibling);
                                                EvoEditor.convertParagraphs(node.previousElementSibling, 
blockquoteLevel,
                                                        EvoEditor.NORMAL_PARAGRAPH_WIDTH - (blockquoteLevel * 
2));
                                        }
@@ -5027,10 +5155,24 @@ EvoEditor.processLoadedContent = function()
        if (cite) {
                cite = document.createElement("BLOCKQUOTE");
                cite.setAttribute("type", "cite");
+
                while (document.body.firstChild) {
                        cite.appendChild(document.body.firstChild);
                }
 
+               var next;
+
+               // Evolution builds HTML with insignificant "\n", thus remove them first
+               for (node = cite.firstChild; node; node = next) {
+                       next = EvoEditor.getNextNodeInHierarchy(node, cite);
+
+                       if (node.nodeType == node.TEXT_NODE && node.nodeValue && node.nodeValue.charAt(0) == 
'\n' && (
+                           (node.previousSibling && EvoEditor.IsBlockNode(node.previousSibling)) ||
+                           (!node.previousSibling && node.parentElement.tagName == "BLOCKQUOTE" && 
!(node.parentElement === cite)))) {
+                               node.nodeValue = node.nodeValue.substr(1);
+                       }
+               }
+
                document.body.appendChild(cite);
        }
 
@@ -5117,9 +5259,21 @@ EvoEditor.processLoadedContent = function()
                }
        }
 
-       if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT)
+       if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT) {
                EvoEditor.convertParagraphs(document.body, 0, EvoEditor.NORMAL_PARAGRAPH_WIDTH);
 
+               if (EvoEditor.MAGIC_LINKS) {
+                       var next;
+
+                       for (node = document.body.firstChild; node; node = next) {
+                               next = EvoEditor.getNextNodeInHierarchy(node, null);
+
+                               if (node.nodeType == node.TEXT_NODE)
+                                       EvoEditor.linkifyText(node, false);
+                       }
+               }
+       }
+
        // remove comments at the beginning, like the Evolution's "<!-- text/html -->"
        while (document.documentElement.firstChild && document.documentElement.firstChild.nodeType == 
document.documentElement.firstChild.COMMENT_NODE) {
                document.documentElement.removeChild(document.documentElement.firstChild);
@@ -5134,6 +5288,8 @@ EvoEditor.processLoadedContent = function()
        for (ii = list.length - 1; ii >= 0; ii--) {
                node = list[ii];
                node.removeAttribute("id");
+
+               document.getSelection().setPosition(node, 0);
        }
 }
 
diff --git a/data/webkit/e-undo-redo.js b/data/webkit/e-undo-redo.js
index 86aefcbe29..6c8cf41834 100644
--- a/data/webkit/e-undo-redo.js
+++ b/data/webkit/e-undo-redo.js
@@ -618,12 +618,16 @@ EvoUndoRedo.StopRecord = function(kind, opType)
                }
        }
 
-       if (record.kind != kind) {
-               throw "EvoUndoRedo:StopRecord: Mismatch in record kind, expected " + record.kind + ", but 
received " + kind;
-       }
+       if (record.kind != kind || record.opType != opType) {
+               // The "InsertContent", especially when inserting plain text, can receive multiple 'input' 
events
+               // with "insertParagraph", "insertText" and similar, which do not have its counterpart 
beforeInput event,
+               // thus ignore those
+
+               if (record.opType == "InsertContent" && opType.startsWith("insert"))
+                       return;
 
-       if (record.opType != opType) {
-               throw "EvoUndoRedo:StopRecord: Mismatch in record opType, expected '" + record.opType + "', 
but received '" + opType + "'";
+               throw "EvoUndoRedo:StopRecord: Mismatch in record kind, expected " + record.kind + " (" + 
record.opType + "), but received " +
+                       kind + "(" + opType + "); ongoing recordings:" + EvoUndoRedo.ongoingRecordings.length;
        }
 
        EvoUndoRedo.ongoingRecordings.length = EvoUndoRedo.ongoingRecordings.length - 1;
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index f5fafd08f7..3a1ff1a93a 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -618,7 +618,6 @@ test_bug_771131 (TestFixture *fixture)
                "<div>" QUOTE_SPAN (QUOTE_CHR QUOTE_CHR) "<br></div>"
                "<div>" QUOTE_SPAN (QUOTE_CHR QUOTE_CHR) "Goodbye</div>"
                "</blockquote>"
-               "<div>" QUOTE_SPAN (QUOTE_CHR) "<br></div>"
                "<div>" QUOTE_SPAN (QUOTE_CHR) "the 3rd line text</div>"
                "</blockquote>"
                HTML_SUFFIX,
@@ -627,7 +626,6 @@ test_bug_771131 (TestFixture *fixture)
                "> > Hello\n"
                "> > \n"
                "> > Goodbye\n"
-               "> \n"
                "> the 3rd line text\n"))
                g_test_fail ();
 }
@@ -654,18 +652,18 @@ test_bug_771493 (TestFixture *fixture)
        if (!test_utils_run_simple_test (fixture,
                "",
                HTML_PREFIX "<div style=\"width: 71ch;\">On Thu, 2016-09-15 at 08:08 -0400, user wrote:</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<div style=\"width: 71ch;\">&gt; <br></div>"
-               "<div style=\"width: 71ch;\">&gt; ----- Original Message -----</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<div style=\"width: 71ch;\">&gt; &gt; This week summary:</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "<br></div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "----- Original Message -----</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR QUOTE_CHR) "This week summary:</div>"
                "</blockquote>"
                "</blockquote>"
                HTML_SUFFIX,
                "On Thu, 2016-09-15 at 08:08 -0400, user wrote:\n"
                "> \n"
                "> ----- Original Message -----\n"
-               "> > This week summary:"))
+               "> > This week summary:\n"))
                g_test_fail ();
 }
 
@@ -687,16 +685,16 @@ test_bug_772171 (TestFixture *fixture)
                E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
 
        if (!test_utils_run_simple_test (fixture,
-               "seq:ddeb",
+               "seq:deb",
                HTML_PREFIX "<div style=\"width: 71ch;\">On Thu, 2016-09-15 at 08:08 -0400, user wrote:</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<div style=\"width: 71ch;\">&gt; <br></div>"
-               "<div style=\"width: 71ch;\">&gt; b</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "<br></div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "b</div>"
                "</blockquote>"
                HTML_SUFFIX,
                "On Thu, 2016-09-15 at 08:08 -0400, user wrote:\n"
                "> \n"
-               "> b"))
+               "> b\n"))
                g_test_fail ();
 }
 
@@ -727,7 +725,8 @@ test_bug_772513 (TestFixture *fixture)
 
        if (!test_utils_run_simple_test (fixture,
                "",
-               HTML_PREFIX "<div style=\"width: 71ch;\"><br></div>" HTML_SUFFIX,
+               HTML_PREFIX "<div style=\"width: 71ch;\"><br></div>"
+               "<div class=\"-x-evo-signature-wrapper\" style=\"width: 71ch;\"><span 
class=\"-x-evo-signature\" id=\"none\"></span></div>" HTML_SUFFIX,
                "\n"))
                g_test_fail ();
 }
@@ -743,7 +742,7 @@ test_bug_772918 (TestFixture *fixture)
                "undo:undo:6\n"
                "undo:redo:6\n",
                HTML_PREFIX "<div>a b 1 2 3 c d</div>" HTML_SUFFIX,
-               "a b 1 2 3 c d"))
+               "a b 1 2 3 c d\n"))
                g_test_fail ();
 }
 
@@ -759,25 +758,21 @@ test_bug_773164 (TestFixture *fixture)
                "undo:undo\n"
                "undo:test\n"
                "undo:redo\n"
-               "seq:huuuue\n" /* Go to the end of the first line */
-               "seq:Sdds\n"
+               "seq:huue\n" /* Go to the end of the first line */
+               "seq:Sds\n"
                "action:cut\n"
                "seq:dde\n" /* Go to the end of the last line */
                "action:paste\n"
-               "undo:undo:5\n"
+               "undo:undo:3\n"
                "undo:test\n"
-               "undo:redo:5\n",
+               "undo:redo:3\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">This is paragraph 1</div>"
-               "<div style=\"width: 71ch;\"><br></div>"
                "<div style=\"width: 71ch;\">This is a longer paragraph 3</div>"
-               "<div style=\"width: 71ch;\"><br></div>"
                "<div style=\"width: 71ch;\">This is paragraph 2</div>"
                HTML_SUFFIX,
                "This is paragraph 1\n"
-               "\n"
                "This is a longer paragraph 3\n"
-               "\n"
-               "This is paragraph 2"))
+               "This is paragraph 2\n"))
                g_test_fail ();
 }
 
@@ -796,17 +791,69 @@ test_bug_775042 (TestFixture *fixture)
                "seq:rl\n"
                "mode:plain\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">On Fri, 2016-11-25 at 08:18 +0000, user wrote:</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<pre>&gt; a</pre>"
-               "<pre>&gt; b</pre>"
-               "<pre>&gt; c</pre>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "a</pre>"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "b</pre>"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "c</pre>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "On Fri, 2016-11-25 at 08:18 +0000, user wrote:\n"
+               "> a\n"
+               "> b\n"
+               "> c\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       test_utils_insert_content (fixture,
+               "<body><pre>a\n"
+               "b\n"
+               "c"
+               "<span class=\"-x-evo-to-body\" data-credits=\"On Fri, 2016-11-25 at 08:18 +0000, user 
wrote:\"></span>"
+               "<span class=\"-x-evo-cite-body\"></span></body>",
+               E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+       if (!test_utils_run_simple_test (fixture,
+               "seq:rl\n",
+               HTML_PREFIX "<div style=\"width: 71ch;\">On Fri, 2016-11-25 at 08:18 +0000, user wrote:</div>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "a</pre>"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "b</pre>"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "c</pre>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "On Fri, 2016-11-25 at 08:18 +0000, user wrote:\n"
+               "> a\n"
+               "> b\n"
+               "> c\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       test_utils_insert_content (fixture,
+               "<body><div>a</div>"
+               "<p>b</p>"
+               "<div>c</div>"
+               "<span class=\"-x-evo-to-body\" data-credits=\"On Fri, 2016-11-25 at 08:18 +0000, user 
wrote:\"></span>"
+               "<span class=\"-x-evo-cite-body\"></span></body>",
+               E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+       if (!test_utils_run_simple_test (fixture,
+               "seq:rl\n",
+               HTML_PREFIX "<div style=\"width: 71ch;\">On Fri, 2016-11-25 at 08:18 +0000, user wrote:</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "a</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "b</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "c</div>"
                "</blockquote>"
                HTML_SUFFIX,
                "On Fri, 2016-11-25 at 08:18 +0000, user wrote:\n"
                "> a\n"
                "> b\n"
-               "> c"))
+               "> c\n")) {
                g_test_fail ();
+               return;
+       }
 }
 
 static void
@@ -823,7 +870,7 @@ test_bug_775691 (TestFixture *fixture)
                "<div style=\"width: 71ch;\">def</div>"
                HTML_SUFFIX,
                "abc def ghi\n"
-               "def"))
+               "def\n"))
                g_test_fail ();
 }
 
@@ -848,20 +895,53 @@ test_bug_779707 (TestFixture *fixture)
                E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
 
        if (!test_utils_run_simple_test (fixture,
-               "seq:uuuSesDbnnu\n"
+               "seq:ChcddhSesDbnn\n"
                "type:a very long text, which splits into multiple lines when this paragraph is not marked as 
preformatted, but as normal, as it should be\n"
-               "",
+               "seq:n\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">Credits:</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<pre>&gt; line 1</pre>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "line 1</pre>"
                "</blockquote>"
                "<div style=\"width: 71ch;\"><br></div>"
                "<div style=\"width: 71ch;\">a very long text, which splits into multiple lines when this 
paragraph is not marked as preformatted, but as normal, as it should be</div>"
                "<div style=\"width: 71ch;\"><br></div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<pre>&gt; line 3</pre>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "line 3</pre>"
                "</blockquote>"
+               HTML_SUFFIX,
+               "Credits:\n"
+               "> line 1\n"
+               "\n"
+               "a very long text, which splits into multiple lines when this paragraph\n"
+               "is not marked as preformatted, but as normal, as it should be\n"
+               "\n"
+               "> line 3\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       test_utils_insert_content (fixture,
+               "<div>line 1</div>"
+               "<div>line 2</div>"
+               "<div>line 3</div>"
+               "<span class=\"-x-evo-to-body\" data-credits=\"Credits:\"></span>"
+               "<span class=\"-x-evo-cite-body\"></span>",
+               E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+       if (!test_utils_run_simple_test (fixture,
+               "seq:ChcddhSesDbnn\n"
+               "type:a very long text, which splits into multiple lines when this paragraph is not marked as 
preformatted, but as normal, as it should be\n"
+               "seq:n\n",
+               HTML_PREFIX "<div style=\"width: 71ch;\">Credits:</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "line 1</div>"
+               "</blockquote>"
+               "<div style=\"width: 71ch;\"><br></div>"
+               "<div style=\"width: 71ch;\">a very long text, which splits into multiple lines when this 
paragraph is not marked as preformatted, but as normal, as it should be</div>"
                "<div style=\"width: 71ch;\"><br></div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "line 3</div>"
+               "</blockquote>"
                HTML_SUFFIX,
                "Credits:\n"
                "> line 1\n"
@@ -896,8 +976,7 @@ test_bug_780275_html (TestFixture *fixture)
                "seq:hSuusD\n"
                "undo:undo\n"
                "undo:test:1\n"
-               "undo:redo\n"
-               "",
+               "undo:redo\n",
                HTML_PREFIX "<div>line 0</div>"
                "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
                "<div>Xline 1</div>"
@@ -908,7 +987,7 @@ test_bug_780275_html (TestFixture *fixture)
                "line 0\n"
                "> Xline 1\n"
                "> line 2\n"
-               "line 4"))
+               "line 4\n"))
                g_test_fail ();
 }
 
@@ -937,16 +1016,16 @@ test_bug_780275_plain (TestFixture *fixture)
                "undo:test:1\n"
                "undo:redo\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">line 0</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<div style=\"width: 71ch;\">&gt; Xline 1</div>"
-               "<div style=\"width: 71ch;\">&gt; line 2</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "Xline 1</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
                "</blockquote>"
                "<div style=\"width: 71ch;\">line 4</div>"
                HTML_SUFFIX,
                "line 0\n"
                "> Xline 1\n"
                "> line 2\n"
-               "line 4"))
+               "line 4\n"))
                g_test_fail ();
 }
 
@@ -969,12 +1048,12 @@ test_bug_781722 (TestFixture *fixture)
                "seq:dd\n"
                "action:style-preformat\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">Credits:</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<pre>&gt; Signed-off-by: User &lt;<a 
href=\"mailto:user@no.where\";>user@no.where</a>&gt;</pre>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "Signed-off-by: User &lt;<a 
href=\"mailto:user@no.where\";>user@no.where</a>&gt;</pre>"
                "</blockquote>"
                HTML_SUFFIX,
                "Credits:\n"
-               "> Signed-off-by: User <user@no.where>"))
+               "> Signed-off-by: User <user@no.where>\n"))
                g_test_fail ();
 }
 
@@ -999,16 +1078,16 @@ test_bug_781116 (TestFixture *fixture)
                "seq:dd\n"
                "action:wrap-lines\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">Credits:</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<pre>&gt; a very long text, which splits into multiple lines when this<br>"
-               "&gt; paragraph is not marked as preformatted, but as normal, as it should<br>"
-               "&gt; be</pre>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "a very long text, which splits into multiple lines when 
this<br>"
+               QUOTE_SPAN (QUOTE_CHR) "paragraph is not marked as preformatted, but as normal, as it 
should<br>"
+               QUOTE_SPAN (QUOTE_CHR) "be</pre>"
                "</blockquote>"
                HTML_SUFFIX,
                "Credits:\n"
                "> a very long text, which splits into multiple lines when this\n"
                "> paragraph is not marked as preformatted, but as normal, as it should\n"
-               "> be</pre>"))
+               "> be</pre>\n"))
                g_test_fail ();
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]