diff --git a/src/client/composer/composer-web-view.vala b/src/client/composer/composer-web-view.vala index c308dcd4..2e7f8147 100644 --- a/src/client/composer/composer-web-view.vala +++ b/src/client/composer/composer-web-view.vala @@ -133,7 +133,6 @@ public class ComposerWebView : ClientWebView { * Loads a message HTML body into the view. */ public new void load_html(string body, - string signature, string quote, bool top_posting, bool is_draft) { @@ -142,9 +141,7 @@ public class ComposerWebView : ClientWebView { const string BODY_PRE = """
para
"; - load_body_fixture(html); + public void get_html() throws GLib.Error { + string BODY = "para
"; + load_body_fixture(BODY); this.test_view.get_html.begin((obj, ret) => { async_complete(ret); }); - try { - assert(this.test_view.get_html.end(async_result()) == - BODY_TEMPLATE.printf(html)); - } catch (Error err) { - print("Error: %s\n", err.message); - assert_not_reached(); - } + string html = this.test_view.get_html.end(async_result()); + assert_string(ComposerPageStateTest.COMPLETE_BODY_TEMPLATE.printf(BODY), html); } public void get_text() throws Error { @@ -210,12 +205,40 @@ long, long, long, long, long, long, long, long, long, long, } } + public void update_signature() throws GLib.Error { + const string BODY = "para
"; + load_body_fixture(BODY); + string html = ""; + + const string SIG1 = "signature text 1"; + this.test_view.update_signature(SIG1); + this.test_view.get_html.begin((obj, ret) => { async_complete(ret); }); + html = this.test_view.get_html.end(async_result()); + assert_true(BODY in html, "Body not present"); + assert_true(SIG1 in html, "Signature 1 not present"); + + const string SIG2 = "signature text 2"; + this.test_view.update_signature(SIG2); + this.test_view.get_html.begin((obj, ret) => { async_complete(ret); }); + html = this.test_view.get_html.end(async_result()); + assert_true(BODY in html, "Body not present"); + assert_false(SIG1 in html, "Signature 1 still present"); + assert_true(SIG2 in html, "Signature 2 not present"); + + this.test_view.update_signature(""); + this.test_view.get_html.begin((obj, ret) => { async_complete(ret); }); + html = this.test_view.get_html.end(async_result()); + assert_true(BODY in html, "Body not present"); + assert_false(SIG1 in html, "Signature 1 still present"); + assert_false(SIG2 in html, "Signature 2 still present"); + } + protected override ComposerWebView set_up_test_view() { return new ComposerWebView(this.config); } protected override void load_body_fixture(string html = "") { - this.test_view.load_html(html, "", "", false, false); + this.test_view.load_html(html, "", false, false); while (this.test_view.is_loading) { Gtk.main_iteration(); } diff --git a/test/js/composer-page-state-test.vala b/test/js/composer-page-state-test.vala index ad8098fd..52afd678 100644 --- a/test/js/composer-page-state-test.vala +++ b/test/js/composer-page-state-test.vala @@ -7,8 +7,9 @@ class ComposerPageStateTest : ClientWebViewTestCaseouterquote text
", true ); @@ -103,9 +103,6 @@ some text assert(!WebKitUtil.to_bool(run_javascript( @"geary.containsAttachmentKeyword(\"innerquote\", \"subject text\");" ))); - assert(!WebKitUtil.to_bool(run_javascript( - @"geary.containsAttachmentKeyword(\"sig\", \"subject text\");" - ))); assert(!WebKitUtil.to_bool(run_javascript( @"geary.containsAttachmentKeyword(\"outerquote\", \"subject text\");" ))); @@ -292,14 +289,13 @@ unknown://example6.com } protected override void load_body_fixture(string body = "") { - load_body_fixture_full(body, "", "", true); + load_body_fixture_full(body, "", true); } protected void load_body_fixture_full(string body, - string sig, string quote, bool top_posting) { - this.test_view.load_html(body, sig, quote, top_posting, false); + this.test_view.load_html(body, quote, top_posting, false); while (this.test_view.is_loading) { Gtk.main_iteration(); } diff --git a/ui/composer-web-view.css b/ui/composer-web-view.css index 83c36e90..a5344c10 100644 --- a/ui/composer-web-view.css +++ b/ui/composer-web-view.css @@ -24,6 +24,10 @@ body.plain a { cursor: text; } +body > *.geary-no-display { + display: none !important; +} + body > div#geary-body { margin: 0 !important; border: 0 !important; diff --git a/ui/composer-web-view.js b/ui/composer-web-view.js index 31fda273..876e4cb5 100644 --- a/ui/composer-web-view.js +++ b/ui/composer-web-view.js @@ -133,6 +133,7 @@ ComposerPageState.prototype = { if (!enabled) { this.stopBodyObserver(); } + this.bodyPart.contentEditable = true; if (this.signaturePart != null) { this.signaturePart.contentEditable = true; @@ -140,6 +141,7 @@ ComposerPageState.prototype = { if (this.quotePart != null) { this.quotePart.contentEditable = true; } + if (enabled) { // Enable modification observation only after the document // has been set editable as WebKit will alter some attrs @@ -208,8 +210,13 @@ ComposerPageState.prototype = { }, updateSignature: function(signature) { if (this.signaturePart != null) { - console.log(signature); - this.signaturePart.innerHTML = signature; + if (signature.trim()) { + this.signaturePart.innerHTML = signature; + this.signaturePart.classList.remove("geary-no-display"); + } else { + this.signaturePart.innerHTML = ""; + this.signaturePart.classList.add("geary-no-display"); + } } }, deleteQuotedMessage: function() { @@ -315,13 +322,17 @@ ComposerPageState.prototype = { if (this.signaturePart != null) { parent.appendChild( - ComposerPageState.cleanPart(this.signaturePart.cloneNode(true), false) + ComposerPageState.cleanPart( + this.signaturePart.cloneNode(true), false + ) ); } if (this.quotePart != null) { parent.appendChild( - ComposerPageState.cleanPart(this.quotePart.cloneNode(true), false) + ComposerPageState.cleanPart( + this.quotePart.cloneNode(true), false + ) ); }