Skip to content

Commit

Permalink
gin: Correct ToV8Traits<T, true>::TryConvertToV8.
Browse files Browse the repository at this point in the history
A context was erroneously passed where an isolate is now expected.

Introduced in:
  https://chromium.googlesource.com/chromium/src/+/eb8a2f1758cf71197e44bdbd79e59105ad845b51

Change-Id: I1b69c4533c7f607e6813c532eae78a2a0c7d50ca
Reviewed-on: https://chromium-review.googlesource.com/964390
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543740}
  • Loading branch information
jeremyroman authored and Commit Bot committed Mar 16, 2018
1 parent 5bd2e47 commit bc83c77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions gin/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,7 @@ struct ToV8Traits<T, true> {
static bool TryConvertToV8(v8::Isolate* isolate,
T input,
v8::Local<v8::Value>* output) {
auto maybe = ConvertToV8(isolate->GetCurrentContext(), input);
if (maybe.IsEmpty())
return false;
*output = maybe.ToLocalChecked();
return true;
return ConvertToV8(isolate, input).ToLocal(output);
}
};

Expand Down
5 changes: 5 additions & 0 deletions gin/converter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,15 @@ TEST_F(ConverterTest, VectorOfWrappables) {
v8::MaybeLocal<v8::Value> maybe = ConvertToV8(isolate, vector);
v8::Local<v8::Value> array;
ASSERT_TRUE(maybe.ToLocal(&array));
v8::Local<v8::Value> array2;
ASSERT_TRUE(TryConvertToV8(isolate, vector, &array2));

std::vector<MyObject*> out_value;
ASSERT_TRUE(ConvertFromV8(isolate, array, &out_value));
EXPECT_THAT(out_value, testing::ContainerEq(vector));
std::vector<MyObject*> out_value2;
ASSERT_TRUE(ConvertFromV8(isolate, array2, &out_value2));
EXPECT_THAT(out_value2, testing::ContainerEq(vector));
}

} // namespace gin

0 comments on commit bc83c77

Please sign in to comment.