parent
952486c716
commit
98eb063398
6 changed files with 37 additions and 43 deletions
|
|
@ -565,7 +565,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
|
||||||
Json.Generator generator = new Json.Generator();
|
Json.Generator generator = new Json.Generator();
|
||||||
generator.set_root(builder.get_root());
|
generator.set_root(builder.get_root());
|
||||||
string js = "geary.addPrintHeaders(" + generator.to_data(null) + ");";
|
string js = "geary.addPrintHeaders(" + generator.to_data(null) + ");";
|
||||||
yield this.primary_message.run_javascript(js, null);
|
yield this.primary_message.evaluate_javascript(js, null);
|
||||||
|
|
||||||
Gtk.Window? window = get_toplevel() as Gtk.Window;
|
Gtk.Window? window = get_toplevel() as Gtk.Window;
|
||||||
WebKit.PrintOperation op = this.primary_message.new_print_operation();
|
WebKit.PrintOperation op = this.primary_message.new_print_operation();
|
||||||
|
|
|
||||||
|
|
@ -672,10 +672,10 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
|
||||||
return new WebKit.PrintOperation(web_view);
|
return new WebKit.PrintOperation(web_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void run_javascript (string script, Cancellable? cancellable) throws Error {
|
public async void evaluate_javascript(string script, Cancellable? cancellable) throws Error {
|
||||||
if (this.web_view == null)
|
if (this.web_view == null)
|
||||||
initialize_web_view();
|
initialize_web_view();
|
||||||
yield web_view.run_javascript(script, cancellable);
|
yield web_view.evaluate_javascript(script, -1, null, null, cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zoom_in() {
|
public void zoom_in() {
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,10 @@ public abstract class Components.WebViewTestCase<V> : TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WebKit.JavascriptResult run_javascript(string command) throws Error {
|
protected JSC.Value? run_javascript(string command) throws Error {
|
||||||
WebView view = (WebView) this.test_view;
|
WebView view = (WebView) this.test_view;
|
||||||
view.run_javascript.begin(command, null, this.async_completion);
|
view.evaluate_javascript.begin(command, -1, null, null, null, this.async_completion);
|
||||||
return view.run_javascript.end(async_result());
|
return view.evaluate_javascript.end(async_result());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,6 @@ class Components.PageStateTest : WebViewTestCase<WebView> {
|
||||||
throws GLib.Error {
|
throws GLib.Error {
|
||||||
string? result = Util.JS.to_string(
|
string? result = Util.JS.to_string(
|
||||||
run_javascript("geary.testResult")
|
run_javascript("geary.testResult")
|
||||||
.get_js_value()
|
|
||||||
);
|
);
|
||||||
assert_equal(result, expected);
|
assert_equal(result, expected);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class Composer.PageStateTest : Components.WebViewTestCase<Composer.WebView> {
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(
|
run_javascript(
|
||||||
@"ComposerPageState.htmlToText(window.document.body);"
|
@"ComposerPageState.htmlToText(window.document.body);"
|
||||||
).get_js_value()
|
)
|
||||||
) == "para\n\n\n\n"
|
) == "para\n\n\n\n"
|
||||||
);
|
);
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -67,7 +67,7 @@ class Composer.PageStateTest : Components.WebViewTestCase<Composer.WebView> {
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(
|
run_javascript(
|
||||||
"ComposerPageState.htmlToText(window.document.body);"
|
"ComposerPageState.htmlToText(window.document.body);"
|
||||||
).get_js_value()
|
)
|
||||||
) == @"pre\n\n$(q_marker)quote\n$(q_marker)\npost\n\n\n\n"
|
) == @"pre\n\n$(q_marker)quote\n$(q_marker)\npost\n\n\n\n"
|
||||||
);
|
);
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -87,7 +87,7 @@ class Composer.PageStateTest : Components.WebViewTestCase<Composer.WebView> {
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(
|
run_javascript(
|
||||||
"ComposerPageState.htmlToText(window.document.body)"
|
"ComposerPageState.htmlToText(window.document.body)"
|
||||||
).get_js_value()
|
)
|
||||||
) == @"pre\n\n$(q_marker)quote1\n$(q_marker)\n$(q_marker)$(q_marker)quote2\n$(q_marker)$(q_marker)\npost\n\n\n\n"
|
) == @"pre\n\n$(q_marker)quote1\n$(q_marker)\n$(q_marker)$(q_marker)quote2\n$(q_marker)$(q_marker)\npost\n\n\n\n"
|
||||||
);
|
);
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -106,7 +106,7 @@ class Composer.PageStateTest : Components.WebViewTestCase<Composer.WebView> {
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(
|
run_javascript(
|
||||||
"ComposerPageState.htmlToText(window.document.body, [\"blockquote\"])"
|
"ComposerPageState.htmlToText(window.document.body, [\"blockquote\"])"
|
||||||
).get_js_value()
|
)
|
||||||
) == @"pre\n\npost\n\n\n\n"
|
) == @"pre\n\npost\n\n\n\n"
|
||||||
);
|
);
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -126,7 +126,7 @@ class Composer.PageStateTest : Components.WebViewTestCase<Composer.WebView> {
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(@"new EditContext(document.getElementById('test')).encode()")
|
run_javascript(@"new EditContext(document.getElementById('test')).encode()")
|
||||||
.get_js_value()
|
|
||||||
).has_prefix("1;url;"));
|
).has_prefix("1;url;"));
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
print("Util.JS.Error: %s\n", err.message);
|
print("Util.JS.Error: %s\n", err.message);
|
||||||
|
|
@ -145,7 +145,7 @@ class Composer.PageStateTest : Components.WebViewTestCase<Composer.WebView> {
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(@"new EditContext(document.getElementById('test')).encode()")
|
run_javascript(@"new EditContext(document.getElementById('test')).encode()")
|
||||||
.get_js_value()
|
|
||||||
) == "0;;Comic Sans;144;rgb(255, 127, 1)");
|
) == "0;;Comic Sans;144;rgb(255, 127, 1)");
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
print("Util.JS.Error: %s\n", err.message);
|
print("Util.JS.Error: %s\n", err.message);
|
||||||
|
|
@ -164,13 +164,13 @@ class Composer.PageStateTest : Components.WebViewTestCase<Composer.WebView> {
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_int32(
|
Util.JS.to_int32(
|
||||||
run_javascript(@"document.querySelectorAll('blockquote[type=cite]').length")
|
run_javascript(@"document.querySelectorAll('blockquote[type=cite]').length")
|
||||||
.get_js_value()
|
|
||||||
) == 1
|
) == 1
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(@"document.querySelectorAll('blockquote[type=cite]').item(0).innerText")
|
run_javascript(@"document.querySelectorAll('blockquote[type=cite]').item(0).innerText")
|
||||||
.get_js_value()
|
|
||||||
) == "some text"
|
) == "some text"
|
||||||
);
|
);
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -197,25 +197,25 @@ some text
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_bool(
|
Util.JS.to_bool(
|
||||||
run_javascript(@"geary.containsAttachmentKeyword(\"some\", \"subject text\");")
|
run_javascript(@"geary.containsAttachmentKeyword(\"some\", \"subject text\");")
|
||||||
.get_js_value()
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_bool(
|
Util.JS.to_bool(
|
||||||
run_javascript(@"geary.containsAttachmentKeyword(\"subject\", \"subject text\");")
|
run_javascript(@"geary.containsAttachmentKeyword(\"subject\", \"subject text\");")
|
||||||
.get_js_value()
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
!Util.JS.to_bool(
|
!Util.JS.to_bool(
|
||||||
run_javascript(@"geary.containsAttachmentKeyword(\"innerquote\", \"subject text\");")
|
run_javascript(@"geary.containsAttachmentKeyword(\"innerquote\", \"subject text\");")
|
||||||
.get_js_value()
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
!Util.JS.to_bool(
|
!Util.JS.to_bool(
|
||||||
run_javascript(@"geary.containsAttachmentKeyword(\"outerquote\", \"subject text\");")
|
run_javascript(@"geary.containsAttachmentKeyword(\"outerquote\", \"subject text\");")
|
||||||
.get_js_value()
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -260,7 +260,7 @@ I can send email through smtp.gmail.com:587 or through <a href="https://www.gmai
|
||||||
run_javascript("geary.cleanContent();");
|
run_javascript("geary.cleanContent();");
|
||||||
string result = Util.JS.to_string(
|
string result = Util.JS.to_string(
|
||||||
run_javascript("window.document.body.innerHTML;")
|
run_javascript("window.document.body.innerHTML;")
|
||||||
.get_js_value()
|
|
||||||
);
|
);
|
||||||
assert_equal(result, DIRTY_BODY_TEMPLATE.printf(expected));
|
assert_equal(result, DIRTY_BODY_TEMPLATE.printf(expected));
|
||||||
}
|
}
|
||||||
|
|
@ -270,7 +270,7 @@ I can send email through smtp.gmail.com:587 or through <a href="https://www.gmai
|
||||||
load_body_fixture(html);
|
load_body_fixture(html);
|
||||||
try {
|
try {
|
||||||
string result = Util.JS.to_string(
|
string result = Util.JS.to_string(
|
||||||
run_javascript(@"window.geary.getHtml();").get_js_value()
|
run_javascript(@"window.geary.getHtml();")
|
||||||
);
|
);
|
||||||
assert(result == CLEAN_BODY_TEMPLATE.printf(html));
|
assert(result == CLEAN_BODY_TEMPLATE.printf(html));
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -288,7 +288,7 @@ I can send email through smtp.gmail.com:587 or through <a href="https://www.gmai
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(@"window.geary.getText();")
|
run_javascript(@"window.geary.getText();")
|
||||||
.get_js_value()
|
|
||||||
) == "para\n\n\n\n"
|
) == "para\n\n\n\n"
|
||||||
);
|
);
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -308,73 +308,73 @@ I can send email through smtp.gmail.com:587 or through <a href="https://www.gmai
|
||||||
// Doesn't contain
|
// Doesn't contain
|
||||||
assert(!Util.JS.to_bool(run_javascript(
|
assert(!Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('notcontained', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('notcontained', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
assert(!Util.JS.to_bool(run_javascript(
|
assert(!Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('not contained', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('not contained', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(!Util.JS.to_bool(run_javascript(
|
assert(!Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('not\tcontained', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('not\tcontained', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(!Util.JS.to_bool(run_javascript(
|
assert(!Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('http://www.keyword1.com', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('http://www.keyword1.com', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(!Util.JS.to_bool(run_javascript(
|
assert(!Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('http://www.something.com/something.sf1', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('http://www.something.com/something.sf1', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(!Util.JS.to_bool(run_javascript(
|
assert(!Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('sf1', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('sf1', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(!Util.JS.to_bool(run_javascript(
|
assert(!Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('.sf1', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('.sf1', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
// Does contain
|
// Does contain
|
||||||
assert(Util.JS.to_bool(run_javascript(
|
assert(Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('keyword1', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('keyword1', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(Util.JS.to_bool(run_javascript(
|
assert(Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('keyword2 contained', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('keyword2 contained', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(Util.JS.to_bool(run_javascript(
|
assert(Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('keyword2\tcontained', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('keyword2\tcontained', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(Util.JS.to_bool(run_javascript(
|
assert(Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('keyword1.', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('keyword1.', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(Util.JS.to_bool(run_javascript(
|
assert(Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('something.sf1', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('something.sf1', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(Util.JS.to_bool(run_javascript(
|
assert(Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('something.something.sf2', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('something.something.sf2', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
assert(!Util.JS.to_bool(run_javascript(
|
assert(!Util.JS.to_bool(run_javascript(
|
||||||
@"ComposerPageState.containsKeywords('http://something/else.sf2', $complete_keys, $suffix_keys);"
|
@"ComposerPageState.containsKeywords('http://something/else.sf2', $complete_keys, $suffix_keys);"
|
||||||
).get_js_value()
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
|
|
@ -394,12 +394,12 @@ I can send email through smtp.gmail.com:587 or through <a href="https://www.gmai
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(single_nbsp)');")
|
run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(single_nbsp)');")
|
||||||
.get_js_value()
|
|
||||||
) == "a b");
|
) == "a b");
|
||||||
assert(
|
assert(
|
||||||
Util.JS.to_string(
|
Util.JS.to_string(
|
||||||
run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(multiple_nbsp)');")
|
run_javascript(@"ComposerPageState.replaceNonBreakingSpace('$(multiple_nbsp)');")
|
||||||
.get_js_value()
|
|
||||||
) == "a b c");
|
) == "a b c");
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
print("Util.JS.Error: %s\n", err.message);
|
print("Util.JS.Error: %s\n", err.message);
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ class ConversationPageStateTest : Components.WebViewTestCase<ConversationWebView
|
||||||
document.getElementById('test'), "BLOCKQUOTE"
|
document.getElementById('test'), "BLOCKQUOTE"
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
.get_js_value()
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -123,7 +122,6 @@ class ConversationPageStateTest : Components.WebViewTestCase<ConversationWebView
|
||||||
document.getElementById('test'), "BLOCKQUOTE", "test-class"
|
document.getElementById('test'), "BLOCKQUOTE", "test-class"
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
.get_js_value()
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +135,6 @@ class ConversationPageStateTest : Components.WebViewTestCase<ConversationWebView
|
||||||
document.getElementById('test'), "DIV"
|
document.getElementById('test'), "DIV"
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
.get_js_value()
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +148,6 @@ class ConversationPageStateTest : Components.WebViewTestCase<ConversationWebView
|
||||||
document.getElementById('test'), "DIV", null, false
|
document.getElementById('test'), "DIV", null, false
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
.get_js_value()
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +163,6 @@ class ConversationPageStateTest : Components.WebViewTestCase<ConversationWebView
|
||||||
try {
|
try {
|
||||||
ret = (uint) Util.JS.to_int32(
|
ret = (uint) Util.JS.to_int32(
|
||||||
run_javascript(@"ConversationPageState.isDeceptiveText(\"$text\", \"$href\")")
|
run_javascript(@"ConversationPageState.isDeceptiveText(\"$text\", \"$href\")")
|
||||||
.get_js_value()
|
|
||||||
);
|
);
|
||||||
} catch (Util.JS.Error err) {
|
} catch (Util.JS.Error err) {
|
||||||
print("Util.JS.Error: %s\n", err.message);
|
print("Util.JS.Error: %s\n", err.message);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue