Fix FullScreen crash in Webapp
[platform/framework/web/chromium-efl.git] / gin / per_context_data_unittest.cc
1 // Copyright 2014 The Chromium Authors
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/per_context_data.h"
6
7 #include "gin/public/context_holder.h"
8 #include "gin/public/isolate_holder.h"
9 #include "gin/test/v8_test.h"
10 #include "v8/include/v8-context.h"
11 #include "v8/include/v8-isolate.h"
12
13 namespace gin {
14
15 typedef V8Test PerContextDataTest;
16
17 // Verifies PerContextData can be looked up by context and that it is not
18 // available once ContextHolder is destroyed.
19 TEST_F(PerContextDataTest, LookupAndDestruction) {
20   v8::Isolate::Scope isolate_scope(instance_->isolate());
21   v8::HandleScope handle_scope(instance_->isolate());
22   v8::Local<v8::Context> context = v8::Context::New(
23       instance_->isolate(), NULL, v8::Local<v8::ObjectTemplate>());
24   {
25     ContextHolder context_holder(instance_->isolate());
26     context_holder.SetContext(context);
27     PerContextData* per_context_data = PerContextData::From(context);
28     EXPECT_TRUE(per_context_data != NULL);
29     EXPECT_EQ(&context_holder, per_context_data->context_holder());
30   }
31   PerContextData* per_context_data = PerContextData::From(context);
32   EXPECT_TRUE(per_context_data == NULL);
33 }
34
35 }  // namespace gin