Commit cc0832ef authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Fix uses of deprecated v8 GetPropertyNames

Replace deprecated GetPropertyNames() with
GetPropertyNames(context).ToLocalChecked(). The previous version
obtained the Context implicitly which could be wrong if the Context
was not properly restored. Additionally the previous version does not
force checking of the exception status which the new version does via
the V8_WARN_UNUSED_RESULT macro.

Bug: v8:7286, v8:8562
Change-Id: If144eb10b4ba0f045ac13af02d1054ffa7e492c1
Reviewed-on: https://chromium-review.googlesource.com/c/1388107
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618817}
parent 159dbdc8
...@@ -276,7 +276,7 @@ TEST_F(V8ValueConverterImplTest, BasicRoundTrip) { ...@@ -276,7 +276,7 @@ TEST_F(V8ValueConverterImplTest, BasicRoundTrip) {
ASSERT_FALSE(v8_object.IsEmpty()); ASSERT_FALSE(v8_object.IsEmpty());
EXPECT_EQ(static_cast<const base::DictionaryValue&>(*original_root).size(), EXPECT_EQ(static_cast<const base::DictionaryValue&>(*original_root).size(),
v8_object->GetPropertyNames()->Length()); v8_object->GetPropertyNames(context).ToLocalChecked()->Length());
EXPECT_TRUE(v8_object EXPECT_TRUE(v8_object
->Get(v8::String::NewFromUtf8( ->Get(v8::String::NewFromUtf8(
isolate_, "null", v8::NewStringType::kInternalized) isolate_, "null", v8::NewStringType::kInternalized)
...@@ -418,7 +418,7 @@ TEST_F(V8ValueConverterImplTest, ObjectExceptions) { ...@@ -418,7 +418,7 @@ TEST_F(V8ValueConverterImplTest, ObjectExceptions) {
v8::Local<v8::Object> copy = v8::Local<v8::Object> copy =
converter.ToV8Value(converted.get(), context).As<v8::Object>(); converter.ToV8Value(converted.get(), context).As<v8::Object>();
EXPECT_FALSE(copy.IsEmpty()); EXPECT_FALSE(copy.IsEmpty());
EXPECT_EQ(2u, copy->GetPropertyNames()->Length()); EXPECT_EQ(2u, copy->GetPropertyNames(context).ToLocalChecked()->Length());
EXPECT_EQ("foo", GetString(copy, "foo")); EXPECT_EQ("foo", GetString(copy, "foo"));
EXPECT_EQ("bar", GetString(copy, "bar")); EXPECT_EQ("bar", GetString(copy, "bar"));
} }
...@@ -560,7 +560,8 @@ TEST_F(V8ValueConverterImplTest, ObjectPrototypeSetter) { ...@@ -560,7 +560,8 @@ TEST_F(V8ValueConverterImplTest, ObjectPrototypeSetter) {
EXPECT_EQ(1, GetInt(result, "getters")); EXPECT_EQ(1, GetInt(result, "getters"));
EXPECT_EQ(1, GetInt(result, "setters")); EXPECT_EQ(1, GetInt(result, "setters"));
EXPECT_EQ(1u, converted->GetPropertyNames()->Length()); EXPECT_EQ(1u,
converted->GetPropertyNames(context).ToLocalChecked()->Length());
EXPECT_EQ("good value", GetString(converted, "foo")); EXPECT_EQ("good value", GetString(converted, "foo"));
// Getters/setters shouldn't be triggered while accessing existing values. // Getters/setters shouldn't be triggered while accessing existing values.
...@@ -578,7 +579,8 @@ TEST_F(V8ValueConverterImplTest, ObjectPrototypeSetter) { ...@@ -578,7 +579,8 @@ TEST_F(V8ValueConverterImplTest, ObjectPrototypeSetter) {
EXPECT_EQ(1, GetInt(result, "getters")); EXPECT_EQ(1, GetInt(result, "getters"));
EXPECT_EQ(1, GetInt(result, "setters")); EXPECT_EQ(1, GetInt(result, "setters"));
EXPECT_EQ(1u, converted2->GetPropertyNames()->Length()); EXPECT_EQ(1u,
converted2->GetPropertyNames(context).ToLocalChecked()->Length());
EXPECT_EQ("hello", GetString(converted2, "otherkey")); EXPECT_EQ("hello", GetString(converted2, "otherkey"));
// Missing key = should trigger getter upon access. // Missing key = should trigger getter upon access.
......
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