OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include "../../../third_party/base/nonstd_unique_ptr.h" |
5 #include "../../../core/include/fpdfapi/fpdf_parser.h" | 6 #include "../../../core/include/fpdfapi/fpdf_parser.h" |
6 #include "../../../testing/embedder_test.h" | 7 #include "../../../testing/embedder_test.h" |
7 #include "../../include/fsdk_mgr.h" | |
8 #include "../../include/javascript/JS_Runtime.h" | |
9 #include "../../include/jsapi/fxjs_v8.h" | 8 #include "../../include/jsapi/fxjs_v8.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
11 | 10 |
12 namespace { | 11 namespace { |
13 | 12 |
14 const wchar_t kScript[] = L"fred = 7"; | 13 const wchar_t kScript[] = L"fred = 7"; |
15 | 14 |
16 } // namespace | 15 } // namespace |
17 | 16 |
18 class FXJSV8Embeddertest : public EmbedderTest { | 17 class FXJSV8Embeddertest : public EmbedderTest { |
(...skipping 23 matching lines...) Expand all Loading... |
42 } | 41 } |
43 | 42 |
44 v8::Isolate* isolate() const { return m_pIsolate; } | 43 v8::Isolate* isolate() const { return m_pIsolate; } |
45 v8::Local<v8::Context> GetV8Context() { | 44 v8::Local<v8::Context> GetV8Context() { |
46 return v8::Local<v8::Context>::New(m_pIsolate, m_pPersistentContext); | 45 return v8::Local<v8::Context>::New(m_pIsolate, m_pPersistentContext); |
47 } | 46 } |
48 | 47 |
49 private: | 48 private: |
50 v8::Isolate* m_pIsolate; | 49 v8::Isolate* m_pIsolate; |
51 v8::Global<v8::Context> m_pPersistentContext; | 50 v8::Global<v8::Context> m_pPersistentContext; |
52 nonstd::unique_ptr<v8::ArrayBuffer::Allocator> m_pAllocator; | 51 nonstd::unique_ptr<FXJS_ArrayBufferAllocator> m_pAllocator; |
53 }; | 52 }; |
54 | 53 |
55 TEST_F(FXJSV8Embeddertest, Getters) { | 54 TEST_F(FXJSV8Embeddertest, Getters) { |
56 v8::Isolate::Scope isolate_scope(isolate()); | 55 v8::Isolate::Scope isolate_scope(isolate()); |
57 v8::HandleScope handle_scope(isolate()); | 56 v8::HandleScope handle_scope(isolate()); |
58 v8::Context::Scope context_scope(GetV8Context()); | 57 v8::Context::Scope context_scope(GetV8Context()); |
59 | 58 |
60 FXJSErr error; | 59 FXJSErr error; |
61 CFX_WideString wsInfo; | 60 CFX_WideString wsInfo; |
62 CFX_WideString wsScript(kScript); | 61 CFX_WideString wsScript(kScript); |
63 int sts = FXJS_Execute(isolate(), nullptr, kScript, wcslen(kScript), &error); | 62 int sts = FXJS_Execute(isolate(), nullptr, kScript, wcslen(kScript), &error); |
64 EXPECT_EQ(0, sts); | 63 EXPECT_EQ(0, sts); |
65 | 64 |
66 v8::Local<v8::Object> This = FXJS_GetThisObj(isolate()); | 65 v8::Local<v8::Object> This = FXJS_GetThisObj(isolate()); |
67 v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred"); | 66 v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred"); |
68 EXPECT_TRUE(fred->IsNumber()); | 67 EXPECT_TRUE(fred->IsNumber()); |
69 } | 68 } |
OLD | NEW |