Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1602)

Unified Diff: content/child/v8_value_converter_impl_unittest.cc

Issue 2685743002: V8ValueConverterImpl: Use V8 to copy from array buffers. (Closed)
Patch Set: correct dcheck, again :( Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/v8_value_converter_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/v8_value_converter_impl_unittest.cc
diff --git a/content/child/v8_value_converter_impl_unittest.cc b/content/child/v8_value_converter_impl_unittest.cc
index a403751b8eed9de269675341d3616f2a57c94be1..84d03fc25bb2d378a9a8685f47d9114a6781f5f6 100644
--- a/content/child/v8_value_converter_impl_unittest.cc
+++ b/content/child/v8_value_converter_impl_unittest.cc
@@ -1108,8 +1108,29 @@ TEST_F(V8ValueConverterImplTest, StrategyBypass) {
EXPECT_TRUE(
base::Value::Equals(reference_array_value.get(), array_value.get()));
- // Not testing ArrayBuffers as V8ValueConverter uses blink helpers and
- // this requires having blink to be initialized.
+ const char kExampleData[] = {1, 2, 3, 4, 5};
+ v8::Local<v8::ArrayBuffer> array_buffer(
+ v8::ArrayBuffer::New(isolate_, sizeof(kExampleData)));
+ memcpy(array_buffer->GetContents().Data(), kExampleData,
+ sizeof(kExampleData));
+ std::unique_ptr<base::Value> binary_value(
+ converter.FromV8Value(array_buffer, context));
+ ASSERT_TRUE(binary_value);
+ std::unique_ptr<base::Value> reference_binary_value(
+ base::BinaryValue::CreateWithCopiedBuffer(kExampleData,
+ sizeof(kExampleData)));
+ EXPECT_TRUE(
+ base::Value::Equals(reference_binary_value.get(), binary_value.get()));
+
+ v8::Local<v8::ArrayBufferView> array_buffer_view(
+ v8::Uint8Array::New(array_buffer, 1, 3));
+ std::unique_ptr<base::Value> binary_view_value(
+ converter.FromV8Value(array_buffer_view, context));
+ ASSERT_TRUE(binary_view_value);
+ std::unique_ptr<base::Value> reference_binary_view_value(
+ base::BinaryValue::CreateWithCopiedBuffer(&kExampleData[1], 3));
+ EXPECT_TRUE(base::Value::Equals(reference_binary_view_value.get(),
+ binary_view_value.get()));
v8::Local<v8::Number> number(v8::Number::New(isolate_, 0.0));
std::unique_ptr<base::Value> number_value(
« no previous file with comments | « content/child/v8_value_converter_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698