| 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 "testing/js_embedder_test.h" | 5 #include "testing/js_embedder_test.h" | 
| 6 | 6 | 
| 7 JSEmbedderTest::JSEmbedderTest() | 7 JSEmbedderTest::JSEmbedderTest() | 
| 8     : m_pArrayBufferAllocator(new FXJS_ArrayBufferAllocator), | 8     : m_pArrayBufferAllocator(new FXJS_ArrayBufferAllocator), | 
| 9       m_pIsolate(nullptr) {} | 9       m_pIsolate(nullptr) {} | 
| 10 | 10 | 
| 11 JSEmbedderTest::~JSEmbedderTest() {} | 11 JSEmbedderTest::~JSEmbedderTest() {} | 
| 12 | 12 | 
| 13 void JSEmbedderTest::SetUp() { | 13 void JSEmbedderTest::SetUp() { | 
| 14   v8::Isolate::CreateParams params; | 14   v8::Isolate::CreateParams params; | 
| 15   params.array_buffer_allocator = m_pArrayBufferAllocator.get(); | 15   params.array_buffer_allocator = m_pArrayBufferAllocator.get(); | 
| 16   m_pIsolate = v8::Isolate::New(params); | 16   m_pIsolate = v8::Isolate::New(params); | 
| 17 | 17 | 
| 18   EmbedderTest::SetExternalIsolate(m_pIsolate); | 18   EmbedderTest::SetExternalIsolate(m_pIsolate); | 
| 19   EmbedderTest::SetUp(); | 19   EmbedderTest::SetUp(); | 
| 20 | 20 | 
| 21   v8::Isolate::Scope isolate_scope(m_pIsolate); | 21   v8::Isolate::Scope isolate_scope(m_pIsolate); | 
| 22 #ifdef PDF_ENABLE_XFA |  | 
| 23   v8::Locker locker(m_pIsolate); |  | 
| 24 #endif  // PDF_ENABLE_XFA |  | 
| 25   v8::HandleScope handle_scope(m_pIsolate); | 22   v8::HandleScope handle_scope(m_pIsolate); | 
| 26   FXJS_PerIsolateData::SetUp(m_pIsolate); | 23   FXJS_PerIsolateData::SetUp(m_pIsolate); | 
| 27   FXJS_InitializeRuntime(m_pIsolate, nullptr, &m_pPersistentContext, | 24   FXJS_InitializeRuntime(m_pIsolate, nullptr, &m_pPersistentContext, | 
| 28                          &m_StaticObjects); | 25                          &m_StaticObjects); | 
| 29 } | 26 } | 
| 30 | 27 | 
| 31 void JSEmbedderTest::TearDown() { | 28 void JSEmbedderTest::TearDown() { | 
| 32   FXJS_ReleaseRuntime(m_pIsolate, &m_pPersistentContext, &m_StaticObjects); | 29   FXJS_ReleaseRuntime(m_pIsolate, &m_pPersistentContext, &m_StaticObjects); | 
| 33   m_pPersistentContext.Reset(); | 30   m_pPersistentContext.Reset(); | 
| 34   FXJS_Release(); | 31   FXJS_Release(); | 
| 35   EmbedderTest::TearDown(); | 32   EmbedderTest::TearDown(); | 
| 36   m_pIsolate->Dispose(); | 33   m_pIsolate->Dispose(); | 
| 37   m_pIsolate = nullptr; | 34   m_pIsolate = nullptr; | 
| 38 } | 35 } | 
| 39 | 36 | 
| 40 v8::Isolate* JSEmbedderTest::isolate() { | 37 v8::Isolate* JSEmbedderTest::isolate() { | 
| 41   return m_pIsolate; | 38   return m_pIsolate; | 
| 42 } | 39 } | 
| 43 | 40 | 
| 44 v8::Local<v8::Context> JSEmbedderTest::GetV8Context() { | 41 v8::Local<v8::Context> JSEmbedderTest::GetV8Context() { | 
| 45   return m_pPersistentContext.Get(m_pIsolate); | 42   return m_pPersistentContext.Get(m_pIsolate); | 
| 46 } | 43 } | 
| OLD | NEW | 
|---|