Chromium Code Reviews| Index: test/cctest/test-decls.cc |
| diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc |
| index 347ca9a6bc89229302686e6ad923996c69057f06..64101f3f7a3a143d6560f14e1aa87d0f4191347c 100644 |
| --- a/test/cctest/test-decls.cc |
| +++ b/test/cctest/test-decls.cc |
| @@ -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 <stdlib.h> |
| #include "src/v8.h" |
| @@ -60,25 +63,24 @@ class DeclarationContext { |
| } |
| } |
| - void Check(const char* source, |
| - int get, int set, int has, |
| + void Check(const char* source, int get, int set, int has, |
| Expectations expectations, |
| - v8::Handle<Value> value = Local<Value>()); |
| + v8::Local<Value> value = Local<Value>()); |
| int get_count() const { return get_count_; } |
| int set_count() const { return set_count_; } |
| int query_count() const { return query_count_; } |
| protected: |
| - virtual v8::Handle<Value> Get(Local<Name> key); |
| - virtual v8::Handle<Value> Set(Local<Name> key, Local<Value> value); |
| - virtual v8::Handle<Integer> Query(Local<Name> key); |
| + virtual v8::Local<Value> Get(Local<Name> key); |
| + virtual v8::Local<Value> Set(Local<Name> key, Local<Value> value); |
| + virtual v8::Local<Integer> Query(Local<Name> key); |
| void InitializeIfNeeded(); |
| // Perform optional initialization steps on the context after it has |
| // been created. Defaults to none but may be overwritten. |
| - virtual void PostInitializeContext(Handle<Context> context) {} |
| + virtual void PostInitializeContext(Local<Context> context) {} |
| // Get the holder for the interceptor. Default to the instance template |
| // but may be overwritten. |
| @@ -138,10 +140,9 @@ void DeclarationContext::InitializeIfNeeded() { |
| } |
| -void DeclarationContext::Check(const char* source, |
| - int get, int set, int query, |
| +void DeclarationContext::Check(const char* source, int get, int set, int query, |
| Expectations expectations, |
| - v8::Handle<Value> value) { |
| + v8::Local<Value> value) { |
| InitializeIfNeeded(); |
| // A retry after a GC may pollute the counts, so perform gc now |
| // to avoid that. |
| @@ -149,27 +150,30 @@ void DeclarationContext::Check(const char* source, |
| HandleScope scope(CcTest::isolate()); |
| TryCatch catcher(CcTest::isolate()); |
| catcher.SetVerbose(true); |
| - Local<Script> script = |
| - Script::Compile(String::NewFromUtf8(CcTest::isolate(), source)); |
| - if (expectations == EXPECT_ERROR) { |
| - CHECK(script.IsEmpty()); |
| + Local<Context> context = CcTest::isolate()->GetCurrentContext(); |
| + Local<Script> script; |
| + if (!Script::Compile(context, String::NewFromUtf8(CcTest::isolate(), source, |
|
vogelheim
2015/12/07 13:51:19
(Total nitpick; and a purely a matter of style. Fe
|
| + v8::NewStringType::kNormal) |
| + .ToLocalChecked()) |
| + .ToLocal(&script)) { |
| + CHECK_EQ(EXPECT_ERROR, expectations); |
| return; |
| } |
| - CHECK(!script.IsEmpty()); |
| - Local<Value> result = script->Run(); |
| + CHECK_NE(EXPECT_ERROR, expectations); |
| + MaybeLocal<Value> result = script->Run(context); |
| CHECK_EQ(get, get_count()); |
| CHECK_EQ(set, set_count()); |
| CHECK_EQ(query, query_count()); |
| if (expectations == EXPECT_RESULT) { |
| CHECK(!catcher.HasCaught()); |
| if (!value.IsEmpty()) { |
| - CHECK(value->Equals(result)); |
| + CHECK(value->Equals(context, result.ToLocalChecked()).FromJust()); |
| } |
| } else { |
| CHECK(expectations == EXPECT_EXCEPTION); |
| CHECK(catcher.HasCaught()); |
| if (!value.IsEmpty()) { |
| - CHECK(value->Equals(catcher.Exception())); |
| + CHECK(value->Equals(context, catcher.Exception()).FromJust()); |
| } |
| } |
| // Clean slate for the next test. |
| @@ -208,18 +212,18 @@ DeclarationContext* DeclarationContext::GetInstance(Local<Value> data) { |
| } |
| -v8::Handle<Value> DeclarationContext::Get(Local<Name> key) { |
| - return v8::Handle<Value>(); |
| +v8::Local<Value> DeclarationContext::Get(Local<Name> key) { |
| + return v8::Local<Value>(); |
| } |
| -v8::Handle<Value> DeclarationContext::Set(Local<Name> key, Local<Value> value) { |
| - return v8::Handle<Value>(); |
| +v8::Local<Value> DeclarationContext::Set(Local<Name> key, Local<Value> value) { |
| + return v8::Local<Value>(); |
| } |
| -v8::Handle<Integer> DeclarationContext::Query(Local<Name> key) { |
| - return v8::Handle<Integer>(); |
| +v8::Local<Integer> DeclarationContext::Query(Local<Name> key) { |
| + return v8::Local<Integer>(); |
| } |
| @@ -268,8 +272,8 @@ TEST(Unknown) { |
| class AbsentPropertyContext: public DeclarationContext { |
| protected: |
| - virtual v8::Handle<Integer> Query(Local<Name> key) { |
| - return v8::Handle<Integer>(); |
| + virtual v8::Local<Integer> Query(Local<Name> key) { |
| + return v8::Local<Integer>(); |
| } |
| }; |
| @@ -332,13 +336,13 @@ class AppearingPropertyContext: public DeclarationContext { |
| AppearingPropertyContext() : state_(DECLARE) { } |
| protected: |
| - virtual v8::Handle<Integer> Query(Local<Name> key) { |
| + virtual v8::Local<Integer> Query(Local<Name> key) { |
| switch (state_) { |
| case DECLARE: |
| // Force declaration by returning that the |
| // property is absent. |
| state_ = INITIALIZE_IF_ASSIGN; |
| - return Handle<Integer>(); |
| + return Local<Integer>(); |
| case INITIALIZE_IF_ASSIGN: |
| // Return that the property is present so we only get the |
| // setter called when initializing with a value. |
| @@ -349,7 +353,7 @@ class AppearingPropertyContext: public DeclarationContext { |
| break; |
| } |
| // Do the lookup in the object. |
| - return v8::Handle<Integer>(); |
| + return v8::Local<Integer>(); |
| } |
| private: |
| @@ -401,7 +405,7 @@ class ExistsInPrototypeContext: public DeclarationContext { |
| public: |
| ExistsInPrototypeContext() { InitializeIfNeeded(); } |
| protected: |
| - virtual v8::Handle<Integer> Query(Local<Name> key) { |
| + virtual v8::Local<Integer> Query(Local<Name> key) { |
| // Let it seem that the property exists in the prototype object. |
| return Integer::New(isolate(), v8::None); |
| } |
| @@ -460,9 +464,9 @@ TEST(ExistsInPrototype) { |
| class AbsentInPrototypeContext: public DeclarationContext { |
| protected: |
| - virtual v8::Handle<Integer> Query(Local<Name> key) { |
| + virtual v8::Local<Integer> Query(Local<Name> key) { |
| // Let it seem that the property is absent in the prototype object. |
| - return Handle<Integer>(); |
| + return Local<Integer>(); |
| } |
| // Use the prototype as the holder for the interceptors. |
| @@ -495,18 +499,21 @@ class ExistsInHiddenPrototypeContext: public DeclarationContext { |
| } |
| protected: |
| - virtual v8::Handle<Integer> Query(Local<Name> key) { |
| + virtual v8::Local<Integer> Query(Local<Name> key) { |
| // Let it seem that the property exists in the hidden prototype object. |
| return Integer::New(isolate(), v8::None); |
| } |
| // Install the hidden prototype after the global object has been created. |
| - virtual void PostInitializeContext(Handle<Context> context) { |
| + virtual void PostInitializeContext(Local<Context> context) { |
| Local<Object> global_object = context->Global(); |
| - Local<Object> hidden_proto = hidden_proto_->GetFunction()->NewInstance(); |
| + Local<Object> hidden_proto = hidden_proto_->GetFunction(context) |
| + .ToLocalChecked() |
| + ->NewInstance(context) |
| + .ToLocalChecked(); |
| Local<Object> inner_global = |
| Local<Object>::Cast(global_object->GetPrototype()); |
| - inner_global->SetPrototype(hidden_proto); |
| + inner_global->SetPrototype(context, hidden_proto).FromJust(); |
| } |
| // Use the hidden prototype as the holder for the interceptors. |
| @@ -567,30 +574,32 @@ class SimpleContext { |
| context_->Exit(); |
| } |
| - void Check(const char* source, |
| - Expectations expectations, |
| - v8::Handle<Value> value = Local<Value>()) { |
| + void Check(const char* source, Expectations expectations, |
| + v8::Local<Value> value = Local<Value>()) { |
| HandleScope scope(context_->GetIsolate()); |
| TryCatch catcher(context_->GetIsolate()); |
| catcher.SetVerbose(true); |
| - Local<Script> script = |
| - Script::Compile(String::NewFromUtf8(context_->GetIsolate(), source)); |
| - if (expectations == EXPECT_ERROR) { |
| - CHECK(script.IsEmpty()); |
| + Local<Script> script; |
|
vogelheim
2015/12/07 13:51:19
(Same nitpick as above. Also feel free to ignore.
|
| + if (!Script::Compile(context_, |
| + String::NewFromUtf8(context_->GetIsolate(), source, |
| + v8::NewStringType::kNormal) |
| + .ToLocalChecked()) |
| + .ToLocal(&script)) { |
| + CHECK_EQ(EXPECT_ERROR, expectations); |
| return; |
| } |
| - CHECK(!script.IsEmpty()); |
| - Local<Value> result = script->Run(); |
| + CHECK_NE(EXPECT_ERROR, expectations); |
| + MaybeLocal<Value> result = script->Run(context_); |
| if (expectations == EXPECT_RESULT) { |
| CHECK(!catcher.HasCaught()); |
| if (!value.IsEmpty()) { |
| - CHECK(value->Equals(result)); |
| + CHECK(value->Equals(context_, result.ToLocalChecked()).FromJust()); |
| } |
| } else { |
| CHECK(expectations == EXPECT_EXCEPTION); |
| CHECK(catcher.HasCaught()); |
| if (!value.IsEmpty()) { |
| - CHECK(value->Equals(catcher.Exception())); |
| + CHECK(value->Equals(context_, catcher.Exception()).FromJust()); |
| } |
| } |
| } |
| @@ -901,10 +910,14 @@ TEST(CrossScriptDynamicLookup) { |
| { |
| SimpleContext context; |
| - Local<String> undefined_string = String::NewFromUtf8( |
| - CcTest::isolate(), "undefined", String::kInternalizedString); |
| - Local<String> number_string = String::NewFromUtf8( |
| - CcTest::isolate(), "number", String::kInternalizedString); |
| + Local<String> undefined_string = |
| + String::NewFromUtf8(CcTest::isolate(), "undefined", |
| + v8::NewStringType::kInternalized) |
| + .ToLocalChecked(); |
| + Local<String> number_string = |
| + String::NewFromUtf8(CcTest::isolate(), "number", |
| + v8::NewStringType::kInternalized) |
| + .ToLocalChecked(); |
| context.Check( |
| "function f(o) { with(o) { return x; } }" |
| @@ -974,10 +987,14 @@ TEST(CrossScriptStaticLookupUndeclared) { |
| { |
| SimpleContext context; |
| - Local<String> undefined_string = String::NewFromUtf8( |
| - CcTest::isolate(), "undefined", String::kInternalizedString); |
| - Local<String> number_string = String::NewFromUtf8( |
| - CcTest::isolate(), "number", String::kInternalizedString); |
| + Local<String> undefined_string = |
| + String::NewFromUtf8(CcTest::isolate(), "undefined", |
| + v8::NewStringType::kInternalized) |
| + .ToLocalChecked(); |
| + Local<String> number_string = |
| + String::NewFromUtf8(CcTest::isolate(), "number", |
| + v8::NewStringType::kInternalized) |
| + .ToLocalChecked(); |
| context.Check( |
| "function f(o) { return x; }" |