0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/known_issues/test-vm-getters.js
AnnaMag 7ef2d90e1b test: fix assertion in vm test
Prototypes are not strict equal when they are from
different contexts. Therefore, assert.strictEqual()
fails for objects that are created in different
contexts, e.g., in vm.runInContext().

Instead of expecting the prototypes to be equal,
only check the properties of the objects
for equality.

PR-URL: https://github.com/nodejs/node/pull/11862
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2017-03-20 09:16:23 +01:00

25 lines
691 B
JavaScript

'use strict';
// Refs: https://github.com/nodejs/node/issues/2734
require('../common');
const assert = require('assert');
const vm = require('vm');
const sandbox = {};
Object.defineProperty(sandbox, 'prop', {
get() {
return 'foo';
}
});
const descriptor = Object.getOwnPropertyDescriptor(sandbox, 'prop');
const context = vm.createContext(sandbox);
const code = 'Object.getOwnPropertyDescriptor(this, "prop");';
const result = vm.runInContext(code, context);
// Ref: https://github.com/nodejs/node/issues/11803
assert.deepStrictEqual(Object.keys(result), Object.keys(descriptor));
for (const prop of Object.keys(result)) {
assert.strictEqual(result[prop], descriptor[prop]);
}