summaryrefslogtreecommitdiffstats
path: root/gin/modules
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-01 06:45:10 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-01 06:45:10 +0000
commit6d73d2a65253c8fe87f01dc2ee2aa902ea32c6bf (patch)
tree2d0bf21c79a0cd738aa3e0ec4e835dff6837e1b5 /gin/modules
parente7f6fde14dd18a182ac86497a5e9fccb5fb65776 (diff)
downloadchromium_src-6d73d2a65253c8fe87f01dc2ee2aa902ea32c6bf.zip
chromium_src-6d73d2a65253c8fe87f01dc2ee2aa902ea32c6bf.tar.gz
chromium_src-6d73d2a65253c8fe87f01dc2ee2aa902ea32c6bf.tar.bz2
Two gin tests
Verifies ModuleRegistry can be looked up from context and that it is no longer available once ContextHolder is destroyed. Similarly verifies PerContextData is available once a ContextHolder is created and that it's context_holder() member points back to the ContextHolder. BUG=none TEST=none R=abarth@chromium.org Review URL: https://codereview.chromium.org/182683005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin/modules')
-rw-r--r--gin/modules/module_registry_unittest.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/gin/modules/module_registry_unittest.cc b/gin/modules/module_registry_unittest.cc
new file mode 100644
index 0000000..af9dd00
--- /dev/null
+++ b/gin/modules/module_registry_unittest.cc
@@ -0,0 +1,33 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gin/modules/module_registry.h"
+
+#include "gin/public/context_holder.h"
+#include "gin/public/isolate_holder.h"
+#include "gin/test/v8_test.h"
+#include "v8/include/v8.h"
+
+namespace gin {
+
+typedef V8Test ModuleRegistryTest;
+
+// Verifies ModuleRegistry is not available after ContextHolder has been
+// deleted.
+TEST_F(ModuleRegistryTest, DestroyedWithContext) {
+ v8::Isolate::Scope isolate_scope(instance_->isolate());
+ v8::HandleScope handle_scope(instance_->isolate());
+ v8::Handle<v8::Context> context = v8::Context::New(
+ instance_->isolate(), NULL, v8::Handle<v8::ObjectTemplate>());
+ {
+ ContextHolder context_holder(instance_->isolate());
+ context_holder.SetContext(context);
+ ModuleRegistry* registry = ModuleRegistry::From(context);
+ EXPECT_TRUE(registry != NULL);
+ }
+ ModuleRegistry* registry = ModuleRegistry::From(context);
+ EXPECT_TRUE(registry == NULL);
+}
+
+} // namespace gin