diff --git a/boa_engine/src/builtins/array_buffer/mod.rs b/boa_engine/src/builtins/array_buffer/mod.rs index d05e7b8240..3f0524017d 100644 --- a/boa_engine/src/builtins/array_buffer/mod.rs +++ b/boa_engine/src/builtins/array_buffer/mod.rs @@ -37,11 +37,17 @@ impl BuiltIn for ArrayBuffer { fn init(context: &mut Context) -> Option { let _timer = Profiler::global().start_event(Self::NAME, "init"); + let flag_attributes = Attribute::CONFIGURABLE | Attribute::NON_ENUMERABLE; + let get_species = FunctionBuilder::native(context, Self::get_species) .name("get [Symbol.species]") .constructor(false) .build(); + let get_byte_length = FunctionBuilder::native(context, Self::get_byte_length) + .name("get byteLength") + .build(); + ConstructorBuilder::with_standard_constructor( context, Self::constructor, @@ -49,6 +55,7 @@ impl BuiltIn for ArrayBuffer { ) .name(Self::NAME) .length(Self::LENGTH) + .accessor("byteLength", Some(get_byte_length), None, flag_attributes) .static_accessor( WellKnownSymbols::species(), Some(get_species), @@ -56,7 +63,6 @@ impl BuiltIn for ArrayBuffer { Attribute::CONFIGURABLE, ) .static_method(Self::is_view, "isView", 1) - .method(Self::byte_length, "byteLength", 0) .method(Self::slice, "slice", 2) .property( WellKnownSymbols::to_string_tag(), @@ -133,7 +139,11 @@ impl ArrayBuffer { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.bytelength - fn byte_length(this: &JsValue, _args: &[JsValue], context: &mut Context) -> JsResult { + fn get_byte_length( + this: &JsValue, + _args: &[JsValue], + context: &mut Context, + ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). let obj = if let Some(obj) = this.as_object() {