summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/embedder_test_timer_handling_delegate.h25
-rw-r--r--testing/resources/bug_551248.in80
-rw-r--r--testing/resources/bug_551248.pdf134
-rw-r--r--testing/test_support.cpp16
-rw-r--r--testing/test_support.h6
5 files changed, 261 insertions, 0 deletions
diff --git a/testing/embedder_test_timer_handling_delegate.h b/testing/embedder_test_timer_handling_delegate.h
index aca4ac1b77..0137aae45f 100644
--- a/testing/embedder_test_timer_handling_delegate.h
+++ b/testing/embedder_test_timer_handling_delegate.h
@@ -7,11 +7,33 @@
#include <map>
#include <utility>
+#include <vector>
#include "embedder_test.h"
class EmbedderTestTimerHandlingDelegate : public EmbedderTest::Delegate {
public:
+ struct ReceivedAlert {
+ ReceivedAlert(FPDF_WIDESTRING message_in,
+ FPDF_WIDESTRING title_in,
+ int type_in,
+ int icon_in)
+ : message(message_in), title(title_in), type(type_in), icon(icon_in) {}
+
+ FPDF_WIDESTRING message;
+ FPDF_WIDESTRING title;
+ int type;
+ int icon;
+ };
+
+ int Alert(FPDF_WIDESTRING message,
+ FPDF_WIDESTRING title,
+ int type,
+ int icon) override {
+ alerts_.push_back(ReceivedAlert(message, title, type, icon));
+ return 0;
+ }
+
int SetTimer(int msecs, TimerCallback fn) override {
expiry_to_timer_map_.insert(std::pair<int, Timer>(
msecs + imaginary_elapsed_msecs_, Timer(++next_timer_id_, fn)));
@@ -44,11 +66,14 @@ class EmbedderTestTimerHandlingDelegate : public EmbedderTest::Delegate {
}
}
+ const std::vector<ReceivedAlert>& GetAlerts() const { return alerts_; }
+
protected:
using Timer = std::pair<int, TimerCallback>; // ID, callback pair.
std::multimap<int, Timer> expiry_to_timer_map_; // Keyed by timeout.
int next_timer_id_ = 0;
int imaginary_elapsed_msecs_ = 0;
+ std::vector<ReceivedAlert> alerts_;
};
#endif // TESTING_EMBEDDER_TEST_TIMER_HANDLING_DELEGATE_H_
diff --git a/testing/resources/bug_551248.in b/testing/resources/bug_551248.in
new file mode 100644
index 0000000000..ad10e93912
--- /dev/null
+++ b/testing/resources/bug_551248.in
@@ -0,0 +1,80 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /Pages 2 0 R
+ /AcroForm 6 0 R
+ /Names <</JavaScript 13 0 R>>
+>>
+endobj
+{{object 2 0}} <<
+ /Type /Pages
+ /Count 1
+ /Kids [4 0 R]
+>>
+endobj
+{{object 4 0}} <<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 612 792]
+ /CropBox [0 0 612 792]
+ /Resources <<>>
+>>
+endobj
+{{object 6 0}} <<
+ /DR <<
+ /Font <</Helv 7 0 R>>
+ >>
+ /DA (/Helv 0 Tf 0 g)
+ /Fields [5 0 R]
+>>
+endobj
+{{object 7 0}} <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Helvetica
+ /Encoding /WinAnsiEncoding
+>>
+endobj
+{{object 8 0}} <<
+ /Type /XObject
+ /Subtype /Form
+ /FormType 1
+ /Matrix [1 0 0 1 0 0]
+ /BBox [0 0 75.907 28.472]
+ /Resources <<
+ /Font <</FXF0 7 0 R>>
+ >>
+>>
+stream
+q
+Q
+
+
+endstream
+endobj
+{{object 11 0}} <<
+ /Type /Action
+ /S /JavaScript
+ /JS 50 0 R
+>>
+endobj
+{{object 13 0}} <<
+ /Names [(startDelay) 11 0 R]
+>>
+endobj
+{{object 50 0}} <<
+>>
+stream
+function startDelay()
+{
+ app.alert("hello world");
+}
+app.setTimeOut("startDelay()", 3000);
+endstream
+endobj
+{{xref}}
+trailer <<
+ /Root 1 0 R
+>>
+{{startxref}}
+%%EOF
diff --git a/testing/resources/bug_551248.pdf b/testing/resources/bug_551248.pdf
new file mode 100644
index 0000000000..cca1872ee7
--- /dev/null
+++ b/testing/resources/bug_551248.pdf
@@ -0,0 +1,134 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Type /Catalog
+ /Pages 2 0 R
+ /AcroForm 6 0 R
+ /Names <</JavaScript 13 0 R>>
+>>
+endobj
+2 0 obj <<
+ /Type /Pages
+ /Count 1
+ /Kids [4 0 R]
+>>
+endobj
+4 0 obj <<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 612 792]
+ /CropBox [0 0 612 792]
+ /Resources <<>>
+>>
+endobj
+6 0 obj <<
+ /DR <<
+ /Font <</Helv 7 0 R>>
+ >>
+ /DA (/Helv 0 Tf 0 g)
+ /Fields [5 0 R]
+>>
+endobj
+7 0 obj <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Helvetica
+ /Encoding /WinAnsiEncoding
+>>
+endobj
+8 0 obj <<
+ /Type /XObject
+ /Subtype /Form
+ /FormType 1
+ /Matrix [1 0 0 1 0 0]
+ /BBox [0 0 75.907 28.472]
+ /Resources <<
+ /Font <</FXF0 7 0 R>>
+ >>
+>>
+stream
+q
+Q
+
+
+endstream
+endobj
+11 0 obj <<
+ /Type /Action
+ /S /JavaScript
+ /JS 50 0 R
+>>
+endobj
+13 0 obj <<
+ /Names [(startDelay) 11 0 R]
+>>
+endobj
+50 0 obj <<
+>>
+stream
+function startDelay()
+{
+ app.alert("hello world");
+}
+app.setTimeOut("startDelay()", 3000);
+endstream
+endobj
+xref
+0 51
+0000000000 65535 f
+0000000015 00000 n
+0000000118 00000 n
+0000000000 65535 f
+0000000181 00000 n
+0000000000 65535 f
+0000000302 00000 n
+0000000404 00000 n
+0000000509 00000 n
+0000000000 65535 f
+0000000000 65535 f
+0000000701 00000 n
+0000000000 65535 f
+0000000769 00000 n
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000822 00000 n
+trailer <<
+ /Root 1 0 R
+>>
+startxref
+954
+%%EOF
diff --git a/testing/test_support.cpp b/testing/test_support.cpp
index 611ba5d580..49232990bc 100644
--- a/testing/test_support.cpp
+++ b/testing/test_support.cpp
@@ -98,6 +98,22 @@ char* GetFileContents(const char* filename, size_t* retlen) {
return buffer;
}
+std::wstring GetWideString(FPDF_WIDESTRING wstr) {
+ if (!wstr)
+ return nullptr;
+
+ size_t characters = 0;
+ while (wstr[characters])
+ ++characters;
+
+ std::wstring platform_string(characters, L'\0');
+ for (size_t i = 0; i < characters + 1; ++i) {
+ const unsigned char* ptr = reinterpret_cast<const unsigned char*>(&wstr[i]);
+ platform_string[i] = ptr[0] + 256 * ptr[1];
+ }
+ return platform_string;
+}
+
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
bool InitializeV8ForPDFium(const std::string& exe_path,
diff --git a/testing/test_support.h b/testing/test_support.h
index 1018421ba7..4bb88db254 100644
--- a/testing/test_support.h
+++ b/testing/test_support.h
@@ -8,6 +8,8 @@
#include <stdlib.h>
#include <string>
+#include "../public/fpdfview.h"
+
#ifdef PDF_ENABLE_V8
#include "v8/include/libplatform/libplatform.h"
#include "v8/include/v8.h"
@@ -16,6 +18,10 @@
// Reads the entire contents of a file into a newly malloc'd buffer.
char* GetFileContents(const char* filename, size_t* retlen);
+// Converts a FPDF_WIDESTRING to a std::wstring.
+// Deals with differences between UTF16LE and wchar_t.
+std::wstring GetWideString(FPDF_WIDESTRING wstr);
+
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
bool InitializeV8ForPDFium(const std::string& exe_path,