diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index 4cf7b87209..b9f400de63 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -133,6 +133,8 @@ Optional Object::get(const FlyString& property_name) const void Object::put(const FlyString& property_name, Value value) { + // If there's a setter in the prototype chain, we go to the setter. + // Otherwise, it goes in the own property storage. Object* object = this; while (object) { auto metadata = object->shape().lookup(property_name); @@ -147,8 +149,6 @@ void Object::put(const FlyString& property_name, Value value) interpreter.pop_call_frame(); return; } - if (object->put_own_property(*this, property_name, value)) - return; } object = object->prototype(); } diff --git a/Libraries/LibJS/Tests/Object.prototype.toString.js b/Libraries/LibJS/Tests/Object.prototype.toString.js new file mode 100644 index 0000000000..a56a377870 --- /dev/null +++ b/Libraries/LibJS/Tests/Object.prototype.toString.js @@ -0,0 +1,8 @@ +function assert(x) { if (!x) throw 1; } + +try { + assert(typeof Object.prototype.toString() === "string"); + console.log("PASS"); +} catch (e) { + console.log("FAIL: " + e); +}