summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/xfa_js_embedder_test.cpp23
-rw-r--r--testing/xfa_js_embedder_test.h4
2 files changed, 20 insertions, 7 deletions
diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp
index 4a29872eab..e5a30f6b88 100644
--- a/testing/xfa_js_embedder_test.cpp
+++ b/testing/xfa_js_embedder_test.cpp
@@ -53,18 +53,27 @@ bool XFAJSEmbedderTest::OpenDocument(const std::string& filename,
}
bool XFAJSEmbedderTest::Execute(const CFX_ByteStringC& input) {
- value_ = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
- if (script_context_->RunScript(XFA_SCRIPTLANGTYPE_Formcalc,
- CFX_WideString::FromUTF8(input).AsStringC(),
- value_.get(), GetXFADocument()->GetRoot())) {
+ if (ExecuteHelper(input)) {
return true;
}
CFXJSE_Value msg(GetIsolate());
value_->GetObjectPropertyByIdx(1, &msg);
- EXPECT_TRUE(msg.IsString());
-
fprintf(stderr, "JS: %.*s\n", input.GetLength(), input.c_str());
- fprintf(stderr, "JS ERROR: %ls\n", msg.ToWideString().c_str());
+ // If the parsing of the input fails, then v8 will not run, so there will be
+ // no value here to print.
+ if (msg.IsString() && !msg.ToWideString().IsEmpty())
+ fprintf(stderr, "JS ERROR: %ls\n", msg.ToWideString().c_str());
return false;
}
+
+bool XFAJSEmbedderTest::ExecuteSilenceFailure(const CFX_ByteStringC& input) {
+ return ExecuteHelper(input);
+}
+
+bool XFAJSEmbedderTest::ExecuteHelper(const CFX_ByteStringC& input) {
+ value_ = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
+ return script_context_->RunScript(XFA_SCRIPTLANGTYPE_Formcalc,
+ CFX_WideString::FromUTF8(input).AsStringC(),
+ value_.get(), GetXFADocument()->GetRoot());
+}
diff --git a/testing/xfa_js_embedder_test.h b/testing/xfa_js_embedder_test.h
index afbdb26e1a..1dc06f05e6 100644
--- a/testing/xfa_js_embedder_test.h
+++ b/testing/xfa_js_embedder_test.h
@@ -33,6 +33,8 @@ class XFAJSEmbedderTest : public EmbedderTest {
CXFA_Document* GetXFADocument();
bool Execute(const CFX_ByteStringC& input);
+ bool ExecuteSilenceFailure(const CFX_ByteStringC& input);
+
CFXJSE_Value* GetValue() const { return value_.get(); }
private:
@@ -40,6 +42,8 @@ class XFAJSEmbedderTest : public EmbedderTest {
std::unique_ptr<CFXJSE_Value> value_;
v8::Isolate* isolate_;
CXFA_ScriptContext* script_context_;
+
+ bool ExecuteHelper(const CFX_ByteStringC& input);
};
#endif // TESTING_XFA_JS_EMBEDDER_TEST_H_