Remove deprecated APIs from two more tests
BUG=4134 R=epertoso@chromium.org LOG=n Review URL: https://codereview.chromium.org/1455603002 Cr-Commit-Position: refs/heads/master@{#32072}
This commit is contained in:
parent
0bcfb26e7c
commit
3e882ff1ea
@ -25,6 +25,9 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// TODO(jochen): Remove this after the setting is turned on globally.
|
||||
#define V8_IMMINENT_DEPRECATION_WARNINGS
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "src/v8.h"
|
||||
@ -57,7 +60,7 @@ using ::v8::V8;
|
||||
// Migrating an isolate
|
||||
class KangarooThread : public v8::base::Thread {
|
||||
public:
|
||||
KangarooThread(v8::Isolate* isolate, v8::Handle<v8::Context> context)
|
||||
KangarooThread(v8::Isolate* isolate, v8::Local<v8::Context> context)
|
||||
: Thread(Options("KangarooThread")),
|
||||
isolate_(isolate),
|
||||
context_(isolate, context) {}
|
||||
@ -74,7 +77,7 @@ class KangarooThread : public v8::base::Thread {
|
||||
v8::Context::Scope context_scope(context);
|
||||
Local<Value> v = CompileRun("getValue()");
|
||||
CHECK(v->IsNumber());
|
||||
CHECK_EQ(30, static_cast<int>(v->NumberValue()));
|
||||
CHECK_EQ(30, static_cast<int>(v->NumberValue(context).FromJust()));
|
||||
}
|
||||
{
|
||||
v8::Locker locker(isolate_);
|
||||
@ -85,7 +88,7 @@ class KangarooThread : public v8::base::Thread {
|
||||
v8::Context::Scope context_scope(context);
|
||||
Local<Value> v = CompileRun("getValue()");
|
||||
CHECK(v->IsNumber());
|
||||
CHECK_EQ(30, static_cast<int>(v->NumberValue()));
|
||||
CHECK_EQ(30, static_cast<int>(v->NumberValue(context).FromJust()));
|
||||
}
|
||||
isolate_->Dispose();
|
||||
}
|
||||
@ -118,14 +121,14 @@ TEST(KangarooIsolates) {
|
||||
}
|
||||
|
||||
|
||||
static void CalcFibAndCheck() {
|
||||
static void CalcFibAndCheck(v8::Local<v8::Context> context) {
|
||||
Local<Value> v = CompileRun("function fib(n) {"
|
||||
" if (n <= 2) return 1;"
|
||||
" return fib(n-1) + fib(n-2);"
|
||||
"}"
|
||||
"fib(10)");
|
||||
CHECK(v->IsNumber());
|
||||
CHECK_EQ(55, static_cast<int>(v->NumberValue()));
|
||||
CHECK_EQ(55, static_cast<int>(v->NumberValue(context).FromJust()));
|
||||
}
|
||||
|
||||
class JoinableThread {
|
||||
@ -189,7 +192,7 @@ class IsolateLockingThreadWithLocalContext : public JoinableThread {
|
||||
LocalContext local_context(isolate_);
|
||||
CHECK_EQ(reinterpret_cast<v8::internal::Isolate*>(isolate_),
|
||||
v8::internal::Isolate::Current());
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(local_context.local());
|
||||
}
|
||||
private:
|
||||
v8::Isolate* isolate_;
|
||||
@ -241,11 +244,11 @@ class IsolateNestedLockingThread : public JoinableThread {
|
||||
LocalContext local_context(isolate_);
|
||||
{
|
||||
v8::Locker another_lock(isolate_);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(local_context.local());
|
||||
}
|
||||
{
|
||||
v8::Locker another_lock(isolate_);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(local_context.local());
|
||||
}
|
||||
}
|
||||
private:
|
||||
@ -289,7 +292,7 @@ class SeparateIsolatesLocksNonexclusiveThread : public JoinableThread {
|
||||
|
||||
IsolateLockingThreadWithLocalContext threadB(isolate2_);
|
||||
threadB.Start();
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(local_context.local());
|
||||
threadB.Join();
|
||||
}
|
||||
private:
|
||||
@ -323,11 +326,10 @@ TEST(SeparateIsolatesLocksNonexclusive) {
|
||||
class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread {
|
||||
public:
|
||||
explicit LockIsolateAndCalculateFibSharedContextThread(
|
||||
v8::Isolate* isolate, v8::Handle<v8::Context> context)
|
||||
: JoinableThread("LockIsolateAndCalculateFibThread"),
|
||||
isolate_(isolate),
|
||||
context_(isolate, context) {
|
||||
}
|
||||
v8::Isolate* isolate, v8::Local<v8::Context> context)
|
||||
: JoinableThread("LockIsolateAndCalculateFibThread"),
|
||||
isolate_(isolate),
|
||||
context_(isolate, context) {}
|
||||
|
||||
virtual void Run() {
|
||||
v8::Locker lock(isolate_);
|
||||
@ -336,7 +338,7 @@ class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread {
|
||||
v8::Local<v8::Context> context =
|
||||
v8::Local<v8::Context>::New(isolate_, context_);
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
private:
|
||||
v8::Isolate* isolate_;
|
||||
@ -357,7 +359,7 @@ class LockerUnlockerThread : public JoinableThread {
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate_);
|
||||
{
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
{
|
||||
LockIsolateAndCalculateFibSharedContextThread thread(isolate_, context);
|
||||
@ -369,7 +371,7 @@ class LockerUnlockerThread : public JoinableThread {
|
||||
isolate_->Enter();
|
||||
{
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,7 +413,7 @@ class LockTwiceAndUnlockThread : public JoinableThread {
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate_);
|
||||
{
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
{
|
||||
v8::Locker second_lock(isolate_);
|
||||
@ -426,7 +428,7 @@ class LockTwiceAndUnlockThread : public JoinableThread {
|
||||
isolate_->Enter();
|
||||
{
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -472,10 +474,10 @@ class LockAndUnlockDifferentIsolatesThread : public JoinableThread {
|
||||
{
|
||||
v8::Isolate::Scope isolate_scope(isolate1_);
|
||||
v8::HandleScope handle_scope(isolate1_);
|
||||
v8::Handle<v8::Context> context1 = v8::Context::New(isolate1_);
|
||||
v8::Local<v8::Context> context1 = v8::Context::New(isolate1_);
|
||||
{
|
||||
v8::Context::Scope context_scope(context1);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context1);
|
||||
}
|
||||
thread.Reset(new LockIsolateAndCalculateFibSharedContextThread(
|
||||
isolate1_, context1));
|
||||
@ -486,17 +488,17 @@ class LockAndUnlockDifferentIsolatesThread : public JoinableThread {
|
||||
{
|
||||
v8::Isolate::Scope isolate_scope(isolate2_);
|
||||
v8::HandleScope handle_scope(isolate2_);
|
||||
v8::Handle<v8::Context> context2 = v8::Context::New(isolate2_);
|
||||
v8::Local<v8::Context> context2 = v8::Context::New(isolate2_);
|
||||
{
|
||||
v8::Context::Scope context_scope(context2);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context2);
|
||||
}
|
||||
v8::Unlocker unlock1(isolate1_);
|
||||
CHECK(!v8::Locker::IsLocked(isolate1_));
|
||||
CHECK(v8::Locker::IsLocked(isolate2_));
|
||||
v8::Context::Scope context_scope(context2);
|
||||
thread->Start();
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context2);
|
||||
thread->Join();
|
||||
}
|
||||
}
|
||||
@ -522,11 +524,10 @@ TEST(LockAndUnlockDifferentIsolates) {
|
||||
|
||||
class LockUnlockLockThread : public JoinableThread {
|
||||
public:
|
||||
LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context)
|
||||
: JoinableThread("LockUnlockLockThread"),
|
||||
isolate_(isolate),
|
||||
context_(isolate, context) {
|
||||
}
|
||||
LockUnlockLockThread(v8::Isolate* isolate, v8::Local<v8::Context> context)
|
||||
: JoinableThread("LockUnlockLockThread"),
|
||||
isolate_(isolate),
|
||||
context_(isolate, context) {}
|
||||
|
||||
virtual void Run() {
|
||||
v8::Locker lock1(isolate_);
|
||||
@ -538,7 +539,7 @@ class LockUnlockLockThread : public JoinableThread {
|
||||
v8::Local<v8::Context> context =
|
||||
v8::Local<v8::Context>::New(isolate_, context_);
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
{
|
||||
v8::Unlocker unlock1(isolate_);
|
||||
@ -553,7 +554,7 @@ class LockUnlockLockThread : public JoinableThread {
|
||||
v8::Local<v8::Context> context =
|
||||
v8::Local<v8::Context>::New(isolate_, context_);
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -579,7 +580,7 @@ TEST(LockUnlockLockMultithreaded) {
|
||||
v8::Locker locker_(isolate);
|
||||
v8::Isolate::Scope isolate_scope(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Handle<v8::Context> context = v8::Context::New(isolate);
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
||||
for (int i = 0; i < kNThreads; i++) {
|
||||
threads.Add(new LockUnlockLockThread(
|
||||
isolate, context));
|
||||
@ -591,7 +592,7 @@ TEST(LockUnlockLockMultithreaded) {
|
||||
|
||||
class LockUnlockLockDefaultIsolateThread : public JoinableThread {
|
||||
public:
|
||||
explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context)
|
||||
explicit LockUnlockLockDefaultIsolateThread(v8::Local<v8::Context> context)
|
||||
: JoinableThread("LockUnlockLockDefaultIsolateThread"),
|
||||
context_(CcTest::isolate(), context) {}
|
||||
|
||||
@ -603,7 +604,7 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread {
|
||||
v8::Local<v8::Context> context =
|
||||
v8::Local<v8::Context>::New(CcTest::isolate(), context_);
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
{
|
||||
v8::Unlocker unlock1(CcTest::isolate());
|
||||
@ -614,7 +615,7 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread {
|
||||
v8::Local<v8::Context> context =
|
||||
v8::Local<v8::Context>::New(CcTest::isolate(), context_);
|
||||
v8::Context::Scope context_scope(context);
|
||||
CalcFibAndCheck();
|
||||
CalcFibAndCheck(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -655,11 +656,12 @@ TEST(Regress1433) {
|
||||
v8::Locker lock(isolate);
|
||||
v8::Isolate::Scope isolate_scope(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Handle<Context> context = v8::Context::New(isolate);
|
||||
v8::Local<Context> context = v8::Context::New(isolate);
|
||||
v8::Context::Scope context_scope(context);
|
||||
v8::Handle<String> source = v8::String::NewFromUtf8(isolate, "1+1");
|
||||
v8::Handle<Script> script = v8::Script::Compile(source);
|
||||
v8::Handle<Value> result = script->Run();
|
||||
v8::Local<String> source = v8_str("1+1");
|
||||
v8::Local<Script> script =
|
||||
v8::Script::Compile(context, source).ToLocalChecked();
|
||||
v8::Local<Value> result = script->Run(context).ToLocalChecked();
|
||||
v8::String::Utf8Value utf8(result);
|
||||
}
|
||||
isolate->Dispose();
|
||||
|
@ -27,6 +27,9 @@
|
||||
//
|
||||
// Tests of logging functions from log.h
|
||||
|
||||
// TODO(jochen): Remove this after the setting is turned on globally.
|
||||
#define V8_IMMINENT_DEPRECATION_WARNINGS
|
||||
|
||||
#ifdef __linux__
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
@ -85,7 +88,7 @@ class ScopedLoggerInitializer {
|
||||
i::FLAG_log = saved_log_;
|
||||
}
|
||||
|
||||
v8::Handle<v8::Context>& env() { return env_; }
|
||||
v8::Local<v8::Context>& env() { return env_; }
|
||||
|
||||
v8::Isolate* isolate() { return isolate_; }
|
||||
|
||||
@ -106,7 +109,7 @@ class ScopedLoggerInitializer {
|
||||
v8::Isolate* isolate_;
|
||||
v8::Isolate::Scope isolate_scope_;
|
||||
v8::HandleScope scope_;
|
||||
v8::Handle<v8::Context> env_;
|
||||
v8::Local<v8::Context> env_;
|
||||
Logger* logger_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer);
|
||||
@ -307,18 +310,21 @@ class SimpleExternalString : public v8::String::ExternalStringResource {
|
||||
|
||||
TEST(Issue23768) {
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
|
||||
v8::Local<v8::Context> env = v8::Context::New(CcTest::isolate());
|
||||
env->Enter();
|
||||
|
||||
SimpleExternalString source_ext_str("(function ext() {})();");
|
||||
v8::Local<v8::String> source =
|
||||
v8::String::NewExternal(CcTest::isolate(), &source_ext_str);
|
||||
v8::String::NewExternalTwoByte(CcTest::isolate(), &source_ext_str)
|
||||
.ToLocalChecked();
|
||||
// Script needs to have a name in order to trigger InitLineEnds execution.
|
||||
v8::Handle<v8::String> origin =
|
||||
v8::String::NewFromUtf8(CcTest::isolate(), "issue-23768-test");
|
||||
v8::Handle<v8::Script> evil_script = CompileWithOrigin(source, origin);
|
||||
v8::Local<v8::String> origin =
|
||||
v8::String::NewFromUtf8(CcTest::isolate(), "issue-23768-test",
|
||||
v8::NewStringType::kNormal)
|
||||
.ToLocalChecked();
|
||||
v8::Local<v8::Script> evil_script = CompileWithOrigin(source, origin);
|
||||
CHECK(!evil_script.IsEmpty());
|
||||
CHECK(!evil_script->Run().IsEmpty());
|
||||
CHECK(!evil_script->Run(env).IsEmpty());
|
||||
i::Handle<i::ExternalTwoByteString> i_source(
|
||||
i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source)));
|
||||
// This situation can happen if source was an external string disposed
|
||||
@ -346,14 +352,18 @@ TEST(LogCallbacks) {
|
||||
v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New(
|
||||
isolate, v8::FunctionTemplate::New(isolate));
|
||||
obj->SetClassName(v8_str("Obj"));
|
||||
v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
|
||||
v8::Local<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
|
||||
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, obj);
|
||||
proto->Set(v8_str("method1"),
|
||||
v8::FunctionTemplate::New(isolate, ObjMethod1,
|
||||
v8::Handle<v8::Value>(), signature),
|
||||
v8::Local<v8::Value>(), signature),
|
||||
static_cast<v8::PropertyAttribute>(v8::DontDelete));
|
||||
|
||||
initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction());
|
||||
initialize_logger.env()
|
||||
->Global()
|
||||
->Set(initialize_logger.env(), v8_str("Obj"),
|
||||
obj->GetFunction(initialize_logger.env()).ToLocalChecked())
|
||||
.FromJust();
|
||||
CompileRun("Obj.prototype.method1.toString();");
|
||||
|
||||
logger->LogCompiledFunctions();
|
||||
@ -401,7 +411,7 @@ TEST(LogAccessorCallbacks) {
|
||||
v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New(
|
||||
isolate, v8::FunctionTemplate::New(isolate));
|
||||
obj->SetClassName(v8_str("Obj"));
|
||||
v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
|
||||
v8::Local<v8::ObjectTemplate> inst = obj->InstanceTemplate();
|
||||
inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
|
||||
inst->SetAccessor(v8_str("prop2"), Prop2Getter);
|
||||
|
||||
@ -475,29 +485,37 @@ TEST(EquivalenceOfLoggingAndTraversal) {
|
||||
i::Vector<const char> log(
|
||||
i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
|
||||
CHECK(exists);
|
||||
v8::Handle<v8::String> log_str = v8::String::NewFromUtf8(
|
||||
isolate, log.start(), v8::String::kNormalString, log.length());
|
||||
initialize_logger.env()->Global()->Set(v8_str("_log"), log_str);
|
||||
v8::Local<v8::String> log_str =
|
||||
v8::String::NewFromUtf8(isolate, log.start(),
|
||||
v8::NewStringType::kNormal, log.length())
|
||||
.ToLocalChecked();
|
||||
initialize_logger.env()
|
||||
->Global()
|
||||
->Set(initialize_logger.env(), v8_str("_log"), log_str)
|
||||
.FromJust();
|
||||
|
||||
i::Vector<const char> source = TestSources::GetScriptsSource();
|
||||
v8::Handle<v8::String> source_str = v8::String::NewFromUtf8(
|
||||
isolate, source.start(), v8::String::kNormalString, source.length());
|
||||
v8::Local<v8::String> source_str =
|
||||
v8::String::NewFromUtf8(isolate, source.start(),
|
||||
v8::NewStringType::kNormal, source.length())
|
||||
.ToLocalChecked();
|
||||
v8::TryCatch try_catch(isolate);
|
||||
v8::Handle<v8::Script> script = CompileWithOrigin(source_str, "");
|
||||
v8::Local<v8::Script> script = CompileWithOrigin(source_str, "");
|
||||
if (script.IsEmpty()) {
|
||||
v8::String::Utf8Value exception(try_catch.Exception());
|
||||
printf("compile: %s\n", *exception);
|
||||
CHECK(false);
|
||||
}
|
||||
v8::Handle<v8::Value> result = script->Run();
|
||||
if (result.IsEmpty()) {
|
||||
v8::Local<v8::Value> result;
|
||||
if (!script->Run(initialize_logger.env()).ToLocal(&result)) {
|
||||
v8::String::Utf8Value exception(try_catch.Exception());
|
||||
printf("run: %s\n", *exception);
|
||||
CHECK(false);
|
||||
}
|
||||
// The result either be a "true" literal or problem description.
|
||||
if (!result->IsTrue()) {
|
||||
v8::Local<v8::String> s = result->ToString(isolate);
|
||||
v8::Local<v8::String> s =
|
||||
result->ToString(initialize_logger.env()).ToLocalChecked();
|
||||
i::ScopedVector<char> data(s->Utf8Length() + 1);
|
||||
CHECK(data.start());
|
||||
s->WriteUtf8(data.start());
|
||||
|
Loading…
Reference in New Issue
Block a user