Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(mythria): Remove this define after this flag is turned on globally | |
| 6 #define V8_IMMINENT_DEPRECATION_WARNINGS | |
| 7 | |
| 5 #include <stdlib.h> | 8 #include <stdlib.h> |
| 6 | 9 |
| 7 #include "src/v8.h" | 10 #include "src/v8.h" |
| 8 #include "test/cctest/cctest.h" | 11 #include "test/cctest/cctest.h" |
| 9 | 12 |
| 10 #include "src/api.h" | 13 #include "src/api.h" |
| 11 #include "src/heap/heap.h" | 14 #include "src/heap/heap.h" |
| 12 #include "src/objects.h" | 15 #include "src/objects.h" |
| 13 | 16 |
| 14 using namespace v8::internal; | 17 using namespace v8::internal; |
| 15 | 18 |
| 16 void TestArrayBufferViewContents(LocalContext& env, bool should_use_buffer) { | 19 void TestArrayBufferViewContents(LocalContext& env, bool should_use_buffer) { |
| 17 v8::Local<v8::Object> obj_a = | 20 v8::Local<v8::Context> context = |
| 18 v8::Local<v8::Object>::Cast(env->Global()->Get(v8_str("a"))); | 21 reinterpret_cast<v8::Isolate*>( |
| 22 v8::Utils::OpenHandle(*env->Global())->GetIsolate()) | |
| 23 ->GetCurrentContext(); | |
|
rmcilroy
2015/09/15 10:29:47
Can you not just do: v8::Isolate::GetCurrent()->Ge
mythria
2015/09/17 11:21:48
Done.
| |
| 24 v8::Local<v8::Object> obj_a = v8::Local<v8::Object>::Cast( | |
| 25 env->Global()->Get(context, v8_str("a")).ToLocalChecked()); | |
| 19 CHECK(obj_a->IsArrayBufferView()); | 26 CHECK(obj_a->IsArrayBufferView()); |
| 20 v8::Local<v8::ArrayBufferView> array_buffer_view = | 27 v8::Local<v8::ArrayBufferView> array_buffer_view = |
| 21 v8::Local<v8::ArrayBufferView>::Cast(obj_a); | 28 v8::Local<v8::ArrayBufferView>::Cast(obj_a); |
| 22 CHECK_EQ(array_buffer_view->HasBuffer(), should_use_buffer); | 29 CHECK_EQ(array_buffer_view->HasBuffer(), should_use_buffer); |
| 23 unsigned char contents[4] = {23, 23, 23, 23}; | 30 unsigned char contents[4] = {23, 23, 23, 23}; |
| 24 CHECK_EQ(sizeof(contents), | 31 CHECK_EQ(sizeof(contents), |
| 25 array_buffer_view->CopyContents(contents, sizeof(contents))); | 32 array_buffer_view->CopyContents(contents, sizeof(contents))); |
| 26 CHECK_EQ(array_buffer_view->HasBuffer(), should_use_buffer); | 33 CHECK_EQ(array_buffer_view->HasBuffer(), should_use_buffer); |
| 27 for (size_t i = 0; i < sizeof(contents); ++i) { | 34 for (size_t i = 0; i < sizeof(contents); ++i) { |
| 28 CHECK_EQ(i, contents[i]); | 35 CHECK_EQ(i, contents[i]); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 v8::HandleScope scope(env->GetIsolate()); | 80 v8::HandleScope scope(env->GetIsolate()); |
| 74 void* memory = reinterpret_cast<Isolate*>(env->GetIsolate()) | 81 void* memory = reinterpret_cast<Isolate*>(env->GetIsolate()) |
| 75 ->array_buffer_allocator() | 82 ->array_buffer_allocator() |
| 76 ->Allocate(1024); | 83 ->Allocate(1024); |
| 77 v8::Local<v8::ArrayBuffer> buffer = | 84 v8::Local<v8::ArrayBuffer> buffer = |
| 78 v8::ArrayBuffer::New(env->GetIsolate(), memory, 1024, | 85 v8::ArrayBuffer::New(env->GetIsolate(), memory, 1024, |
| 79 v8::ArrayBufferCreationMode::kInternalized); | 86 v8::ArrayBufferCreationMode::kInternalized); |
| 80 CHECK(!buffer->IsExternal()); | 87 CHECK(!buffer->IsExternal()); |
| 81 CHECK_EQ(memory, buffer->GetContents().Data()); | 88 CHECK_EQ(memory, buffer->GetContents().Data()); |
| 82 } | 89 } |
| OLD | NEW |