1 // Copyright 2017 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef TESTING_XFA_JS_EMBEDDER_TEST_H_ 6 #define TESTING_XFA_JS_EMBEDDER_TEST_H_ 7 8 #include <string> 9 10 #include "core/fxcrt/string_view_template.h" 11 #include "testing/js_embedder_test.h" 12 #include "v8/include/v8-local-handle.h" 13 #include "v8/include/v8-persistent-handle.h" 14 #include "v8/include/v8-value.h" 15 16 class CFXJSE_Engine; 17 class CXFA_Document; 18 19 class XFAJSEmbedderTest : public JSEmbedderTest { 20 public: 21 XFAJSEmbedderTest(); 22 ~XFAJSEmbedderTest() override; 23 24 // EmbedderTest: 25 void SetUp() override; 26 void TearDown() override; 27 bool OpenDocumentWithOptions(const std::string& filename, 28 const char* password, 29 LinearizeOption linearize_option, 30 JavaScriptOption javascript_option) override; 31 32 CXFA_Document* GetXFADocument() const; GetScriptContext()33 CFXJSE_Engine* GetScriptContext() const { return script_context_; } 34 v8::Local<v8::Value> GetValue() const; 35 36 bool Execute(ByteStringView input); 37 bool ExecuteSilenceFailure(ByteStringView input); 38 39 private: 40 bool ExecuteHelper(ByteStringView input); 41 42 v8::Global<v8::Value> value_; 43 CFXJSE_Engine* script_context_ = nullptr; 44 }; 45 46 #endif // TESTING_XFA_JS_EMBEDDER_TEST_H_ 47