summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorJamie Mansfield <jmansfield@cadixdev.org>2022-02-13 02:33:57 +0000
committerLinus Groh <mail@linusgroh.de>2022-02-13 21:26:15 +0000
commit04c5bc5e553fe3dc7f38dec0522651968fe9b596 (patch)
tree9750c45044bb85337a98b0786d672c97c4fd1f61 /Userland
parent7aa4c22f6b0dde61457c4e4112428b777401213b (diff)
downloadserenity-04c5bc5e553fe3dc7f38dec0522651968fe9b596.zip
LibJS: Add spec comments to ArrayBuffer.prototype.byteLength
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
index 1b52da708a..768272f4d8 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
@@ -127,12 +127,22 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice)
// 25.1.5.1 get ArrayBuffer.prototype.byteLength, https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.bytelength
JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::byte_length_getter)
{
+ // 1. Let O be the this value.
+ // 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
auto* array_buffer_object = TRY(typed_this_value(global_object));
+
+ // 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
// FIXME: Check for shared buffer
+
+ // 4. If IsDetachedBuffer(O) is true, return +0𝔽.
if (array_buffer_object->is_detached())
return Value(0);
- return Value(array_buffer_object->byte_length());
+ // 5. Let length be O.[[ArrayBufferByteLength]].
+ auto length = array_buffer_object->byte_length();
+
+ // 6. Return 𝔽(length).
+ return Value(length);
}
}