Skip to content

Commit

Permalink
tests: undefined variable "self" should be void 0 in the vm
Browse files Browse the repository at this point in the history
  • Loading branch information
watilde committed Jun 16, 2016
1 parent 3445876 commit 79c4657
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tests/noderunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function runTest(testPath) {
var content,
context = LIBS.vm.createContext({});

context.self = void 0;

content = LIBS.fs.readFileSync(LIBS.path.resolve(TEST_DIR, testPath)).toString();
LIBS.vm.runInContext(POLYFILL_CODE, context, POLYFILL_PATH);
LIBS.vm.runInContext(DATA_CODE, context, DATA_PATH);
Expand Down
8 changes: 5 additions & 3 deletions tests/polyfilling.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function assert(value, expected, message) {

const context = new vm.createContext();
var script = new vm.Script('this');
context.self = void 0;
const window = script.runInContext(context);

const fs = require('fs');
Expand All @@ -22,10 +23,11 @@ window.window = window; // circular, in case the polyfill uses window
var originalIntl = window.Intl;
var script = new vm.Script(code);
script.runInContext(context);
assert(typeof global.Intl, 'object', 'for this test to function, global.Intl is required');
assert(typeof window.Intl, 'object', 'for this test to function, window.Intl is required');
assert(typeof window.IntlPolyfill, 'object', 'polyfill should always add the custom global IntlPolyfill');
assert(window.Intl, originalIntl, 'validating that the polyfilling process does not touch the original Intl value');

if (originalIntl) {
assert(window.Intl, originalIntl, 'validating that the polyfilling process does not touch the original Intl value if it exists');
}
// second evaluation
window.window = window; // circular, in case the polyfill uses window
window.Intl = undefined; // disabling Intl
Expand Down

0 comments on commit 79c4657

Please sign in to comment.