From b720d0a14601f1496ef15297bc46d401f5a2a890 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 2 Mar 2015 12:18:50 -0800 Subject: Return error information from pdfium to JS. This implements the previously unimplemented JS_Error() function. Along the way: - fix some IWYU when the include order in global.cpp was perturbed. - remove some uses of JS_ErrorString, to increase transparency. - use vp.IsSetting() in place of !vp.IsGetting() for clarity. - specify an error string on several error return paths. - add an error string for writing readonly properties. - rename an error string constant to reflect the actual message. - replace calls to variadic Format() with a function doing string appends. - remove unused JS_GetClassName() R=thestig@chromium.org Review URL: https://codereview.chromium.org/963193003 --- testing/resources/javascript/globals.in | 44 ++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'testing/resources/javascript/globals.in') diff --git a/testing/resources/javascript/globals.in b/testing/resources/javascript/globals.in index 6d2f3ca241..4812101e7a 100644 --- a/testing/resources/javascript/globals.in +++ b/testing/resources/javascript/globals.in @@ -63,21 +63,34 @@ var props_to_test = [ function setup_global() { for (var i = 0; i < props_to_test.length; ++i) { var prop = props_to_test[i]; - global[prop.name] = prop.value; + try { + global[prop.name] = prop.value; + } catch (e) { + app.alert("For " + prop.name + ": Setup: ERROR: " + e.toString()); + } } } function delete_global() { for (var i = 0; i < props_to_test.length; ++i) { var prop = props_to_test[i]; - delete global[prop.name]; + try { + delete global[prop.name]; + } catch (e) { + app.alert("For " + prop.name + ": Delete: ERROR: " + e.toString()); + } } } function persist_global(should_persist) { for (var i = 0; i < props_to_test.length; ++i) { var prop = props_to_test[i]; - global.setPersistent(prop.name, should_persist); + try { + global.setPersistent(prop.name, should_persist); + } catch (e) { + app.alert("For " + prop.name + + ": Set Persistent: ERROR: " + e.toString()); + } } } @@ -85,18 +98,27 @@ function dump_global(msg) { app.alert("************ " + msg + " ************"); app.alert("Enumerable Globals:"); for (var name in global) { - app.alert(" " + name + " = " + global[name] + - ", own property = " + global.hasOwnProperty(name)); + try { + app.alert(" " + name + " = " + global[name] + + ", own property = " + global.hasOwnProperty(name)); + } catch (e) { + app.alert("For " + name + ": Dump: ERROR: " + e.toString()); + } } app.alert("Expected Globals:"); for (var i = 0; i < props_to_test.length; ++i) { var prop = props_to_test[i]; - var actual = global[prop.name]; - app.alert(" " + prop.name + " = " + actual); - if (actual != null && typeof actual == "object") { - app.alert(" " + actual.colors[0]); - app.alert(" " + actual.colors[1]); - app.alert(" " + actual.colors[2]); + try { + var actual = global[prop.name]; + app.alert(" " + prop.name + " = " + actual); + if (actual != null && typeof actual == "object") { + app.alert(" " + actual.colors[0]); + app.alert(" " + actual.colors[1]); + app.alert(" " + actual.colors[2]); + } + } catch (e) { + app.alert("For " + prop.name + + ": Dump Expected: ERROR: " + e.toString()); } } } -- cgit v1.2.3