5#include "testing/xfa_js_embedder_test.h"
10#include "fpdfsdk/cpdfsdk_helpers.h"
11#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
13#include "fxjs/xfa/cfxjse_engine.h"
14#include "fxjs/xfa/cfxjse_isolatetracker.h"
15#include "fxjs/xfa/cfxjse_value.h"
16#include "testing/gtest/include/gtest/gtest.h"
17#include "third_party/base/check_op.h"
18#include "v8/include/v8-container.h"
19#include "v8/include/v8-local-handle.h"
20#include "v8/include/v8-value.h"
32 script_context_ =
nullptr;
38 auto* pDoc = CPDFDocumentFromFPDFDocument(
document());
42 auto* pContext =
static_cast<CPDFXFA_Context*>(pDoc->GetExtension());
54 return v8::Local<v8::Value>::New(isolate(), value_);
58 const std::string& filename,
65 filename, password, linearize_option, javascript_option)) {
79 if (ExecuteHelper(input))
82 fprintf(stderr,
"FormCalc: %.*s\n",
static_cast<
int>(input.GetLength()),
83 input.unterminated_c_str());
85 v8::Local<v8::Value> result = GetValue();
86 if (!fxv8::IsArray(result))
89 v8::Local<v8::Value> msg = fxv8::ReentrantGetArrayElementHelper(
90 isolate(), result.As<v8::Array>(), 1);
91 if (!fxv8::IsString(msg))
94 WideString str = fxv8::ReentrantToWideStringHelper(isolate(), msg);
96 fprintf(stderr,
"JS ERROR: %ls\n", str
.c_str());
103 return ExecuteHelper(input);
110 value_.Reset(isolate(), exec_result.value->GetValue(isolate()));
CFXJSE_Context * GetJseContextForTest() const
CFXJSE_Context::ExecutionResult RunScript(CXFA_Script::Type eScriptType, WideStringView wsScript, CXFA_Object *pThisObject)
CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context *pContext)
CFXJSE_Engine * GetScriptContext() const
CXFA_Node * GetRoot() const
CXFA_Document * GetXFADoc() const
FPDF_DOCUMENT document() const
v8::Local< v8::Value > GetValue() const
CXFA_Document * GetXFADocument() const
bool Execute(ByteStringView input)
bool OpenDocumentWithOptions(const std::string &filename, const char *password, LinearizeOption linearize_option, JavaScriptOption javascript_option) override
~XFAJSEmbedderTest() override
bool ExecuteSilenceFailure(ByteStringView input)
static WideString FromUTF8(ByteStringView str)
const wchar_t * c_str() const