blob: 96e292f116ca951d03a97b74eda4e17ab39aae7c [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
Dan Sinclair14aacd52017-05-18 14:11:29 -04008#include <string>
9
Lei Zhang8d477f72020-06-06 05:05:56 +000010#include "core/fxcrt/string_view_template.h"
Tom Sepezae26e662020-07-10 19:59:20 +000011#include "testing/js_embedder_test.h"
Lei Zhangbfcf1562022-07-07 01:49:26 +000012#include "v8/include/v8-local-handle.h"
13#include "v8/include/v8-persistent-handle.h"
14#include "v8/include/v8-value.h"
Dan Sinclair14aacd52017-05-18 14:11:29 -040015
Dan Sinclair3fff90a2017-11-01 13:12:39 +000016class CFXJSE_Engine;
Lei Zhang8d477f72020-06-06 05:05:56 +000017class CXFA_Document;
18
Tom Sepezae26e662020-07-10 19:59:20 +000019class XFAJSEmbedderTest : public JSEmbedderTest {
Dan Sinclair14aacd52017-05-18 14:11:29 -040020 public:
21 XFAJSEmbedderTest();
22 ~XFAJSEmbedderTest() override;
23
Lei Zhang208eecf2017-12-20 19:40:50 +000024 // EmbedderTest:
Dan Sinclair14aacd52017-05-18 14:11:29 -040025 void SetUp() override;
26 void TearDown() override;
Lei Zhang208eecf2017-12-20 19:40:50 +000027 bool OpenDocumentWithOptions(const std::string& filename,
28 const char* password,
Tom Sepez0784c732018-04-23 18:02:57 +000029 LinearizeOption linearize_option,
30 JavaScriptOption javascript_option) override;
Dan Sinclair14aacd52017-05-18 14:11:29 -040031
Nicolas Penae6575672018-09-20 21:30:06 +000032 CXFA_Document* GetXFADocument() const;
Tom Sepezae26e662020-07-10 19:59:20 +000033 CFXJSE_Engine* GetScriptContext() const { return script_context_; }
Tom Sepezd564b0d2020-11-06 18:28:10 +000034 v8::Local<v8::Value> GetValue() const;
Dan Sinclair14aacd52017-05-18 14:11:29 -040035
Tom Sepezc839ac72018-12-14 20:34:11 +000036 bool Execute(ByteStringView input);
37 bool ExecuteSilenceFailure(ByteStringView input);
Ryan Harrison580c1592017-06-29 10:43:53 -040038
Dan Sinclair14aacd52017-05-18 14:11:29 -040039 private:
Tom Sepezc839ac72018-12-14 20:34:11 +000040 bool ExecuteHelper(ByteStringView input);
Tom Sepezae26e662020-07-10 19:59:20 +000041
Tom Sepezd564b0d2020-11-06 18:28:10 +000042 v8::Global<v8::Value> value_;
Tom Sepezae26e662020-07-10 19:59:20 +000043 CFXJSE_Engine* script_context_ = nullptr;
Dan Sinclair14aacd52017-05-18 14:11:29 -040044};
45
46#endif // TESTING_XFA_JS_EMBEDDER_TEST_H_