You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The calling convention for class constructors is totally different than ordinary functions: they expect newTarget in the arguments 0 slot, where "this" usually goes. Recent changes to fix the construction of bound functions regressed the construction of bound classes. This change adds support (and tests) for the class case.
Fixes OS:17555846
Fixes OS:17554002
assert.areNotEqual(boundObject,obj,"bound function should ignore bound this when constructing");
69
+
assert.areEqual("prop-value",obj["prop-name"],"bound function should keep bound arguments when constructing");
70
+
assert.areEqual(expectedConstructionCount,constructionCount,`proxy construct trap should be called ${expectedConstructionCount} times`);
71
+
assert.areEqual(expectedFunctionCallCount,functionCallCount,`base function-style constructor should be called ${expectedFunctionCallCount} times`);
72
+
assert.areEqual(expectedClassConstructorCount,classConstructorCount,`base class constructor should be called ${expectedClassConstructorCount} times`);
73
+
assert.strictEqual(expectedPrototype.prototype,obj.__proto__,useReflect ? "bound function should use explicit newTarget if provided" : "constructed object should be instance of original function");
74
+
assert.areEqual(expectedPrototype.prototype.protoVal,obj.localVal,"prototype should be available during construction");
75
+
}
76
+
32
77
consttests=[
33
78
{
34
79
name : "Construct trapped bound proxy with new",
35
80
body : function(){
36
-
constructionCount=0;
37
-
functionCallCount=0;
38
-
constobj=newboundTrapped("prop-value");
39
-
assert.areNotEqual(boundObject,obj,"bound function should ignore bound this when constructing");
40
-
assert.areEqual("prop-value",obj["prop-name"],"bound function should keep bound arguments when constructing");
41
-
assert.areEqual(1,constructionCount,"bound proxy should be constructed once");
42
-
assert.areEqual(1,functionCallCount,"bound proxy function should be called once");
43
-
assert.strictEqual(a.prototype,obj.__proto__,"constructed object should be instance of original function");
81
+
test(boundTrapped,false,a,1,1,0);
44
82
}
45
83
},
46
84
{
47
85
name : "Construct trapped bound proxy with Reflect",
0 commit comments