Bug 1055472 - Part 3: Make the Object constructor properly subclassable. (r=Waldo)

This commit is contained in:
Eric Faust 2015-11-13 18:22:21 -08:00
parent 298927c7c3
commit cc367ad748
3 changed files with 7 additions and 3 deletions

View File

@ -33,7 +33,12 @@ js::obj_construct(JSContext* cx, unsigned argc, Value* vp)
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, nullptr);
if (args.length() > 0 && !args[0].isNullOrUndefined()) {
if (args.isConstructing() && (&args.newTarget().toObject() != &args.callee())) {
RootedObject newTarget(cx, &args.newTarget().toObject());
obj = CreateThis(cx, &PlainObject::class_, newTarget);
if (!obj)
return false;
} else if (args.length() > 0 && !args[0].isNullOrUndefined()) {
obj = ToObject(cx, args[0]);
if (!obj)
return false;

View File

@ -16,6 +16,7 @@ function testBuiltin(builtin) {
testBuiltin(Function);
testBuiltin(Object);
`;

View File

@ -53,8 +53,6 @@ testBase(p);
handler.construct = (target, args, nt) => Reflect.construct(target, args, nt);
testBase(p);
// Object will have to wait for fixed builtins.
`;
if (classesEnabled())