mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 21:25:20 +00:00

* use const instead of var * use assert.strictEqual instead of assert.equal PR-URL: https://github.com/nodejs/node/pull/10429 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
26 lines
585 B
JavaScript
26 lines
585 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const vm = require('vm');
|
|
|
|
const symbol = Symbol();
|
|
|
|
function Document() {
|
|
this[symbol] = 'foo';
|
|
}
|
|
|
|
Document.prototype.getSymbolValue = function() {
|
|
return this[symbol];
|
|
};
|
|
|
|
const context = new Document();
|
|
vm.createContext(context);
|
|
|
|
assert.strictEqual(context.getSymbolValue(), 'foo',
|
|
'should return symbol-keyed value from the outside');
|
|
|
|
assert.strictEqual(vm.runInContext('this.getSymbolValue()', context), 'foo',
|
|
'should return symbol-keyed value from the inside');
|