Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 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 | |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Lei Zhang | 8d477f7 | 2020-06-06 05:05:56 +0000 | [diff] [blame] | 10 | #include "core/fxcrt/string_view_template.h" |
Tom Sepez | ae26e66 | 2020-07-10 19:59:20 +0000 | [diff] [blame] | 11 | #include "testing/js_embedder_test.h" |
Lei Zhang | bfcf156 | 2022-07-07 01:49:26 +0000 | [diff] [blame] | 12 | #include "v8/include/v8-local-handle.h" |
| 13 | #include "v8/include/v8-persistent-handle.h" |
| 14 | #include "v8/include/v8-value.h" |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 15 | |
Dan Sinclair | 3fff90a | 2017-11-01 13:12:39 +0000 | [diff] [blame] | 16 | class CFXJSE_Engine; |
Lei Zhang | 8d477f7 | 2020-06-06 05:05:56 +0000 | [diff] [blame] | 17 | class CXFA_Document; |
| 18 | |
Tom Sepez | ae26e66 | 2020-07-10 19:59:20 +0000 | [diff] [blame] | 19 | class XFAJSEmbedderTest : public JSEmbedderTest { |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 20 | public: |
| 21 | XFAJSEmbedderTest(); |
| 22 | ~XFAJSEmbedderTest() override; |
| 23 | |
Lei Zhang | 208eecf | 2017-12-20 19:40:50 +0000 | [diff] [blame] | 24 | // EmbedderTest: |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 25 | void SetUp() override; |
| 26 | void TearDown() override; |
Lei Zhang | 208eecf | 2017-12-20 19:40:50 +0000 | [diff] [blame] | 27 | bool OpenDocumentWithOptions(const std::string& filename, |
| 28 | const char* password, |
Tom Sepez | 0784c73 | 2018-04-23 18:02:57 +0000 | [diff] [blame] | 29 | LinearizeOption linearize_option, |
| 30 | JavaScriptOption javascript_option) override; |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 31 | |
Nicolas Pena | e657567 | 2018-09-20 21:30:06 +0000 | [diff] [blame] | 32 | CXFA_Document* GetXFADocument() const; |
Tom Sepez | ae26e66 | 2020-07-10 19:59:20 +0000 | [diff] [blame] | 33 | CFXJSE_Engine* GetScriptContext() const { return script_context_; } |
Tom Sepez | d564b0d | 2020-11-06 18:28:10 +0000 | [diff] [blame] | 34 | v8::Local<v8::Value> GetValue() const; |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 35 | |
Tom Sepez | c839ac7 | 2018-12-14 20:34:11 +0000 | [diff] [blame] | 36 | bool Execute(ByteStringView input); |
| 37 | bool ExecuteSilenceFailure(ByteStringView input); |
Ryan Harrison | 580c159 | 2017-06-29 10:43:53 -0400 | [diff] [blame] | 38 | |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 39 | private: |
Tom Sepez | c839ac7 | 2018-12-14 20:34:11 +0000 | [diff] [blame] | 40 | bool ExecuteHelper(ByteStringView input); |
Tom Sepez | ae26e66 | 2020-07-10 19:59:20 +0000 | [diff] [blame] | 41 | |
Tom Sepez | d564b0d | 2020-11-06 18:28:10 +0000 | [diff] [blame] | 42 | v8::Global<v8::Value> value_; |
Tom Sepez | ae26e66 | 2020-07-10 19:59:20 +0000 | [diff] [blame] | 43 | CFXJSE_Engine* script_context_ = nullptr; |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | #endif // TESTING_XFA_JS_EMBEDDER_TEST_H_ |