• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 PDFium Authors. All rights reserved.
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 <memory>
9 #include <string>
10 
11 #include "testing/embedder_test.h"
12 #include "xfa/fxfa/parser/cxfa_document.h"
13 #include "xfa/fxfa/parser/cxfa_node.h"
14 
15 class CFXJSE_Engine;
16 class CFXJSE_Value;
17 class CFX_V8ArrayBufferAllocator;
18 
19 class XFAJSEmbedderTest : public EmbedderTest {
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 
GetIsolate()32   v8::Isolate* GetIsolate() const { return isolate_; }
33   CXFA_Document* GetXFADocument() const;
34 
35   bool Execute(ByteStringView input);
36   bool ExecuteSilenceFailure(ByteStringView input);
37 
GetScriptContext()38   CFXJSE_Engine* GetScriptContext() const { return script_context_; }
GetValue()39   CFXJSE_Value* GetValue() const { return value_.get(); }
40 
41  private:
42   std::unique_ptr<CFX_V8ArrayBufferAllocator> array_buffer_allocator_;
43   std::unique_ptr<CFXJSE_Value> value_;
44   v8::Isolate* isolate_ = nullptr;
45   CFXJSE_Engine* script_context_ = nullptr;
46 
47   bool ExecuteHelper(ByteStringView input);
48 };
49 
50 #endif  // TESTING_XFA_JS_EMBEDDER_TEST_H_
51