blob: 362db471ce3f7a10e6639e936ebfc234b4ea56fa [file] [log] [blame]
Dan Sinclair14aacd52017-05-18 14:11:29 -04001// 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 "fxjs/cfxjse_value.h"
12#include "fxjs/fxjs_v8.h"
13#include "testing/embedder_test.h"
Dan Sinclair129b0132017-05-24 09:33:20 -040014#include "xfa/fxfa/parser/cxfa_document.h"
15#include "xfa/fxfa/parser/cxfa_node.h"
16#include "xfa/fxfa/parser/cxfa_object.h"
Dan Sinclair14aacd52017-05-18 14:11:29 -040017
18class CXFA_ScriptContext;
19
20class XFAJSEmbedderTest : public EmbedderTest {
21 public:
22 XFAJSEmbedderTest();
23 ~XFAJSEmbedderTest() override;
24
25 void SetUp() override;
26 void TearDown() override;
27
28 bool OpenDocument(const std::string& filename,
29 const char* password = nullptr,
30 bool must_linearize = false) override;
31
32 v8::Isolate* GetIsolate() const { return isolate_; }
Dan Sinclair129b0132017-05-24 09:33:20 -040033 CXFA_Document* GetXFADocument();
Dan Sinclair14aacd52017-05-18 14:11:29 -040034
Ryan Harrison275e2602017-09-18 14:23:18 -040035 bool Execute(const ByteStringView& input);
36 bool ExecuteSilenceFailure(const ByteStringView& input);
Ryan Harrison580c1592017-06-29 10:43:53 -040037
Dan Sinclair14aacd52017-05-18 14:11:29 -040038 CFXJSE_Value* GetValue() const { return value_.get(); }
39
40 private:
41 std::unique_ptr<FXJS_ArrayBufferAllocator> array_buffer_allocator_;
42 std::unique_ptr<CFXJSE_Value> value_;
43 v8::Isolate* isolate_;
44 CXFA_ScriptContext* script_context_;
Ryan Harrison580c1592017-06-29 10:43:53 -040045
Ryan Harrison275e2602017-09-18 14:23:18 -040046 bool ExecuteHelper(const ByteStringView& input);
Dan Sinclair14aacd52017-05-18 14:11:29 -040047};
48
49#endif // TESTING_XFA_JS_EMBEDDER_TEST_H_