summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdf_formfill_embeddertest.cpp25
-rw-r--r--testing/resources/document_aactions.in139
-rw-r--r--testing/resources/document_aactions.pdf164
3 files changed, 327 insertions, 1 deletions
diff --git a/fpdfsdk/fpdf_formfill_embeddertest.cpp b/fpdfsdk/fpdf_formfill_embeddertest.cpp
index 99d30f3cc3..f5b39ae4b1 100644
--- a/fpdfsdk/fpdf_formfill_embeddertest.cpp
+++ b/fpdfsdk/fpdf_formfill_embeddertest.cpp
@@ -435,6 +435,30 @@ TEST_F(FPDFFormFillEmbeddertest, DisableJavaScript) {
UnloadPage(page);
}
+TEST_F(FPDFFormFillEmbeddertest, DocumentAActions) {
+ EmbedderTestTimerHandlingDelegate delegate;
+ SetDelegate(&delegate);
+
+ EXPECT_TRUE(OpenDocument("document_aactions.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_TRUE(page);
+
+ const auto& alerts = delegate.GetAlerts();
+ EXPECT_EQ(0U, alerts.size());
+
+ FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WS);
+ FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DS);
+ FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WP);
+ FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DP);
+ UnloadPage(page);
+
+ ASSERT_EQ(4U, alerts.size());
+ EXPECT_STREQ(L"Will Save", alerts[0].message.c_str());
+ EXPECT_STREQ(L"Did Save", alerts[1].message.c_str());
+ EXPECT_STREQ(L"Will Print", alerts[2].message.c_str());
+ EXPECT_STREQ(L"Did Print", alerts[3].message.c_str());
+}
+
TEST_F(FPDFFormFillEmbeddertest, BUG_551248) {
// Test that timers fire once and intervals fire repeatedly.
EmbedderTestTimerHandlingDelegate delegate;
@@ -594,7 +618,6 @@ TEST_F(FPDFFormFillEmbeddertest, BUG_765384) {
FORM_OnLButtonUp(form_handle(), page, 0, 140, 590);
UnloadPage(page);
}
-
#endif // PDF_ENABLE_V8
TEST_F(FPDFFormFillEmbeddertest, FormText) {
diff --git a/testing/resources/document_aactions.in b/testing/resources/document_aactions.in
new file mode 100644
index 0000000000..5c7ceed497
--- /dev/null
+++ b/testing/resources/document_aactions.in
@@ -0,0 +1,139 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /Pages 2 0 R
+ /AcroForm 3 0 R
+ /AA 11 0 R
+>>
+endobj
+{{object 2 0}} <<
+ /Type /Pages
+ /Count 3
+ /Kids [4 0 R]
+>>
+endobj
+{{object 3 0}} <<
+ /CO [9 0 R]
+ /Fields [
+ 9 0 R
+ 7 0 R
+ ]
+>>
+endobj
+{{object 4 0}} <<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 612 792]
+>>
+endobj
+{{object 7 0}} <<
+ /FT /Tx
+ /Type /Annot
+ /Subtype /Widget
+ /T (txtName2)
+ /F 4
+ /AP <</N 8 0 R>>
+ /Rect [20 20 400 60]
+>>
+endobj
+{{object 8 0}} <<
+ /Type /XObject
+ /Subtype /Form
+ /FormType 1
+>>
+endobj
+{{object 9 0}} <<
+ /FT /Tx
+ /Type /Annot
+ /Subtype /Widget
+ /T (txtName1)
+ /F 4
+ /AP <</N 10 0 R>>
+ /Rect [200 200 400 260]
+>>
+endobj
+{{object 10 0}} <<
+ /Type /XObject
+ /Subtype /Form
+ /FormType 1
+>>
+endobj
+{{object 11 0}} <<
+ /WP 14 0 R
+ /DP 16 0 R
+ /WS 18 0 R
+ /DS 20 0 R
+>>
+endobj
+{{object 12 0}} <<
+ /Type /Action
+ /S /JavaScript
+ /JS 13 0 R
+>>
+endobj
+{{object 13 0}} <<
+ {{streamlen}}
+>>
+stream
+app.alert('Will Close');
+endstream
+endobj
+{{object 14 0}} <<
+ /Type /Action
+ /S /JavaScript
+ /JS 15 0 R
+>>
+endobj
+{{object 15 0}} <<
+ {{streamlen}}
+>>
+stream
+app.alert('Will Print');
+endstream
+endobj
+{{object 16 0}} <<
+ /Type /Action
+ /S /JavaScript
+ /JS 17 0 R
+>>
+endobj
+{{object 17 0}} <<
+ {{streamlen}}
+>>
+stream
+app.alert('Did Print');
+endstream
+endobj
+{{object 18 0}} <<
+ /Type /Action
+ /S /JavaScript
+ /JS 19 0 R
+>>
+endobj
+{{object 19 0}} <<
+ {{streamlen}}
+>>
+stream
+app.alert('Will Save');
+endstream
+endobj
+{{object 20 0}} <<
+ /Type /Action
+ /S /JavaScript
+ /JS 21 0 R
+>>
+endobj
+{{object 21 0}} <<
+ {{streamlen}}
+>>
+stream
+app.alert('Did Save');
+endstream
+endobj
+{{xref}}
+trailer <<
+ /Size 14
+ /Root 1 0 R
+>>
+{{startxref}}
+%%EOF
diff --git a/testing/resources/document_aactions.pdf b/testing/resources/document_aactions.pdf
new file mode 100644
index 0000000000..b921772672
--- /dev/null
+++ b/testing/resources/document_aactions.pdf
@@ -0,0 +1,164 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Type /Catalog
+ /Pages 2 0 R
+ /AcroForm 3 0 R
+ /AA 11 0 R
+>>
+endobj
+2 0 obj <<
+ /Type /Pages
+ /Count 3
+ /Kids [4 0 R]
+>>
+endobj
+3 0 obj <<
+ /CO [9 0 R]
+ /Fields [
+ 9 0 R
+ 7 0 R
+ ]
+>>
+endobj
+4 0 obj <<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 612 792]
+>>
+endobj
+7 0 obj <<
+ /FT /Tx
+ /Type /Annot
+ /Subtype /Widget
+ /T (txtName2)
+ /F 4
+ /AP <</N 8 0 R>>
+ /Rect [20 20 400 60]
+>>
+endobj
+8 0 obj <<
+ /Type /XObject
+ /Subtype /Form
+ /FormType 1
+>>
+endobj
+9 0 obj <<
+ /FT /Tx
+ /Type /Annot
+ /Subtype /Widget
+ /T (txtName1)
+ /F 4
+ /AP <</N 10 0 R>>
+ /Rect [200 200 400 260]
+>>
+endobj
+10 0 obj <<
+ /Type /XObject
+ /Subtype /Form
+ /FormType 1
+>>
+endobj
+11 0 obj <<
+ /WP 14 0 R
+ /DP 16 0 R
+ /WS 18 0 R
+ /DS 20 0 R
+>>
+endobj
+12 0 obj <<
+ /Type /Action
+ /S /JavaScript
+ /JS 13 0 R
+>>
+endobj
+13 0 obj <<
+ /Length 25
+>>
+stream
+app.alert('Will Close');
+endstream
+endobj
+14 0 obj <<
+ /Type /Action
+ /S /JavaScript
+ /JS 15 0 R
+>>
+endobj
+15 0 obj <<
+ /Length 25
+>>
+stream
+app.alert('Will Print');
+endstream
+endobj
+16 0 obj <<
+ /Type /Action
+ /S /JavaScript
+ /JS 17 0 R
+>>
+endobj
+17 0 obj <<
+ /Length 24
+>>
+stream
+app.alert('Did Print');
+endstream
+endobj
+18 0 obj <<
+ /Type /Action
+ /S /JavaScript
+ /JS 19 0 R
+>>
+endobj
+19 0 obj <<
+ /Length 24
+>>
+stream
+app.alert('Will Save');
+endstream
+endobj
+20 0 obj <<
+ /Type /Action
+ /S /JavaScript
+ /JS 21 0 R
+>>
+endobj
+21 0 obj <<
+ /Length 23
+>>
+stream
+app.alert('Did Save');
+endstream
+endobj
+xref
+0 22
+0000000000 65535 f
+0000000015 00000 n
+0000000099 00000 n
+0000000162 00000 n
+0000000233 00000 n
+0000000000 65535 f
+0000000000 65535 f
+0000000310 00000 n
+0000000440 00000 n
+0000000509 00000 n
+0000000643 00000 n
+0000000713 00000 n
+0000000787 00000 n
+0000000855 00000 n
+0000000932 00000 n
+0000001000 00000 n
+0000001077 00000 n
+0000001145 00000 n
+0000001221 00000 n
+0000001289 00000 n
+0000001365 00000 n
+0000001433 00000 n
+trailer <<
+ /Size 14
+ /Root 1 0 R
+>>
+startxref
+1508
+%%EOF