Index: test/unittests/test-utils.cc |
diff --git a/test/unittests/test-utils.cc b/test/unittests/test-utils.cc |
index aa37b2f30d8c0c5af24b6215d15d2f609727c586..fd52a4b21dcf388aeae81df6c682e3e6c2bc93b5 100644 |
--- a/test/unittests/test-utils.cc |
+++ b/test/unittests/test-utils.cc |
@@ -11,6 +11,20 @@ |
namespace v8 { |
+class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
+ public: |
+ virtual void* Allocate(size_t length) { |
+ void* data = AllocateUninitialized(length); |
+ return data == NULL ? data : memset(data, 0, length); |
+ } |
+ virtual void* AllocateUninitialized(size_t length) { return malloc(length); } |
+ virtual void Free(void* data, size_t) { free(data); } |
+}; |
+ |
+ |
+// static |
+ArrayBufferAllocator* TestWithIsolate::array_buffer_allocator_ = NULL; |
+ |
// static |
Isolate* TestWithIsolate::isolate_ = NULL; |
@@ -26,7 +40,10 @@ TestWithIsolate::~TestWithIsolate() {} |
void TestWithIsolate::SetUpTestCase() { |
Test::SetUpTestCase(); |
EXPECT_EQ(NULL, isolate_); |
- isolate_ = v8::Isolate::New(); |
+ v8::Isolate::CreateParams create_params; |
+ array_buffer_allocator_ = new ArrayBufferAllocator; |
+ create_params.array_buffer_allocator = array_buffer_allocator_; |
+ isolate_ = v8::Isolate::New(create_params); |
EXPECT_TRUE(isolate_ != NULL); |
} |
@@ -36,6 +53,7 @@ void TestWithIsolate::TearDownTestCase() { |
ASSERT_TRUE(isolate_ != NULL); |
isolate_->Dispose(); |
isolate_ = NULL; |
+ delete array_buffer_allocator_; |
Test::TearDownTestCase(); |
} |