-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v8: handle proxy objects in MakeMirror(), v1
- Loading branch information
1 parent
9cb3ba5
commit af54fa6
Showing
3 changed files
with
35 additions
and
1 deletion.
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
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,30 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
|
||
const { MakeMirror } = vm.runInDebugContext('Debug'); | ||
const proxy = new Proxy({ x: 1, y: 2 }, { get: Reflect.get }); | ||
const mirror = MakeMirror(proxy, /* transient */ true); | ||
|
||
assert.strictEqual(mirror.protoObject().value(), undefined); | ||
assert.strictEqual(mirror.className(), 'Object'); | ||
assert.strictEqual(mirror.constructorFunction().value(), undefined); | ||
assert.strictEqual(mirror.prototypeObject().value(), undefined); | ||
assert.strictEqual(mirror.hasNamedInterceptor(), false); | ||
assert.strictEqual(mirror.hasIndexedInterceptor(), false); | ||
assert.strictEqual(mirror.referencedBy(1).length, 0); | ||
assert.strictEqual(mirror.toText(), '#<Object>'); | ||
|
||
const propertyNames = mirror.propertyNames(); | ||
const DebugContextArray = propertyNames.constructor; | ||
assert.deepStrictEqual(propertyNames, DebugContextArray.from(['x', 'y'])); | ||
|
||
const properties = mirror.properties(); | ||
assert.strictEqual(properties.length, 2); | ||
// UndefinedMirror because V8 cannot retrieve the values without invoking | ||
// the handler. Could be turned a PropertyMirror but mirror.value() would | ||
// still be an UndefinedMirror. This seems Good Enough for now. | ||
assert(properties[0].isUndefined()); | ||
assert(properties[1].isUndefined()); |