forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 nodejs#884.
- Loading branch information
Showing
2 changed files
with
67 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |