summaryrefslogtreecommitdiffstats
path: root/chrome/test/base
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 14:26:14 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 14:26:14 +0000
commitbff6037ea5f7ed4a016f7e2e7d5ecf23c6ee24db (patch)
treeeca915bf0ed1b8ee6d7ee024fec065e729a9f0cf /chrome/test/base
parent1a1ce4af29016cf5cabdca111081c00789310fc3 (diff)
downloadchromium_src-bff6037ea5f7ed4a016f7e2e7d5ecf23c6ee24db.zip
chromium_src-bff6037ea5f7ed4a016f7e2e7d5ecf23c6ee24db.tar.gz
chromium_src-bff6037ea5f7ed4a016f7e2e7d5ecf23c6ee24db.tar.bz2
Remove usage of deprecated V8 API from v8 unit test
BUG=324225 R=marja@chromium.org Review URL: https://codereview.chromium.org/99073003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238094 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/base')
-rw-r--r--chrome/test/base/v8_unit_test.cc84
1 files changed, 53 insertions, 31 deletions
diff --git a/chrome/test/base/v8_unit_test.cc b/chrome/test/base/v8_unit_test.cc
index 92a9b42..623f815 100644
--- a/chrome/test/base/v8_unit_test.cc
+++ b/chrome/test/base/v8_unit_test.cc
@@ -90,13 +90,13 @@ bool V8UnitTest::RunJavascriptTestF(
if (!ExecuteJavascriptLibraries())
return false;
- v8::Context::Scope context_scope(isolate_, context_);
v8::HandleScope handle_scope(isolate_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
+ v8::Context::Scope context_scope(context);
v8::Handle<v8::Value> functionProperty =
- context->Global()->Get(v8::String::New("runTest"));
+ context->Global()->Get(v8::String::NewFromUtf8(isolate_, "runTest"));
EXPECT_FALSE(functionProperty.IsEmpty());
if (::testing::Test::HasNonfatalFailure())
return false;
@@ -106,12 +106,20 @@ bool V8UnitTest::RunJavascriptTestF(
v8::Handle<v8::Function> function =
v8::Handle<v8::Function>::Cast(functionProperty);
- v8::Local<v8::Array> params = v8::Array::New();
- params->Set(0, v8::String::New(testFixture.data(), testFixture.size()));
- params->Set(1, v8::String::New(testName.data(), testName.size()));
+ v8::Local<v8::Array> params = v8::Array::New(isolate_);
+ params->Set(0,
+ v8::String::NewFromUtf8(isolate_,
+ testFixture.data(),
+ v8::String::kNormalString,
+ testFixture.size()));
+ params->Set(1,
+ v8::String::NewFromUtf8(isolate_,
+ testName.data(),
+ v8::String::kNormalString,
+ testName.size()));
v8::Handle<v8::Value> args[] = {
- v8::Boolean::New(false),
- v8::String::New("RUN_TEST_F"),
+ v8::Boolean::New(isolate_, false),
+ v8::String::NewFromUtf8(isolate_, "RUN_TEST_F"),
params
};
@@ -156,46 +164,60 @@ void V8UnitTest::InitPathsAndLibraries() {
}
void V8UnitTest::SetUp() {
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
- v8::Handle<v8::String> logString = v8::String::New("log");
+ v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate_);
+ v8::Handle<v8::String> logString = v8::String::NewFromUtf8(isolate_, "log");
v8::Handle<v8::FunctionTemplate> logFunction =
v8::FunctionTemplate::New(&V8UnitTest::Log);
global->Set(logString, logFunction);
// Set up chrome object for chrome.send().
- v8::Handle<v8::ObjectTemplate> chrome = v8::ObjectTemplate::New();
- global->Set(v8::String::New("chrome"), chrome);
- chrome->Set(v8::String::New("send"),
- v8::FunctionTemplate::New(&V8UnitTest::ChromeSend));
+ v8::Handle<v8::ObjectTemplate> chrome = v8::ObjectTemplate::New(isolate_);
+ global->Set(v8::String::NewFromUtf8(isolate_, "chrome"), chrome);
+ chrome->Set(v8::String::NewFromUtf8(isolate_, "send"),
+ v8::FunctionTemplate::New(isolate_, &V8UnitTest::ChromeSend));
// Set up console object for console.log(), etc.
- v8::Handle<v8::ObjectTemplate> console = v8::ObjectTemplate::New();
- global->Set(v8::String::New("console"), console);
+ v8::Handle<v8::ObjectTemplate> console = v8::ObjectTemplate::New(isolate_);
+ global->Set(v8::String::NewFromUtf8(isolate_, "console"), console);
console->Set(logString, logFunction);
- console->Set(v8::String::New("info"), logFunction);
- console->Set(v8::String::New("warn"), logFunction);
- console->Set(v8::String::New("error"),
- v8::FunctionTemplate::New(&V8UnitTest::Error));
+ console->Set(v8::String::NewFromUtf8(isolate_, "info"), logFunction);
+ console->Set(v8::String::NewFromUtf8(isolate_, "warn"), logFunction);
+ console->Set(v8::String::NewFromUtf8(isolate_, "error"),
+ v8::FunctionTemplate::New(isolate_, &V8UnitTest::Error));
context_.Reset(isolate_, v8::Context::New(isolate_, NULL, global));
}
void V8UnitTest::SetGlobalStringVar(const std::string& var_name,
const std::string& value) {
- v8::Context::Scope context_scope(isolate_, context_);
- v8::Local<v8::Context>::New(isolate_, context_)->Global()
- ->Set(v8::String::New(var_name.c_str(), var_name.length()),
- v8::String::New(value.c_str(), value.length()));
+ v8::Local<v8::Context> context =
+ v8::Local<v8::Context>::New(isolate_, context_);
+ v8::Context::Scope context_scope(context);
+ context->Global()->Set(
+ v8::String::NewFromUtf8(isolate_,
+ var_name.c_str(),
+ v8::String::kNormalString,
+ var_name.length()),
+ v8::String::NewFromUtf8(
+ isolate_, value.c_str(), v8::String::kNormalString, value.length()));
}
void V8UnitTest::ExecuteScriptInContext(const base::StringPiece& script_source,
const base::StringPiece& script_name) {
- v8::Context::Scope context_scope(isolate_, context_);
v8::HandleScope handle_scope(isolate_);
- v8::Handle<v8::String> source = v8::String::New(script_source.data(),
- script_source.size());
- v8::Handle<v8::String> name = v8::String::New(script_name.data(),
- script_name.size());
+ v8::Local<v8::Context> context =
+ v8::Local<v8::Context>::New(isolate_, context_);
+ v8::Context::Scope context_scope(context);
+ v8::Handle<v8::String> source =
+ v8::String::NewFromUtf8(isolate_,
+ script_source.data(),
+ v8::String::kNormalString,
+ script_source.size());
+ v8::Handle<v8::String> name =
+ v8::String::NewFromUtf8(isolate_,
+ script_name.data(),
+ v8::String::kNormalString,
+ script_name.size());
v8::TryCatch try_catch;
v8::Handle<v8::Script> script = v8::Script::Compile(source, name);
@@ -229,13 +251,13 @@ std::string V8UnitTest::ExceptionToString(const v8::TryCatch& try_catch) {
}
void V8UnitTest::TestFunction(const std::string& function_name) {
- v8::Context::Scope context_scope(isolate_, context_);
v8::HandleScope handle_scope(isolate_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
+ v8::Context::Scope context_scope(context);
- v8::Handle<v8::Value> functionProperty =
- context->Global()->Get(v8::String::New(function_name.c_str()));
+ v8::Handle<v8::Value> functionProperty = context->Global()->Get(
+ v8::String::NewFromUtf8(isolate_, function_name.c_str()));
ASSERT_FALSE(functionProperty.IsEmpty());
ASSERT_TRUE(functionProperty->IsFunction());
v8::Handle<v8::Function> function =