dataPropertiesToRepair.js: add Function.prototype.constructor
MODIFY
src/bundle/dataPropertiesToRepair.js
src/bundle/dataPropertiesToRepair.js
@@ -78,6 +78,7 @@ export default {
Function: {
prototype: {
bind: t, // set by "underscore"
+ constructor: t, // set by "regenerator-runtime"
name: t,
toString: t,
},
@@ -105,7 +106,7 @@ export default {
GeneratorFunction: {
prototype: {
- constructor: t, // set by "regenerator-runtime"
+ constructor: t,
name: t,
toString: t,
},
@@ -113,6 +114,7 @@ export default {
AsyncFunction: {
prototype: {
+ constructor: t,
name: t,
toString: t,
},
@@ -120,6 +122,7 @@ export default {
AsyncGeneratorFunction: {
prototype: {
+ constructor: t,
name: t,
toString: t,
},

MODIFY
test/test-repairDataProperties.js
test/test-repairDataProperties.js
@@ -119,13 +119,25 @@ test('packages in-the-wild', t => {
try {
const s = SES.makeSESRootRealm();
- function testContent1() {
+ function testContent0() {
function* X() {
// empty
}
X.constructor = function XConstructor() {};
}
+ t.doesNotThrow(
+ () => s.evaluate(`(${testContent0})`)(),
+ 'generator function constructor',
+ );
+
+ function testContent1() {
+ function X() {
+ // empty
+ }
+ X.constructor = function XConstructor() {};
+ }
+
t.doesNotThrow(
() => s.evaluate(`(${testContent1})`)(),
'regenerator-runtime generator function constructor',

dataPropertiesToRepair.js: add Function.prototype.constructor