summaryrefslogtreecommitdiff
path: root/fxjs/cfxjse_formcalc_context_embeddertest.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-25 15:05:04 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-25 15:05:04 +0000
commit08d9f6e3f0a68bae9eedb015458071e1481d28f4 (patch)
treeec942925c6cb9c8bb6fd98e16db3c7c5df1f6920 /fxjs/cfxjse_formcalc_context_embeddertest.cpp
parentbe0f656a8e61336cbe0089904c9bfb6e23521bce (diff)
downloadpdfium-08d9f6e3f0a68bae9eedb015458071e1481d28f4.tar.xz
[xfa] Allow accessing the event changed parameter from JS.
This CL updates the CFXJSE_Engine code to access the defined properties of a class if we fail to find the property in any other way. This fixes up an issue where we were unable to read the 'change' property of the CJX_EventPseudoModel because we could not find the 'change' property. Bug: 1066 Change-Id: I4ad205bc527beeca1c3e24a36cdde0c21287d9fb Reviewed-on: https://pdfium-review.googlesource.com/32930 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fxjs/cfxjse_formcalc_context_embeddertest.cpp')
-rw-r--r--fxjs/cfxjse_formcalc_context_embeddertest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/fxjs/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/cfxjse_formcalc_context_embeddertest.cpp
index a7efc14d20..a32f988d06 100644
--- a/fxjs/cfxjse_formcalc_context_embeddertest.cpp
+++ b/fxjs/cfxjse_formcalc_context_embeddertest.cpp
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "fxjs/cfxjse_engine.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/xfa_js_embedder_test.h"
+#include "xfa/fxfa/cxfa_eventparam.h"
class CFXJSE_FormCalcContextEmbedderTest : public XFAJSEmbedderTest {};
@@ -1455,3 +1457,32 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, MethodCall) {
EXPECT_TRUE(value->IsString());
EXPECT_STREQ("12.7mm", value->ToString().c_str());
}
+
+TEST_F(CFXJSE_FormCalcContextEmbedderTest, GetXFAEventChange) {
+ ASSERT_TRUE(OpenDocument("simple_xfa.pdf"));
+
+ CXFA_EventParam params;
+ params.m_wsChange = L"changed";
+
+ CFXJSE_Engine* context = GetScriptContext();
+ context->SetEventParam(params);
+
+ const char test[] = {"xfa.event.change"};
+ EXPECT_TRUE(Execute(test));
+
+ CFXJSE_Value* value = GetValue();
+ EXPECT_TRUE(value->IsString());
+ EXPECT_STREQ("changed", value->ToString().c_str());
+}
+
+TEST_F(CFXJSE_FormCalcContextEmbedderTest, SetXFAEventChange) {
+ ASSERT_TRUE(OpenDocument("simple_xfa.pdf"));
+
+ CXFA_EventParam params;
+ CFXJSE_Engine* context = GetScriptContext();
+ context->SetEventParam(params);
+
+ const char test[] = {"xfa.event.change = \"changed\""};
+ EXPECT_TRUE(Execute(test));
+ EXPECT_EQ(L"changed", context->GetEventParam()->m_wsChange);
+}