| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6fbb0b7 commit 780e65c
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | 39 | # Reset this number to 0 on major V8 upgrades. | |
| 40 | 40 | # Increment by one for each non-official patch applied to deps/v8. | |
| 41 | - 'v8_embedder_string': '-node.18', | ||
| 41 | + 'v8_embedder_string': '-node.19', | ||
| 42 | 42 | ||
| 43 | 43 | ##### V8 defaults for Node.js ##### | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -637,7 +637,8 @@ Tagged<Object> ArrayBufferTransfer(Isolate* isolate, | |||
| 637 | 637 | // 8. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a | |
| 638 | 638 | // TypeError exception. | |
| 639 | 639 | ||
| 640 | - if (!array_buffer->is_detachable()) { | ||
| 640 | + if (!IsUndefined(array_buffer->detach_key()) || | ||
| 641 | + !array_buffer->is_detachable()) { | ||
| 641 | 642 | THROW_NEW_ERROR_RETURN_FAILURE( | |
| 642 | 643 | isolate, | |
| 643 | 644 | NewTypeError(MessageTemplate::kDataCloneErrorNonDetachableArrayBuffer)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + // Copyright 2026 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + // | ||
| 5 | + // Flags: --allow-natives-syntax | ||
| 6 | + | ||
| 7 | + function TestTransferSucceeds() { | ||
| 8 | + const ab = new ArrayBuffer(100); | ||
| 9 | + %ArrayBufferSetDetachKey(ab, undefined); | ||
| 10 | + ab.transfer(); | ||
| 11 | + assertEquals(0, ab.byteLength); // Detached. | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + function TestTransferFails() { | ||
| 15 | + const ab = new ArrayBuffer(100); | ||
| 16 | + %ArrayBufferSetDetachKey(ab, Symbol()); | ||
| 17 | + assertThrows(() => { ab.transfer(); }, TypeError); | ||
| 18 | + assertEquals(100, ab.byteLength); // Not detached. | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + TestTransferSucceeds(); | ||
| 22 | + TestTransferFails(); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -263,6 +263,7 @@ v8_source_set("v8_unittests_sources") { | |||
| 263 | 263 | "api/remote-object-unittest.cc", | |
| 264 | 264 | "api/resource-constraints-unittest.cc", | |
| 265 | 265 | "api/smi-tagging-unittest.cc", | |
| 266 | + "api/v8-array-buffer-unittest.cc", | ||
| 266 | 267 | "api/v8-array-unittest.cc", | |
| 267 | 268 | "api/v8-maybe-unittest.cc", | |
| 268 | 269 | "api/v8-memory-span-unittest.cc", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,40 @@ | |||
| 1 | + // Copyright 2026 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + | ||
| 5 | + #include "include/v8-array-buffer.h" | ||
| 6 | + | ||
| 7 | + #include "test/unittests/test-utils.h" | ||
| 8 | + #include "testing/gtest/include/gtest/gtest.h" | ||
| 9 | + | ||
| 10 | + namespace v8 { | ||
| 11 | + namespace { | ||
| 12 | + | ||
| 13 | + using ArrayBufferTest = TestWithContext; | ||
| 14 | + | ||
| 15 | + TEST_F(ArrayBufferTest, TransferWithDetachKey) { | ||
| 16 | + Local<ArrayBuffer> ab = ArrayBuffer::New(isolate(), 1); | ||
| 17 | + Local<Value> key = Symbol::New(isolate()); | ||
| 18 | + ab->SetDetachKey(key); | ||
| 19 | + Local<Object> global = context()->Global(); | ||
| 20 | + Local<String> property_name = | ||
| 21 | + String::NewFromUtf8Literal(isolate(), "test_ab"); | ||
| 22 | + global->Set(context(), property_name, ab).ToChecked(); | ||
| 23 | + | ||
| 24 | + { | ||
| 25 | + TryCatch try_catch(isolate()); | ||
| 26 | + CHECK(TryRunJS("globalThis.test_ab.transfer()").IsEmpty()); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + // Didnot transfer. | ||
| 30 | + EXPECT_EQ(ab->ByteLength(), 1u); | ||
| 31 | + | ||
| 32 | + ab->SetDetachKey(Undefined(isolate())); | ||
| 33 | + RunJS("globalThis.test_ab.transfer()"); | ||
| 34 | + | ||
| 35 | + // Transferred. | ||
| 36 | + EXPECT_EQ(ab->ByteLength(), 0u); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + } // namespace | ||
| 40 | + } // namespace v8 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments