summaryrefslogtreecommitdiff
path: root/test/parallel/test-vm-symbols.js
diff options
context:
space:
mode:
authorDomenic Denicola <d@domenic.me>2015-06-01 12:22:19 -0400
committerRod Vagg <rod@vagg.org>2015-08-04 11:56:11 -0700
commit3b021efe11ea6828ed8c856167fc6f5e20b18fcc (patch)
tree0c0d2bd1101946d0607040a4bf0fdcb216aa69bd /test/parallel/test-vm-symbols.js
parent7b81e4ba36e8928b9e0309ccbea01b454982ca7a (diff)
downloadandroid-node-v8-3b021efe11ea6828ed8c856167fc6f5e20b18fcc.tar.gz
android-node-v8-3b021efe11ea6828ed8c856167fc6f5e20b18fcc.tar.bz2
android-node-v8-3b021efe11ea6828ed8c856167fc6f5e20b18fcc.zip
vm: fix symbol access
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>
Diffstat (limited to 'test/parallel/test-vm-symbols.js')
-rw-r--r--test/parallel/test-vm-symbols.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-vm-symbols.js b/test/parallel/test-vm-symbols.js
new file mode 100644
index 0000000000..d7d0ffe3af
--- /dev/null
+++ b/test/parallel/test-vm-symbols.js
@@ -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');