LibJS: Don't assume Object.setPrototypeOf() prototype value is an object

We're crashing otherwise. Also it was not possible to set the prototype
to null.
This commit is contained in:
Linus Groh 2020-06-02 12:25:21 +01:00 committed by Andreas Kling
commit 8cf1ded478
Notes: sideshowbarker 2024-07-19 05:53:49 +09:00
2 changed files with 18 additions and 1 deletions

View file

@ -3,6 +3,13 @@ load("test-common.js");
try {
assert(Object.setPrototypeOf.length === 2);
assertThrowsError(() => {
Object.setPrototypeOf({}, "foo");
}, {
error: TypeError,
message: "Prototype must be null or object"
});
o = {};
assert(Object.setPrototypeOf(o, {}) === o);