Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / gin / test / v8_test.cc
1 // Copyright 2013 The Chromium 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 "gin/test/v8_test.h"
6
7 #include "gin/array_buffer.h"
8 #include "gin/public/isolate_holder.h"
9
10 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
11 #include "gin/public/isolate_holder.h"
12 #endif
13
14 using v8::Context;
15 using v8::Local;
16 using v8::HandleScope;
17
18 namespace gin {
19
20 V8Test::V8Test() {
21 }
22
23 V8Test::~V8Test() {
24 }
25
26 void V8Test::SetUp() {
27 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
28   gin::IsolateHolder::LoadV8Snapshot();
29 #endif
30   gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
31                                  gin::ArrayBufferAllocator::SharedInstance());
32   instance_.reset(new gin::IsolateHolder);
33   instance_->isolate()->Enter();
34   HandleScope handle_scope(instance_->isolate());
35   context_.Reset(instance_->isolate(), Context::New(instance_->isolate()));
36   Local<Context>::New(instance_->isolate(), context_)->Enter();
37 }
38
39 void V8Test::TearDown() {
40   {
41     HandleScope handle_scope(instance_->isolate());
42     Local<Context>::New(instance_->isolate(), context_)->Exit();
43     context_.Reset();
44   }
45   instance_->isolate()->Exit();
46   instance_.reset();
47 }
48
49 }  // namespace gin