Skip to content

Commit 13ccb23

Browse files
committed
Test that polfill actually managed to be created
1 parent d6a11a2 commit 13ccb23

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
'use strict';
22
Object.defineProperty(
3-
String.prototype,
4-
Symbol('fake-polyfill-property'), {
3+
Object.prototype,
4+
'flatten', {
55
enumerable: false,
6-
value: null
6+
// purposefully named something that
7+
// would never land in JS itself
8+
value: function smoosh() {}
79
}
810
);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
'use strict';
2+
console.log({}.flatten.name);

test/parallel/test-preload.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const fixtureB = fixtures.path('printB.js');
2424
const fixtureC = fixtures.path('printC.js');
2525
const fixtureD = fixtures.path('define-global.js');
2626
const fixtureE = fixtures.path('intrinsic-mutation.js');
27+
const fixtureF = fixtures.path('print-intrinsic-mutation-name.js');
2728
const fixtureThrows = fixtures.path('throws_error4.js');
2829

2930
// Test preloading a single module works
@@ -65,18 +66,28 @@ childProcess.exec(
6566

6667
// Test that preload can be used with --frozen-intrinsics
6768
childProcess.exec(
68-
`"${nodeBinary}" --frozen-intrinsics ${preloadOption([fixtureE])}-e "console.log('hello');"`,
69+
`"${nodeBinary}" --frozen-intrinsics ${
70+
preloadOption([fixtureE])
71+
} ${
72+
fixtureF
73+
}`,
6974
function(err, stdout) {
7075
assert.ifError(err);
71-
assert.strictEqual(stdout, 'hello\n');
76+
assert.strictEqual(stdout, 'smoosh\n');
7277
}
7378
);
74-
const workerSrc = `const {Worker} = require('worker_threads');new Worker(${JSON.stringify(fixtureA)});`;
79+
const workerSrc = `new (require('worker_threads').Worker)(${fixtureF});`;
7580
childProcess.exec(
76-
`"${nodeBinary}" --frozen-intrinsics ${preloadOption([fixtureE])}-e ${JSON.stringify(workerSrc)}`,
81+
`"${
82+
nodeBinary
83+
}" --frozen-intrinsics ${
84+
preloadOption([fixtureE])
85+
}-e ${
86+
workerSrc
87+
}`,
7788
function(err, stdout) {
7889
assert.ifError(err);
79-
assert.strictEqual(stdout, 'A\n');
90+
assert.strictEqual(stdout, 'smoosh\n');
8091
}
8192
);
8293

0 commit comments

Comments
 (0)