2016-12-12 22:47:53 +11:00
|
|
|
/*
|
2017-11-23 09:35:51 +11:00
|
|
|
* Copyright 2016-2017 Michael Gratton <mike@vee.net>
|
2016-12-12 22:47:53 +11:00
|
|
|
*
|
|
|
|
|
* This software is licensed under the GNU Lesser General Public License
|
|
|
|
|
* (version 2.1 or later). See the COPYING file in this distribution.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-01-09 09:14:31 +11:00
|
|
|
// Defined by CMake build script.
|
|
|
|
|
extern const string _GSETTINGS_DIR;
|
|
|
|
|
|
2016-12-12 23:39:46 +11:00
|
|
|
int main(string[] args) {
|
2016-12-26 13:21:58 +10:30
|
|
|
/*
|
|
|
|
|
* Set env vars right up front to avoid weird bugs
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Use the memory GSettings DB so we a) always start with default
|
|
|
|
|
// values, and b) don't persist any changes made during a test
|
|
|
|
|
Environment.set_variable("GSETTINGS_BACKEND", "memory", true);
|
|
|
|
|
|
2017-01-09 09:14:31 +11:00
|
|
|
// Let GSettings know where to find the dev schema
|
|
|
|
|
Environment.set_variable("GSETTINGS_SCHEMA_DIR", _GSETTINGS_DIR, true);
|
|
|
|
|
|
2016-12-26 13:18:51 +10:30
|
|
|
/*
|
|
|
|
|
* Initialise all the things.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-12-31 14:49:38 +11:00
|
|
|
Gtk.init(ref args);
|
2016-12-12 22:47:53 +11:00
|
|
|
Test.init(ref args);
|
Fix HTML, CSS and JS leaking into conversation list preview. Bug 714317
When generating the preview, only the first 128 bytes of the first MIME
part is fetched and used. If this part is text/html with a significant
amount of embedded CSS, then there is a good chance the string passed to
Geary.HTML::remove_html_tags() will be invalid, or be missing closing
elements. Since that function uses regexes that require balanced tags to
remove script and style blocks, then it was very possible that in these
cases this method will miss removing these blocks.
To solve this, remove_html_tags() is removed and its call sites are
replaced by calls to Geary.HTML::html_to_text(), which has been tidyied
up to produce more human-readable result.
Add unit tests to cover new html_to_text functionality and its call
sites.
* src/engine/util/util-html.vala: Remove remove_html_tags(). Update
html_to_text() to not just insert line breaks, but also insert spaces
and alt text, and ignore tags like HEAD, SCRIPT and STYLE, as
appropriate. Add an optional param to also allow skipping BLOCKQUOTE
elements, which we don't want in the preview.
2016-12-18 23:28:53 +11:00
|
|
|
|
|
|
|
|
Geary.RFC822.init();
|
|
|
|
|
Geary.HTML.init();
|
2017-01-01 12:37:08 +11:00
|
|
|
Geary.Logging.init();
|
Fix HTML, CSS and JS leaking into conversation list preview. Bug 714317
When generating the preview, only the first 128 bytes of the first MIME
part is fetched and used. If this part is text/html with a significant
amount of embedded CSS, then there is a good chance the string passed to
Geary.HTML::remove_html_tags() will be invalid, or be missing closing
elements. Since that function uses regexes that require balanced tags to
remove script and style blocks, then it was very possible that in these
cases this method will miss removing these blocks.
To solve this, remove_html_tags() is removed and its call sites are
replaced by calls to Geary.HTML::html_to_text(), which has been tidyied
up to produce more human-readable result.
Add unit tests to cover new html_to_text functionality and its call
sites.
* src/engine/util/util-html.vala: Remove remove_html_tags(). Update
html_to_text() to not just insert line breaks, but also insert spaces
and alt text, and ignore tags like HEAD, SCRIPT and STYLE, as
appropriate. Add an optional param to also allow skipping BLOCKQUOTE
elements, which we don't want in the preview.
2016-12-18 23:28:53 +11:00
|
|
|
|
2016-12-26 13:18:51 +10:30
|
|
|
/*
|
|
|
|
|
* Hook up all tests into appropriate suites
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
TestSuite client = new TestSuite("client");
|
|
|
|
|
|
2017-01-30 23:09:02 +11:00
|
|
|
// Keep this before other ClientWebView based tests since it tests
|
|
|
|
|
// WebContext init
|
2018-07-23 14:38:57 +10:00
|
|
|
client.add_suite(new Accounts.ManagerTest().get_suite());
|
2017-01-30 23:09:02 +11:00
|
|
|
client.add_suite(new ClientWebViewTest().get_suite());
|
2017-01-02 10:23:35 +11:00
|
|
|
client.add_suite(new ComposerWebViewTest().get_suite());
|
2016-12-26 13:21:58 +10:30
|
|
|
client.add_suite(new ConfigurationTest().get_suite());
|
2019-03-09 19:59:25 +11:00
|
|
|
client.add_suite(new Util.Avatar.Test().get_suite());
|
2016-12-26 13:21:58 +10:30
|
|
|
|
2017-01-01 12:37:08 +11:00
|
|
|
TestSuite js = new TestSuite("js");
|
|
|
|
|
|
2017-11-16 12:44:57 +11:00
|
|
|
js.add_suite(new ClientPageStateTest().get_suite());
|
2017-01-01 12:37:08 +11:00
|
|
|
js.add_suite(new ComposerPageStateTest().get_suite());
|
2017-01-24 00:05:44 +11:00
|
|
|
js.add_suite(new ConversationPageStateTest().get_suite());
|
2017-01-01 12:37:08 +11:00
|
|
|
|
2016-12-26 13:18:51 +10:30
|
|
|
/*
|
|
|
|
|
* Run the tests
|
|
|
|
|
*/
|
|
|
|
|
TestSuite root = TestSuite.get_root();
|
|
|
|
|
root.add_suite(client);
|
2017-01-01 12:37:08 +11:00
|
|
|
root.add_suite(js);
|
2016-12-12 23:39:46 +11:00
|
|
|
|
2016-12-31 14:49:38 +11:00
|
|
|
int ret = -1;
|
|
|
|
|
Idle.add(() => {
|
|
|
|
|
ret = Test.run();
|
|
|
|
|
Gtk.main_quit();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Gtk.main();
|
|
|
|
|
return ret;
|
2016-12-12 22:47:53 +11:00
|
|
|
}
|