summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.cpp2
-rw-r--r--fpdfsdk/fpdf_formfill_embeddertest.cpp30
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp15
3 files changed, 39 insertions, 8 deletions
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index b3375d4501..272e27032b 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -203,8 +203,6 @@ void CPDFSDK_FormFillEnvironment::JS_docgotoPage(int nPageNum) {
}
IJS_Runtime* CPDFSDK_FormFillEnvironment::GetIJSRuntime() {
- if (!IsJSPlatformPresent())
- return nullptr;
if (!m_pIJSRuntime)
m_pIJSRuntime = IJS_Runtime::Create(this);
return m_pIJSRuntime.get();
diff --git a/fpdfsdk/fpdf_formfill_embeddertest.cpp b/fpdfsdk/fpdf_formfill_embeddertest.cpp
index 09e0c200d3..cedb96c0ca 100644
--- a/fpdfsdk/fpdf_formfill_embeddertest.cpp
+++ b/fpdfsdk/fpdf_formfill_embeddertest.cpp
@@ -380,6 +380,36 @@ TEST_F(FPDFFormFillEmbeddertest, BUG_514690) {
}
#ifdef PDF_ENABLE_V8
+TEST_F(FPDFFormFillEmbeddertest, DisableJavaScript) {
+ // Test that timers and intervals can't fire without JS.
+ EmbedderTestTimerHandlingDelegate delegate;
+ SetDelegate(&delegate);
+
+ EXPECT_TRUE(OpenDocumentWithoutJavaScript("bug_551248.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_TRUE(page);
+ DoOpenActions();
+
+ const auto& alerts = delegate.GetAlerts();
+ EXPECT_EQ(0U, alerts.size());
+
+ delegate.AdvanceTime(1000);
+ EXPECT_EQ(0U, alerts.size()); // nothing fired.
+ delegate.AdvanceTime(1000);
+ EXPECT_EQ(0U, alerts.size()); // nothing fired.
+ delegate.AdvanceTime(1000);
+ EXPECT_EQ(0U, alerts.size()); // nothing fired.
+ delegate.AdvanceTime(1000);
+ EXPECT_EQ(0U, alerts.size()); // nothing fired.
+ delegate.AdvanceTime(1000);
+ EXPECT_EQ(0U, alerts.size()); // nothing fired.
+ delegate.AdvanceTime(1000);
+ EXPECT_EQ(0U, alerts.size()); // nothing fired.
+ delegate.AdvanceTime(1000);
+ EXPECT_EQ(0U, alerts.size()); // nothing fired.
+ UnloadPage(page);
+}
+
TEST_F(FPDFFormFillEmbeddertest, BUG_551248) {
// Test that timers fire once and intervals fire repeatedly.
EmbedderTestTimerHandlingDelegate delegate;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index c85c1bd27e..7d1b28be70 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -81,11 +81,11 @@ void CPDFXFA_Context::SetFormFillEnv(
bool CPDFXFA_Context::LoadXFADoc() {
m_nLoadStatus = FXFA_LOADSTATUS_LOADING;
+ m_XFAPageList.clear();
+
if (!m_pPDFDoc)
return false;
- m_XFAPageList.clear();
-
CXFA_FFApp* pApp = GetXFAApp();
if (!pApp)
return false;
@@ -96,8 +96,13 @@ bool CPDFXFA_Context::LoadXFADoc() {
return false;
}
- m_pXFADoc->GetXFADoc()->InitScriptContext(GetCJSRuntime());
+ CJS_Runtime* actual_runtime = GetCJSRuntime(); // Null if a stub.
+ if (!actual_runtime) {
+ SetLastError(FPDF_ERR_XFALOAD);
+ return false;
+ }
+ m_pXFADoc->GetXFADoc()->InitScriptContext(actual_runtime);
if (m_pXFADoc->GetFormType() == FormType::kXFAFull)
m_FormType = FormType::kXFAFull;
else
@@ -113,7 +118,6 @@ bool CPDFXFA_Context::LoadXFADoc() {
m_pXFADocView->DoLayout();
m_pXFADocView->StopLayout();
m_nLoadStatus = FXFA_LOADSTATUS_LOADED;
-
return true;
}
@@ -196,8 +200,7 @@ CJS_Runtime* CPDFXFA_Context::GetCJSRuntime() const {
if (!m_pFormFillEnv)
return nullptr;
- // XFA requires V8, if we have V8 then we have a CJS_Runtime and not the stub.
- return static_cast<CJS_Runtime*>(m_pFormFillEnv->GetIJSRuntime());
+ return m_pFormFillEnv->GetIJSRuntime()->AsCJSRuntime();
}
WideString CPDFXFA_Context::GetAppTitle() const {