Commit 99ea16bb authored by sammc@chromium.org's avatar sammc@chromium.org

Don't create a gin::IsolateHolder in extensions unittests.

This isn't necessary because the test environment set up includes Blink
creating an isolate holder.

Review URL: https://codereview.chromium.org/402553002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283904 0039d316-1c4b-4281-b951-d872f2087c98
parent 2ea2726b
...@@ -121,15 +121,13 @@ class ModuleSystemTestEnvironment::StringSourceMap ...@@ -121,15 +121,13 @@ class ModuleSystemTestEnvironment::StringSourceMap
std::map<std::string, std::string> source_map_; std::map<std::string, std::string> source_map_;
}; };
ModuleSystemTestEnvironment::ModuleSystemTestEnvironment( ModuleSystemTestEnvironment::ModuleSystemTestEnvironment(v8::Isolate* isolate)
gin::IsolateHolder* isolate_holder) : isolate_(isolate),
: isolate_holder_(isolate_holder), context_holder_(new gin::ContextHolder(isolate_)),
context_holder_(new gin::ContextHolder(isolate_holder_->isolate())), handle_scope_(isolate_),
handle_scope_(isolate_holder_->isolate()),
source_map_(new StringSourceMap()) { source_map_(new StringSourceMap()) {
context_holder_->SetContext( context_holder_->SetContext(v8::Context::New(
v8::Context::New(isolate_holder->isolate(), isolate, g_v8_extension_configurator.Get().GetConfiguration()));
g_v8_extension_configurator.Get().GetConfiguration()));
context_.reset(new ScriptContext(context_holder_->context(), context_.reset(new ScriptContext(context_holder_->context(),
NULL, // WebFrame NULL, // WebFrame
NULL, // Extension NULL, // Extension
...@@ -202,16 +200,15 @@ void ModuleSystemTestEnvironment::ShutdownModuleSystem() { ...@@ -202,16 +200,15 @@ void ModuleSystemTestEnvironment::ShutdownModuleSystem() {
v8::Handle<v8::Object> ModuleSystemTestEnvironment::CreateGlobal( v8::Handle<v8::Object> ModuleSystemTestEnvironment::CreateGlobal(
const std::string& name) { const std::string& name) {
v8::Isolate* isolate = isolate_holder_->isolate(); v8::EscapableHandleScope handle_scope(isolate_);
v8::EscapableHandleScope handle_scope(isolate); v8::Local<v8::Object> object = v8::Object::New(isolate_);
v8::Local<v8::Object> object = v8::Object::New(isolate); isolate_->GetCurrentContext()->Global()->Set(
isolate->GetCurrentContext()->Global()->Set( v8::String::NewFromUtf8(isolate_, name.c_str()), object);
v8::String::NewFromUtf8(isolate, name.c_str()), object);
return handle_scope.Escape(object); return handle_scope.Escape(object);
} }
ModuleSystemTest::ModuleSystemTest() ModuleSystemTest::ModuleSystemTest()
: isolate_holder_(v8::Isolate::GetCurrent(), NULL), : isolate_(v8::Isolate::GetCurrent()),
env_(CreateEnvironment()), env_(CreateEnvironment()),
should_assertions_be_made_(true) { should_assertions_be_made_(true) {
} }
...@@ -227,7 +224,7 @@ void ModuleSystemTest::TearDown() { ...@@ -227,7 +224,7 @@ void ModuleSystemTest::TearDown() {
} }
scoped_ptr<ModuleSystemTestEnvironment> ModuleSystemTest::CreateEnvironment() { scoped_ptr<ModuleSystemTestEnvironment> ModuleSystemTest::CreateEnvironment() {
return make_scoped_ptr(new ModuleSystemTestEnvironment(&isolate_holder_)); return make_scoped_ptr(new ModuleSystemTestEnvironment(isolate_));
} }
void ModuleSystemTest::ExpectNoAssertionsMade() { void ModuleSystemTest::ExpectNoAssertionsMade() {
...@@ -235,7 +232,7 @@ void ModuleSystemTest::ExpectNoAssertionsMade() { ...@@ -235,7 +232,7 @@ void ModuleSystemTest::ExpectNoAssertionsMade() {
} }
void ModuleSystemTest::RunResolvedPromises() { void ModuleSystemTest::RunResolvedPromises() {
isolate_holder_.isolate()->RunMicrotasks(); isolate_->RunMicrotasks();
} }
} // namespace extensions } // namespace extensions
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "extensions/renderer/scoped_persistent.h" #include "extensions/renderer/scoped_persistent.h"
#include "extensions/renderer/script_context.h" #include "extensions/renderer/script_context.h"
#include "gin/public/context_holder.h" #include "gin/public/context_holder.h"
#include "gin/public/isolate_holder.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
...@@ -20,7 +19,7 @@ class ModuleSystemTestEnvironment { ...@@ -20,7 +19,7 @@ class ModuleSystemTestEnvironment {
class AssertNatives; class AssertNatives;
class StringSourceMap; class StringSourceMap;
explicit ModuleSystemTestEnvironment(gin::IsolateHolder* isolate_holder); explicit ModuleSystemTestEnvironment(v8::Isolate* isolate);
~ModuleSystemTestEnvironment(); ~ModuleSystemTestEnvironment();
// Register a named JS module in the module system. // Register a named JS module in the module system.
...@@ -50,12 +49,12 @@ class ModuleSystemTestEnvironment { ...@@ -50,12 +49,12 @@ class ModuleSystemTestEnvironment {
ScriptContext* context() { return context_.get(); } ScriptContext* context() { return context_.get(); }
v8::Isolate* isolate() { return isolate_holder_->isolate(); } v8::Isolate* isolate() { return isolate_; }
AssertNatives* assert_natives() { return assert_natives_; } AssertNatives* assert_natives() { return assert_natives_; }
private: private:
gin::IsolateHolder* isolate_holder_; v8::Isolate* isolate_;
scoped_ptr<gin::ContextHolder> context_holder_; scoped_ptr<gin::ContextHolder> context_holder_;
v8::HandleScope handle_scope_; v8::HandleScope handle_scope_;
scoped_ptr<ScriptContext> context_; scoped_ptr<ScriptContext> context_;
...@@ -98,7 +97,7 @@ class ModuleSystemTest : public testing::Test { ...@@ -98,7 +97,7 @@ class ModuleSystemTest : public testing::Test {
void RunResolvedPromises(); void RunResolvedPromises();
private: private:
gin::IsolateHolder isolate_holder_; v8::Isolate* isolate_;
scoped_ptr<ModuleSystemTestEnvironment> env_; scoped_ptr<ModuleSystemTestEnvironment> env_;
bool should_assertions_be_made_; bool should_assertions_be_made_;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "extensions/renderer/script_context.h" #include "extensions/renderer/script_context.h"
#include "extensions/renderer/script_context_set.h" #include "extensions/renderer/script_context_set.h"
#include "gin/public/context_holder.h" #include "gin/public/context_holder.h"
#include "gin/public/isolate_holder.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
...@@ -21,7 +20,6 @@ TEST(ScriptContextSet, Lifecycle) { ...@@ -21,7 +20,6 @@ TEST(ScriptContextSet, Lifecycle) {
ScriptContextSet context_set; ScriptContextSet context_set;
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();
gin::IsolateHolder isolate_holder(isolate, NULL);
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
gin::ContextHolder context_holder(isolate); gin::ContextHolder context_holder(isolate);
context_holder.SetContext(v8::Context::New(isolate)); context_holder.SetContext(v8::Context::New(isolate));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment