Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit 79c4657

Browse files
committed
tests: undefined variable "self" should be void 0 in the vm
1 parent 3445876 commit 79c4657

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tests/noderunner.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ function runTest(testPath) {
1717
var content,
1818
context = LIBS.vm.createContext({});
1919

20+
context.self = void 0;
21+
2022
content = LIBS.fs.readFileSync(LIBS.path.resolve(TEST_DIR, testPath)).toString();
2123
LIBS.vm.runInContext(POLYFILL_CODE, context, POLYFILL_PATH);
2224
LIBS.vm.runInContext(DATA_CODE, context, DATA_PATH);

tests/polyfilling.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function assert(value, expected, message) {
1212

1313
const context = new vm.createContext();
1414
var script = new vm.Script('this');
15+
context.self = void 0;
1516
const window = script.runInContext(context);
1617

1718
const fs = require('fs');
@@ -22,10 +23,11 @@ window.window = window; // circular, in case the polyfill uses window
2223
var originalIntl = window.Intl;
2324
var script = new vm.Script(code);
2425
script.runInContext(context);
25-
assert(typeof global.Intl, 'object', 'for this test to function, global.Intl is required');
26+
assert(typeof window.Intl, 'object', 'for this test to function, window.Intl is required');
2627
assert(typeof window.IntlPolyfill, 'object', 'polyfill should always add the custom global IntlPolyfill');
27-
assert(window.Intl, originalIntl, 'validating that the polyfilling process does not touch the original Intl value');
28-
28+
if (originalIntl) {
29+
assert(window.Intl, originalIntl, 'validating that the polyfilling process does not touch the original Intl value if it exists');
30+
}
2931
// second evaluation
3032
window.window = window; // circular, in case the polyfill uses window
3133
window.Intl = undefined; // disabling Intl

0 commit comments

Comments
 (0)