mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 18:02:21 +00:00

By using the new SetHandler API instead of SetNamedPropertyHandler, we can intercept symbols now. This forces us to use Maybes and MaybeLocals more, since this new API does not have a non-maybe variant. Fixes: https://github.com/nodejs/io.js/issues/884 PR-URL: https://github.com/nodejs/io.js/pull/1773 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
26 lines
548 B
JavaScript
26 lines
548 B
JavaScript
'use strict';
|
|
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
var vm = require('vm');
|
|
|
|
var symbol = Symbol();
|
|
|
|
function Document() {
|
|
this[symbol] = 'foo';
|
|
}
|
|
|
|
Document.prototype.getSymbolValue = function() {
|
|
return this[symbol];
|
|
};
|
|
|
|
var context = new Document();
|
|
vm.createContext(context);
|
|
|
|
assert.equal(context.getSymbolValue(), 'foo',
|
|
'should return symbol-keyed value from the outside');
|
|
|
|
assert.equal(vm.runInContext('this.getSymbolValue()', context), 'foo',
|
|
'should return symbol-keyed value from the inside');
|