mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LibJS: Disallow changing the prototype of non-extensible objects
Object::set_prototype() now returns a boolean indicating success. Setting the prototype to an identical object is always considered successful, even if the object is non-extensible.
This commit is contained in:
parent
8cf1ded478
commit
b958e4f573
4 changed files with 22 additions and 6 deletions
|
@ -11,7 +11,17 @@ try {
|
|||
});
|
||||
|
||||
o = {};
|
||||
assert(Object.setPrototypeOf(o, {}) === o);
|
||||
p = {};
|
||||
assert(Object.setPrototypeOf(o, p) === o);
|
||||
|
||||
Object.preventExtensions(o);
|
||||
assertThrowsError(() => {
|
||||
Object.setPrototypeOf(o, {});
|
||||
}, {
|
||||
error: TypeError,
|
||||
message: "Can't set prototype of non-extensible object"
|
||||
});
|
||||
assert(Object.setPrototypeOf(o, p) === o);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue