diff --git a/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 1c56ce254f..c9ed9087f2 100644 --- a/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -103,7 +103,7 @@ Value ObjectConstructor::set_prototype_of(Interpreter& interpreter) if (interpreter.exception()) return {}; object->set_prototype(&const_cast(interpreter.argument(1).as_object())); - return {}; + return object; } Value ObjectConstructor::is_extensible(Interpreter& interpreter) diff --git a/Libraries/LibJS/Tests/Object.setPrototypeOf.js b/Libraries/LibJS/Tests/Object.setPrototypeOf.js new file mode 100644 index 0000000000..c803865c1f --- /dev/null +++ b/Libraries/LibJS/Tests/Object.setPrototypeOf.js @@ -0,0 +1,12 @@ +load("test-common.js"); + +try { + assert(Object.setPrototypeOf.length === 2); + + o = {}; + assert(Object.setPrototypeOf(o, {}) === o); + + console.log("PASS"); +} catch (e) { + console.log("FAIL: " + e); +}