Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index 3ffb0b58ad68ccbce25bd82b567f7c53a8e655b5..525eb67c4bf263de21b7b17f4df159c1bba5f0a4 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -7024,8 +7024,18 @@ MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate, |
THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray); |
} |
- // TODO(caitp): throw if array.[[ViewedArrayBuffer]] is neutered (per v8:4648) |
- return Handle<JSTypedArray>::cast(receiver); |
+ Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver); |
+ if (V8_UNLIKELY(array->WasNeutered())) { |
+ const MessageTemplate::Template message = |
+ MessageTemplate::kDetachedOperation; |
+ Handle<String> operation = |
+ isolate->factory()->NewStringFromAsciiChecked(method_name); |
+ THROW_NEW_ERROR(isolate, NewTypeError(message, operation), JSTypedArray); |
+ } |
+ |
+ // spec describes to return `buffer`, but it may disrupt current |
+ // implementations, and it's much useful to return array for now. |
+ return array; |
} |
#ifdef VERIFY_HEAP |