mirror of https://github.com/lukechilds/node.git
Browse Source
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>v4.0.0-rc
Domenic Denicola
10 years ago
committed by
Rod Vagg
2 changed files with 67 additions and 28 deletions
@ -0,0 +1,25 @@ |
|||
'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'); |
Loading…
Reference in new issue