Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9858,6 +9858,15 @@ int JS_PreventExtensions(JSContext *ctx, JSValueConst obj)
p = JS_VALUE_GET_OBJ(obj);
if (unlikely(p->class_id == JS_CLASS_PROXY))
return js_proxy_preventExtensions(ctx, obj);
if (is_typed_array(p->class_id)) {
JSTypedArray *ta = p->u.typed_array;
JSArrayBuffer *abuf = ta->buffer->u.array_buffer;
if (ta->track_rab ||
(array_buffer_is_resizable(abuf) && !abuf->shared))
{
return false;
}
}
p->extensible = false;
return true;
}
Expand Down Expand Up @@ -41752,7 +41761,7 @@ static JSValue js_object_preventExtensions(JSContext *ctx, JSValueConst this_val
return js_bool(ret);
} else {
if (!ret)
return JS_ThrowTypeError(ctx, "proxy preventExtensions handler returned false");
return JS_ThrowTypeError(ctx, "Cannot prevent extensions");
return js_dup(obj);
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/bug1691.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { assertThrows } from "./assert.js";

assertThrows(TypeError, function () {Object.preventExtensions(new Int8Array(new ArrayBuffer(16, { maxByteLength: 16 })));});
Loading