* bindings/vapi/javascriptcore-4.0.vapi (Object::get_property): Fix return type. * src/client/conversation-viewer/conversation-message.vala (GtkTemplate): Hook up to new deceptive_link_clicked signal, remove old DOM-based implementation. * src/client/conversation-viewer/conversation-web-view.vala (ConversationWebView): Add new deceptive_link_clicked signal and DeceptiveText enum, listen for deceptiveLinkClicked JS message and fire signal when received. * src/client/util/util-webkit.vala (WebKitUtil): Add to_object util function. * src/engine/util/util-js.vala (Geary.JS): Add to_object and get_property util functions. * ui/conversation-web-view.js (ConversationPageState) Listen for link clicks, check for deceptive text and send message if found. Add unit tests for deceptive text check. * test/js/composer-page-state-test.vala: Move ::run_javascript to parent class so new ConversationPageStateTest class can use it, adapt call sites to different parent signature.
54 lines
1.5 KiB
Vala
54 lines
1.5 KiB
Vala
/*
|
|
* Copyright 2016 Michael Gratton <mike@vee.net>
|
|
*
|
|
* This software is licensed under the GNU Lesser General Public License
|
|
* (version 2.1 or later). See the COPYING file in this distribution.
|
|
*/
|
|
|
|
// Defined by CMake build script.
|
|
extern const string _BUILD_ROOT_DIR;
|
|
|
|
public abstract class ClientWebViewTestCase<V> : Gee.TestCase {
|
|
|
|
protected V? test_view = null;
|
|
protected Configuration? config = null;
|
|
|
|
public ClientWebViewTestCase(string name) {
|
|
base(name);
|
|
}
|
|
|
|
public override void set_up() {
|
|
this.config = new Configuration(GearyApplication.APP_ID);
|
|
ClientWebView.init_web_context(
|
|
this.config,
|
|
File.new_for_path(_BUILD_ROOT_DIR).get_child("src"),
|
|
true
|
|
);
|
|
try {
|
|
ClientWebView.load_scripts();
|
|
} catch (Error err) {
|
|
assert_not_reached();
|
|
}
|
|
this.test_view = set_up_test_view();
|
|
}
|
|
|
|
protected abstract V set_up_test_view();
|
|
|
|
protected virtual void load_body_fixture(string? html = null) {
|
|
ClientWebView client_view = (ClientWebView) this.test_view;
|
|
client_view.load_html(html);
|
|
while (client_view.is_loading) {
|
|
Gtk.main_iteration();
|
|
}
|
|
}
|
|
|
|
protected WebKit.JavascriptResult run_javascript(string command) throws Error {
|
|
ClientWebView view = (ClientWebView) this.test_view;
|
|
view.run_javascript.begin(
|
|
command, null, (obj, res) => { async_complete(res); }
|
|
);
|
|
|
|
return view.run_javascript.end(async_result());
|
|
}
|
|
|
|
}
|