summaryrefslogtreecommitdiff
path: root/test/parallel/test-vm-symbols.js
blob: e5a4e9e756d17312143c618b2481ee9489cced50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'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');

assert.strictEqual(vm.runInContext('this.getSymbolValue()', context), 'foo');