mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibJS: Make Object.prototype.constructor non-enumerable
This commit is contained in:
parent
9f064d4439
commit
b299c75d45
Notes:
sideshowbarker
2024-07-19 06:36:12 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/b299c75d455 Pull-request: https://github.com/SerenityOS/serenity/pull/2252
2 changed files with 24 additions and 18 deletions
|
@ -73,7 +73,7 @@ inline void GlobalObject::add_constructor(const FlyString& property_name, Constr
|
|||
{
|
||||
constructor = heap().allocate<ConstructorType>();
|
||||
constructor->put("name", js_string(heap(), property_name), Attribute::Configurable);
|
||||
prototype.put("constructor", constructor);
|
||||
prototype.put("constructor", constructor, Attribute::Writable | Attribute::Configurable);
|
||||
put(property_name, constructor, Attribute::Writable | Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,28 +1,34 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(Array.prototype.constructor === Array)
|
||||
assert(Boolean.prototype.constructor === Boolean)
|
||||
assert(Date.prototype.constructor === Date)
|
||||
assert(Error.prototype.constructor === Error)
|
||||
assert(Function.prototype.constructor === Function)
|
||||
assert(Number.prototype.constructor === Number)
|
||||
assert(Object.prototype.constructor === Object)
|
||||
assert(Array.prototype.constructor === Array);
|
||||
assert(Boolean.prototype.constructor === Boolean);
|
||||
assert(Date.prototype.constructor === Date);
|
||||
assert(Error.prototype.constructor === Error);
|
||||
assert(Function.prototype.constructor === Function);
|
||||
assert(Number.prototype.constructor === Number);
|
||||
assert(Object.prototype.constructor === Object);
|
||||
|
||||
o = {}
|
||||
assert(o.constructor === Object)
|
||||
o = {};
|
||||
assert(o.constructor === Object);
|
||||
|
||||
o = new Object
|
||||
assert(o.constructor === Object)
|
||||
o = new Object();
|
||||
assert(o.constructor === Object);
|
||||
|
||||
a = []
|
||||
assert(a.constructor === Array)
|
||||
a = [];
|
||||
assert(a.constructor === Array);
|
||||
|
||||
a = new Array
|
||||
assert(a.constructor === Array)
|
||||
a = new Array();
|
||||
assert(a.constructor === Array);
|
||||
|
||||
n = new Number(3)
|
||||
assert(n.constructor === Number)
|
||||
n = new Number(3);
|
||||
assert(n.constructor === Number);
|
||||
|
||||
d = Object.getOwnPropertyDescriptor(Object.prototype, "constructor");
|
||||
assert(d.configurable === true);
|
||||
assert(d.enumerable === false);
|
||||
assert(d.writable === true);
|
||||
assert(d.value === Object);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in a new issue