Reenable converting plain text URLs to links in HTML documents.
* src/client/composer/composer-web-view.vala (ComposerWebView): Rename ::linkify_document since it really only applies to editor content. Make an asyc method so we can wait until its finished. Update call sites. Thunk call to JS. * src/client/web-process/util-composer.vala, src/client/web-process/util-webkit.vala: Remove unused code. * ui/composer-web-view.js (ComposerPageState): Add ::linkifyContent method and ::linkify static method. Add unit tests.
This commit is contained in:
parent
e22ece508c
commit
848558f368
7 changed files with 108 additions and 146 deletions
|
|
@ -13,13 +13,15 @@ class ComposerPageStateTest : ClientWebViewTestCase<ComposerWebView> {
|
|||
add_test("edit_context_link", edit_context_link);
|
||||
add_test("indent_line", indent_line);
|
||||
add_test("contains_attachment_keywords", contains_attachment_keywords);
|
||||
add_test("linkify_content", linkify_content);
|
||||
add_test("get_html", get_html);
|
||||
add_test("get_text", get_text);
|
||||
add_test("get_text_with_quote", get_text_with_quote);
|
||||
add_test("get_text_with_nested_quote", get_text_with_nested_quote);
|
||||
add_test("resolve_nesting", resolve_nesting);
|
||||
|
||||
add_test("contains_keywords", contains_keywords);
|
||||
add_test("quote_lines", quote_lines);
|
||||
add_test("resolve_nesting", resolve_nesting);
|
||||
add_test("replace_non_breaking_space", replace_non_breaking_space);
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +111,45 @@ some text
|
|||
}
|
||||
}
|
||||
|
||||
public void linkify_content() {
|
||||
// XXX split these up into multiple tests
|
||||
load_body_fixture("""
|
||||
http://example1.com
|
||||
|
||||
<p>http://example2.com</p>
|
||||
|
||||
<p>http://example3.com http://example4.com</p>
|
||||
|
||||
<a href="blarg">http://example5.com</a>
|
||||
|
||||
unknown://example6.com
|
||||
""");
|
||||
|
||||
string expected = """
|
||||
<a href="http://example1.com">http://example1.com</a>
|
||||
|
||||
<p><a href="http://example2.com">http://example2.com</a></p>
|
||||
|
||||
<p><a href="http://example3.com">http://example3.com</a> <a href="http://example4.com">http://example4.com</a></p>
|
||||
|
||||
<a href="blarg">http://example5.com</a>
|
||||
|
||||
unknown://example6.com
|
||||
<br><br>""";
|
||||
|
||||
try {
|
||||
run_javascript("geary.linkifyContent();");
|
||||
assert(WebKitUtil.to_string(run_javascript("geary.messageBody.innerHTML;")) ==
|
||||
expected);
|
||||
} catch (Geary.JS.Error err) {
|
||||
print("Geary.JS.Error: %s\n", err.message);
|
||||
assert_not_reached();
|
||||
} catch (Error err) {
|
||||
print("WKError: %s\n", err.message);
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
public void get_html() {
|
||||
string html = "<p>para</p>";
|
||||
load_body_fixture(html);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue