Bug 1055472 - Part 11: Make the WeakMap constructor properly subclassable. (r=Waldo)
authorEric Faust <efaustbmo@gmail.com>
Fri, 13 Nov 2015 18:22:21 -0800
changeset 275614 40b67434bff60d5a3a6a7a5aeeda6c7e1e83b70e
parent 275613 57cf6353c9fb31f250c26a93b8a460140359e572
child 275615 579411961394179050dd1678e8a4f8d08dfc94f7
push id68893
push userefaustbmo@gmail.com
push dateFri, 04 Dec 2015 06:36:43 +0000
treeherdermozilla-inbound@ca6084eaafbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1055472
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1055472 - Part 11: Make the WeakMap constructor properly subclassable. (r=Waldo)
js/src/builtin/WeakMapObject.cpp
js/src/tests/ecma_6/Class/extendBuiltinConstructors.js
--- a/js/src/builtin/WeakMapObject.cpp
+++ b/js/src/builtin/WeakMapObject.cpp
@@ -311,17 +311,18 @@ static bool
 WeakMap_construct(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     // ES6 draft rev 31 (15 Jan 2015) 23.3.1.1 step 1.
     if (!ThrowIfNotConstructing(cx, args, "WeakMap"))
         return false;
 
-    RootedObject obj(cx, NewBuiltinClassInstance(cx, &WeakMapObject::class_));
+    RootedObject newTarget(cx, &args.newTarget().toObject());
+    RootedObject obj(cx, CreateThis(cx, &WeakMapObject::class_, newTarget));
     if (!obj)
         return false;
 
     // Steps 5-6, 11.
     if (!args.get(0).isNullOrUndefined()) {
         // Steps 7a-b.
         RootedValue adderVal(cx);
         if (!GetProperty(cx, obj, obj, cx->names().set, &adderVal))
--- a/js/src/tests/ecma_6/Class/extendBuiltinConstructors.js
+++ b/js/src/tests/ecma_6/Class/extendBuiltinConstructors.js
@@ -29,16 +29,17 @@ testBuiltin(Number);
 testBuiltin(Date);
 testBuiltin(Date, 5);
 testBuiltin(Date, 5, 10);
 testBuiltin(RegExp);
 testBuiltin(RegExp, /Regexp Argument/);
 testBuiltin(RegExp, "String Argument");
 testBuiltin(Map);
 testBuiltin(Set);
+testBuiltin(WeakMap);
 
 `;
 
 if (classesEnabled())
     eval(test);
 
 if (typeof reportCompare === 'function')
     reportCompare(0,0,"OK");