Components.WebView: Check for pass up exceptions when calling JS code
Update web extension to check for errors when invoking page state methods and pass a message back if found. Check for this, decode and throw a vala error in the WebView if found.
This commit is contained in:
parent
ff565bc6ef
commit
c813aa5707
4 changed files with 146 additions and 13 deletions
|
|
@ -31,7 +31,9 @@ class Components.PageStateTest : WebViewTestCase<WebView> {
|
|||
base("Components.PageStateTest");
|
||||
add_test("content_loaded", content_loaded);
|
||||
add_test("call_void", call_void);
|
||||
add_test("call_void_throws", call_void_throws);
|
||||
add_test("call_returning", call_returning);
|
||||
add_test("call_returning_throws", call_returning_throws);
|
||||
|
||||
try {
|
||||
WebView.load_resources(GLib.File.new_for_path("/tmp"));
|
||||
|
|
@ -68,6 +70,35 @@ class Components.PageStateTest : WebViewTestCase<WebView> {
|
|||
assert_test_result("void");
|
||||
}
|
||||
|
||||
public void call_void_throws() throws GLib.Error {
|
||||
load_body_fixture("OHHAI");
|
||||
var test_article = this.test_view as TestWebView;
|
||||
|
||||
try {
|
||||
test_article.call_void.begin(
|
||||
new Util.JS.Callable("testThrow").string("void message"),
|
||||
this.async_completion
|
||||
);
|
||||
test_article.call_void.end(this.async_result());
|
||||
assert_not_reached();
|
||||
} catch (Util.JS.Error.EXCEPTION err) {
|
||||
assert_string(
|
||||
err.message
|
||||
).contains(
|
||||
"testThrow"
|
||||
// WebKitGTK doesn't actually pass any details through:
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=215877
|
||||
// ).contains(
|
||||
// "Error"
|
||||
// ).contains(
|
||||
// "void message"
|
||||
// ).contains(
|
||||
// "components-web-view.js"
|
||||
);
|
||||
assert_test_result("void message");
|
||||
}
|
||||
}
|
||||
|
||||
public void call_returning() throws GLib.Error {
|
||||
load_body_fixture("OHHAI");
|
||||
var test_article = this.test_view as TestWebView;
|
||||
|
|
@ -81,6 +112,35 @@ class Components.PageStateTest : WebViewTestCase<WebView> {
|
|||
assert_test_result("check 1-2");
|
||||
}
|
||||
|
||||
public void call_returning_throws() throws GLib.Error {
|
||||
load_body_fixture("OHHAI");
|
||||
var test_article = this.test_view as TestWebView;
|
||||
|
||||
try {
|
||||
test_article.call_returning.begin(
|
||||
new Util.JS.Callable("testThrow").string("return message"),
|
||||
this.async_completion
|
||||
);
|
||||
test_article.call_returning.end(this.async_result());
|
||||
assert_not_reached();
|
||||
} catch (Util.JS.Error.EXCEPTION err) {
|
||||
assert_string(
|
||||
err.message
|
||||
).contains(
|
||||
"testThrow"
|
||||
// WebKitGTK doesn't actually pass any details through:
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=215877
|
||||
// ).contains(
|
||||
// "Error"
|
||||
// ).contains(
|
||||
// "return message"
|
||||
// ).contains(
|
||||
// "components-web-view.js"
|
||||
);
|
||||
assert_test_result("return message");
|
||||
}
|
||||
}
|
||||
|
||||
protected override WebView set_up_test_view() {
|
||||
WebKit.UserScript test_script;
|
||||
test_script = new WebKit.UserScript(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue