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