1 // Copyright 2015 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 #include "testing/js_embedder_test.h" 6 7 #include "third_party/base/ptr_util.h" 8 JSEmbedderTest()9JSEmbedderTest::JSEmbedderTest() 10 : m_pArrayBufferAllocator(pdfium::MakeUnique<FXJS_ArrayBufferAllocator>()) { 11 } 12 ~JSEmbedderTest()13JSEmbedderTest::~JSEmbedderTest() {} 14 SetUp()15void JSEmbedderTest::SetUp() { 16 v8::Isolate::CreateParams params; 17 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); 18 m_pIsolate = v8::Isolate::New(params); 19 20 EmbedderTest::SetExternalIsolate(m_pIsolate); 21 EmbedderTest::SetUp(); 22 23 v8::Isolate::Scope isolate_scope(m_pIsolate); 24 v8::HandleScope handle_scope(m_pIsolate); 25 FXJS_PerIsolateData::SetUp(m_pIsolate); 26 m_Engine = pdfium::MakeUnique<CFXJS_Engine>(m_pIsolate); 27 m_Engine->InitializeEngine(); 28 } 29 TearDown()30void JSEmbedderTest::TearDown() { 31 m_Engine->ReleaseEngine(); 32 m_Engine.reset(); 33 EmbedderTest::TearDown(); 34 m_pIsolate->Dispose(); 35 m_pIsolate = nullptr; 36 } 37 isolate()38v8::Isolate* JSEmbedderTest::isolate() { 39 return m_pIsolate; 40 } 41 GetV8Context()42v8::Local<v8::Context> JSEmbedderTest::GetV8Context() { 43 return m_Engine->GetPersistentContext(); 44 } 45