Limit spellcheck feedback to approximately 10 MB.
[chromium-blink-merge.git] / gin / per_context_data_unittest.cc
blob831ad1cb697b5ed088d6832ad64616e61ba223da
1 // Copyright 2014 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.
5 #include "gin/per_context_data.h"
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.h"
12 namespace gin {
14 typedef V8Test PerContextDataTest;
16 // Verifies PerContextData can be looked up by context and that it is not
17 // available once ContextHolder is destroyed.
18 TEST_F(PerContextDataTest, LookupAndDestruction) {
19 v8::Isolate::Scope isolate_scope(instance_->isolate());
20 v8::HandleScope handle_scope(instance_->isolate());
21 v8::Local<v8::Context> context = v8::Context::New(
22 instance_->isolate(), NULL, v8::Local<v8::ObjectTemplate>());
24 ContextHolder context_holder(instance_->isolate());
25 context_holder.SetContext(context);
26 PerContextData* per_context_data = PerContextData::From(context);
27 EXPECT_TRUE(per_context_data != NULL);
28 EXPECT_EQ(&context_holder, per_context_data->context_holder());
30 PerContextData* per_context_data = PerContextData::From(context);
31 EXPECT_TRUE(per_context_data == NULL);
34 } // namespace gin