mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50: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 = heap().allocate<ConstructorType>();
|
||||||
constructor->put("name", js_string(heap(), property_name), Attribute::Configurable);
|
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);
|
put(property_name, constructor, Attribute::Writable | Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,34 @@
|
||||||
load("test-common.js");
|
load("test-common.js");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assert(Array.prototype.constructor === Array)
|
assert(Array.prototype.constructor === Array);
|
||||||
assert(Boolean.prototype.constructor === Boolean)
|
assert(Boolean.prototype.constructor === Boolean);
|
||||||
assert(Date.prototype.constructor === Date)
|
assert(Date.prototype.constructor === Date);
|
||||||
assert(Error.prototype.constructor === Error)
|
assert(Error.prototype.constructor === Error);
|
||||||
assert(Function.prototype.constructor === Function)
|
assert(Function.prototype.constructor === Function);
|
||||||
assert(Number.prototype.constructor === Number)
|
assert(Number.prototype.constructor === Number);
|
||||||
assert(Object.prototype.constructor === Object)
|
assert(Object.prototype.constructor === Object);
|
||||||
|
|
||||||
o = {}
|
o = {};
|
||||||
assert(o.constructor === Object)
|
assert(o.constructor === Object);
|
||||||
|
|
||||||
o = new Object
|
o = new Object();
|
||||||
assert(o.constructor === Object)
|
assert(o.constructor === Object);
|
||||||
|
|
||||||
a = []
|
a = [];
|
||||||
assert(a.constructor === Array)
|
assert(a.constructor === Array);
|
||||||
|
|
||||||
a = new Array
|
a = new Array();
|
||||||
assert(a.constructor === Array)
|
assert(a.constructor === Array);
|
||||||
|
|
||||||
n = new Number(3)
|
n = new Number(3);
|
||||||
assert(n.constructor === Number)
|
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");
|
console.log("PASS");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in a new issue