Skip to content

Commit

Permalink
v8: handle proxy objects in MakeMirror(), v1
Browse files Browse the repository at this point in the history
PR-URL: #14343
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
bnoordhuis authored and MylesBorins committed Sep 5, 2017
1 parent 4963228 commit bccd2f5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 5
#define V8_MINOR_VERSION 1
#define V8_BUILD_NUMBER 281
#define V8_PATCH_LEVEL 105
#define V8_PATCH_LEVEL 106

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
4 changes: 4 additions & 0 deletions deps/v8/src/runtime/runtime-debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) {

DCHECK(args.length() == 2);

if (args[0]->IsJSProxy()) return isolate->heap()->undefined_value();
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);

Expand Down Expand Up @@ -382,6 +383,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetProperty) {

DCHECK(args.length() == 2);

if (args[0]->IsJSProxy()) return isolate->heap()->undefined_value();
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);

Expand Down Expand Up @@ -1318,6 +1320,7 @@ static bool HasInPrototypeChainIgnoringProxies(Isolate* isolate,
RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
if (!args[0]->IsJSObject()) return *isolate->factory()->NewJSArray(0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1);
RUNTIME_ASSERT(filter->IsUndefined() || filter->IsJSObject());
Expand Down Expand Up @@ -1408,6 +1411,7 @@ RUNTIME_FUNCTION(Runtime_DebugConstructedBy) {
RUNTIME_FUNCTION(Runtime_DebugGetPrototype) {
HandleScope shs(isolate);
DCHECK(args.length() == 1);
if (args[0]->IsJSProxy()) return isolate->heap()->undefined_value();
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
Handle<Object> prototype;
// TODO(1543): Come up with a solution for clients to handle potential errors
Expand Down
30 changes: 30 additions & 0 deletions test/parallel/test-debug-mirror-proxy.js
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());

0 comments on commit bccd2f5

Please sign in to comment.