mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibJS: Consider non-extensible objects in Reflect.setPrototypeOf()
This commit is contained in:
parent
c1248a7fd8
commit
b32761f2e0
Notes:
sideshowbarker
2024-07-19 05:53:38 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/b32761f2e0e Pull-request: https://github.com/SerenityOS/serenity/pull/2478
2 changed files with 6 additions and 4 deletions
|
@ -261,9 +261,7 @@ Value ReflectObject::set_prototype_of(Interpreter& interpreter)
|
|||
Object* prototype = nullptr;
|
||||
if (!prototype_value.is_null())
|
||||
prototype = const_cast<Object*>(&prototype_value.as_object());
|
||||
target->set_prototype(prototype);
|
||||
// FIXME: Needs to return false for prototype chain cycles and non-extensible objects (don't have those yet).
|
||||
return Value(true);
|
||||
return Value(target->set_prototype(prototype));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,10 +28,14 @@ try {
|
|||
assert(Reflect.setPrototypeOf({}, Reflect.getPrototypeOf({})) === true);
|
||||
|
||||
var o = {};
|
||||
var p = { foo: "bar" };
|
||||
assert(o.foo === undefined);
|
||||
assert(Reflect.setPrototypeOf(o, { foo: "bar" }) === true);
|
||||
assert(Reflect.setPrototypeOf(o, p) === true);
|
||||
assert(o.foo === "bar");
|
||||
|
||||
Reflect.preventExtensions(o);
|
||||
assert(Reflect.setPrototypeOf(o, {}) === false);
|
||||
assert(Reflect.setPrototypeOf(o, p) === true);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue