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 "../../../core/include/fpdfapi/fpdf_parser.h" | 5 #include "../../../core/include/fpdfapi/fpdf_parser.h" |
6 #include "../../../testing/embedder_test.h" | 6 #include "../../../testing/embedder_test.h" |
7 #include "../../include/fsdk_mgr.h" | 7 #include "../../include/fsdk_mgr.h" |
8 #include "../../include/javascript/JS_Runtime.h" | 8 #include "../../include/javascript/JS_Runtime.h" |
9 #include "../../include/jsapi/fxjs_v8.h" | 9 #include "../../include/jsapi/fxjs_v8.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 m_pAllocator.reset(new FXJS_ArrayBufferAllocator()); | 25 m_pAllocator.reset(new FXJS_ArrayBufferAllocator()); |
26 | 26 |
27 v8::Isolate::CreateParams params; | 27 v8::Isolate::CreateParams params; |
28 params.array_buffer_allocator = m_pAllocator.get(); | 28 params.array_buffer_allocator = m_pAllocator.get(); |
29 m_pIsolate = v8::Isolate::New(params); | 29 m_pIsolate = v8::Isolate::New(params); |
30 | 30 |
31 v8::Isolate::Scope isolate_scope(m_pIsolate); | 31 v8::Isolate::Scope isolate_scope(m_pIsolate); |
32 v8::Locker locker(m_pIsolate); | 32 v8::Locker locker(m_pIsolate); |
33 v8::HandleScope handle_scope(m_pIsolate); | 33 v8::HandleScope handle_scope(m_pIsolate); |
34 FXJS_Initialize(0); | 34 FXJS_Initialize(0); |
35 FXJS_PrepareIsolate(m_pIsolate); | 35 FXJS_PerIsolateData::SetUp(m_pIsolate); |
36 FXJS_InitializeRuntime(m_pIsolate, nullptr, nullptr, m_pPersistentContext); | 36 FXJS_InitializeRuntime(m_pIsolate, nullptr, nullptr, m_pPersistentContext); |
37 } | 37 } |
38 | 38 |
39 void TearDown() override { | 39 void TearDown() override { |
40 FXJS_ReleaseRuntime(m_pIsolate, m_pPersistentContext); | 40 FXJS_ReleaseRuntime(m_pIsolate, m_pPersistentContext); |
41 FXJS_Release(); | 41 FXJS_Release(); |
42 EmbedderTest::TearDown(); | 42 EmbedderTest::TearDown(); |
43 } | 43 } |
44 | 44 |
45 v8::Isolate* isolate() const { return m_pIsolate; } | 45 v8::Isolate* isolate() const { return m_pIsolate; } |
(...skipping 16 matching lines...) Expand all Loading... |
62 FXJSErr error; | 62 FXJSErr error; |
63 CFX_WideString wsInfo; | 63 CFX_WideString wsInfo; |
64 CFX_WideString wsScript(kScript); | 64 CFX_WideString wsScript(kScript); |
65 int sts = FXJS_Execute(isolate(), nullptr, kScript, wcslen(kScript), &error); | 65 int sts = FXJS_Execute(isolate(), nullptr, kScript, wcslen(kScript), &error); |
66 EXPECT_EQ(0, sts); | 66 EXPECT_EQ(0, sts); |
67 | 67 |
68 v8::Local<v8::Object> This = FXJS_GetThisObj(isolate()); | 68 v8::Local<v8::Object> This = FXJS_GetThisObj(isolate()); |
69 v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred"); | 69 v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred"); |
70 EXPECT_TRUE(fred->IsNumber()); | 70 EXPECT_TRUE(fred->IsNumber()); |
71 } | 71 } |
OLD | NEW |