Browse Source

v8: handle proxy objects in MakeMirror(), v1

PR-URL: https://github.com/nodejs/node/pull/14343
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
Ben Noordhuis 8 years ago
committed by Myles Borins
parent
commit
bccd2f59b0
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 2
      deps/v8/include/v8-version.h
  2. 4
      deps/v8/src/runtime/runtime-debug.cc
  3. 30
      test/parallel/test-debug-mirror-proxy.js

2
deps/v8/include/v8-version.h

@ -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.)

4
deps/v8/src/runtime/runtime-debug.cc

@ -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);
@ -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);
@ -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());
@ -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

30
test/parallel/test-debug-mirror-proxy.js

@ -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());
Loading…
Cancel
Save