Exercise FFI_ExecuteNamedAction paths
Introduce logging in pdfium_test for this callback.
Change-Id: Ic641196da23d9eeb77d890752a81a2b19cfa9c91
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93311
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index c6a3661..2643859 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -435,6 +435,10 @@
}
#endif // PDF_ENABLE_XFA
+void ExampleNamedAction(FPDF_FORMFILLINFO* pInfo, FPDF_BYTESTRING name) {
+ printf("Execute named action: %s\n", name);
+}
+
void ExampleUnsupportedHandler(UNSUPPORT_INFO*, int type) {
std::string feature = "Unknown";
switch (type) {
@@ -1065,6 +1069,7 @@
#else // PDF_ENABLE_XFA
form_callbacks.version = 1;
#endif // PDF_ENABLE_XFA
+ form_callbacks.FFI_ExecuteNamedAction = ExampleNamedAction;
form_callbacks.FFI_GetPage = GetPageForIndex;
#ifdef PDF_ENABLE_V8
diff --git a/testing/resources/javascript/named_action.in b/testing/resources/javascript/named_action.in
new file mode 100644
index 0000000..ba8d28b
--- /dev/null
+++ b/testing/resources/javascript/named_action.in
@@ -0,0 +1,33 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /Pages 2 0 R
+ /OpenAction 10 0 R
+>>
+endobj
+{{object 2 0}} <<
+ /Type /Pages
+ /Count 1
+ /Kids [
+ 3 0 R
+ ]
+>>
+endobj
+% Page number 0.
+{{object 3 0}} <<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 612 792]
+>>
+endobj
+% OpenAction action - not really JS, but generates text under test env.
+{{object 10 0}} <<
+ /Type /Action
+ /S /Named
+ /N (Print)
+>>
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/named_action_expected.txt b/testing/resources/javascript/named_action_expected.txt
new file mode 100644
index 0000000..1099a7f
--- /dev/null
+++ b/testing/resources/javascript/named_action_expected.txt
@@ -0,0 +1 @@
+Execute named action: Print