| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 | 86 |
| 87 TEST(WeakArrayBuffersFromApi) { | 87 TEST(WeakArrayBuffersFromApi) { |
| 88 v8::V8::Initialize(); | 88 v8::V8::Initialize(); |
| 89 LocalContext context; | 89 LocalContext context; |
| 90 Isolate* isolate = GetIsolateFrom(&context); | 90 Isolate* isolate = GetIsolateFrom(&context); |
| 91 | 91 |
| 92 int start = CountArrayBuffersInWeakList(isolate->heap()); | 92 int start = CountArrayBuffersInWeakList(isolate->heap()); |
| 93 { | 93 { |
| 94 v8::HandleScope s1(context->GetIsolate()); | 94 v8::HandleScope s1(context->GetIsolate()); |
| 95 v8::Handle<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::New(256); | 95 v8::Handle<v8::ArrayBuffer> ab1 = |
| 96 v8::ArrayBuffer::New(context->GetIsolate(), 256); |
| 96 { | 97 { |
| 97 v8::HandleScope s2(context->GetIsolate()); | 98 v8::HandleScope s2(context->GetIsolate()); |
| 98 v8::Handle<v8::ArrayBuffer> ab2 = v8::ArrayBuffer::New(128); | 99 v8::Handle<v8::ArrayBuffer> ab2 = |
| 100 v8::ArrayBuffer::New(context->GetIsolate(), 128); |
| 99 | 101 |
| 100 Handle<JSArrayBuffer> iab1 = v8::Utils::OpenHandle(*ab1); | 102 Handle<JSArrayBuffer> iab1 = v8::Utils::OpenHandle(*ab1); |
| 101 Handle<JSArrayBuffer> iab2 = v8::Utils::OpenHandle(*ab2); | 103 Handle<JSArrayBuffer> iab2 = v8::Utils::OpenHandle(*ab2); |
| 102 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()) - start); | 104 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()) - start); |
| 103 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab1)); | 105 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab1)); |
| 104 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab2)); | 106 CHECK(HasArrayBufferInWeakList(isolate->heap(), *iab2)); |
| 105 } | 107 } |
| 106 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 108 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
| 107 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); | 109 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); |
| 108 { | 110 { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 181 } |
| 180 } | 182 } |
| 181 | 183 |
| 182 template <typename View> | 184 template <typename View> |
| 183 void TestViewFromApi() { | 185 void TestViewFromApi() { |
| 184 v8::V8::Initialize(); | 186 v8::V8::Initialize(); |
| 185 LocalContext context; | 187 LocalContext context; |
| 186 Isolate* isolate = GetIsolateFrom(&context); | 188 Isolate* isolate = GetIsolateFrom(&context); |
| 187 | 189 |
| 188 v8::HandleScope s1(context->GetIsolate()); | 190 v8::HandleScope s1(context->GetIsolate()); |
| 189 v8::Handle<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(2048); | 191 v8::Handle<v8::ArrayBuffer> ab = |
| 192 v8::ArrayBuffer::New(context->GetIsolate(), 2048); |
| 190 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); | 193 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); |
| 191 { | 194 { |
| 192 v8::HandleScope s2(context->GetIsolate()); | 195 v8::HandleScope s2(context->GetIsolate()); |
| 193 v8::Handle<View> ta1 = View::New(ab, 0, 256); | 196 v8::Handle<View> ta1 = View::New(ab, 0, 256); |
| 194 { | 197 { |
| 195 v8::HandleScope s3(context->GetIsolate()); | 198 v8::HandleScope s3(context->GetIsolate()); |
| 196 v8::Handle<View> ta2 = View::New(ab, 0, 128); | 199 v8::Handle<View> ta2 = View::New(ab, 0, 128); |
| 197 | 200 |
| 198 Handle<JSArrayBufferView> ita1 = v8::Utils::OpenHandle(*ta1); | 201 Handle<JSArrayBufferView> ita1 = v8::Utils::OpenHandle(*ta1); |
| 199 Handle<JSArrayBufferView> ita2 = v8::Utils::OpenHandle(*ta2); | 202 Handle<JSArrayBufferView> ita2 = v8::Utils::OpenHandle(*ta2); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 383 |
| 381 | 384 |
| 382 TEST(Uint8ClampedArrayFromScript) { | 385 TEST(Uint8ClampedArrayFromScript) { |
| 383 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); | 386 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); |
| 384 } | 387 } |
| 385 | 388 |
| 386 | 389 |
| 387 TEST(DataViewFromScript) { | 390 TEST(DataViewFromScript) { |
| 388 TestTypedArrayFromScript<v8::DataView>("DataView"); | 391 TestTypedArrayFromScript<v8::DataView>("DataView"); |
| 389 } | 392 } |
| OLD | NEW |